Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions core/actions/declaration_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,62 @@ actions:
])
);
});

test(`SQLx backward compatible with LegacyConfig`, () => {
const projectDir = tmpDirFixture.createNewTmpDir();
fs.writeFileSync(path.join(projectDir, "workflow_settings.yaml"), VALID_WORKFLOW_SETTINGS_YAML);
fs.mkdirSync(path.join(projectDir, "definitions"));
fs.writeFileSync(
path.join(projectDir, "definitions/legacy.sqlx"),
`config {
type: "declaration",
name: "legacy",
dataset: "legacyDataset",
project: "legacyProject"
}`
);
fs.writeFileSync(
path.join(projectDir, "definitions/current.sqlx"),
`config {
type: "declaration",
name: "current",
schema: "currentSchema",
database: "currentDatabase"
}`
);

const result = runMainInVm(coreExecutionRequestFromPath(projectDir));

expect(result.compile.compiledGraph.graphErrors.compilationErrors).deep.equals([]);
expect(asPlainObject(result.compile.compiledGraph.declarations)).deep.equals(
asPlainObject([
{
target: {
database: "currentDatabase",
schema: "currentSchema",
name: "current"
},
canonicalTarget: {
database: "currentDatabase",
schema: "currentSchema",
name: "current"
},
fileName: "definitions/current.sqlx"
},
{
target: {
database: "legacyProject",
schema: "legacyDataset",
name: "legacy"
},
canonicalTarget: {
database: "legacyProject",
schema: "legacyDataset",
name: "legacy"
},
fileName: "definitions/legacy.sqlx"
},
])
);
});
});
3 changes: 0 additions & 3 deletions core/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ export class Session {
"Actions may only include incremental_where if they are of type 'incremental'."
);
}
if (!sqlxConfig.hasOwnProperty("schema") && actionType === "declaration") {
this.compileError("Actions of type 'declaration' must specify a value for 'schema'.");
}
if (actionOptions.inputContextables.length > 0 && actionType !== "test") {
this.compileError("Actions may only include input blocks if they are of type 'test'.");
}
Expand Down