Skip to content

Commit

Permalink
Make overriding 'database' work for declarations. (#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenBirt authored Dec 19, 2019
1 parent 6f5b58c commit 1976929
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions core/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export class Session {
return this.operate(actionOptions.sqlxConfig.name);
case "declaration":
return this.declare({
database: actionOptions.sqlxConfig.database,
schema: actionOptions.sqlxConfig.schema,
name: actionOptions.sqlxConfig.name
});
Expand Down
1 change: 1 addition & 0 deletions examples/common_v2/definitions/example_declaration.sqlx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
config {
type: "declaration",
database: "some_database_name",
schema: "some_external_schema_name",
name: "very_important_external_table",
description: "This table is not generated by Dataform!"
Expand Down
9 changes: 5 additions & 4 deletions tests/api/examples.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,10 @@ describe("examples", () => {
expect(exampleOperationWithOutput.queries).to.eql([
`\nCREATE OR REPLACE VIEW \`tada-analytics.${schemaWithSuffix(
"df_integration_test"
)}.example_operation_with_output\` AS (SELECT * FROM \`tada-analytics.some_external_schema_name.very_important_external_table\`)`
)}.example_operation_with_output\` AS (SELECT * FROM \`some_database_name.some_external_schema_name.very_important_external_table\`)`
]);
expect(exampleOperationWithOutput.dependencies).to.eql([
"tada-analytics.some_external_schema_name.very_important_external_table"
"some_database_name.some_external_schema_name.very_important_external_table"
]);
expect(exampleOperationWithOutput.actionDescriptor).to.eql(
dataform.ActionDescriptor.create({
Expand All @@ -424,12 +424,13 @@ describe("examples", () => {

// Check declaration.
const exampleDeclaration = graph.declarations.find(
d => d.name === "tada-analytics.some_external_schema_name.very_important_external_table"
d =>
d.name === "some_database_name.some_external_schema_name.very_important_external_table"
);
expect(exampleDeclaration).to.not.be.undefined;
expect(exampleDeclaration.target).eql(
dataform.Target.create({
database: "tada-analytics",
database: "some_database_name",
schema: "some_external_schema_name",
name: "very_important_external_table"
})
Expand Down
2 changes: 1 addition & 1 deletion version.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# NOTE: If you change the format of this line, you must change the bash command
# in /scripts/publish to extract the version string correctly.
DF_VERSION = "1.4.5"
DF_VERSION = "1.4.6"

0 comments on commit 1976929

Please sign in to comment.