Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix protected default, add a unit test for SQLX config parameters #1718

Merged
merged 6 commits into from
Jun 26, 2024
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
12 changes: 8 additions & 4 deletions core/actions/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ export class Table extends ActionBuilder<dataform.Table> {
if (config.disabled) {
this.disabled();
}
if (config.protected) {
this.protected();
if (config.type === "incremental") {
this.protected(config.protected);
}
if (config.bigquery && Object.keys(config.bigquery).length > 0) {
this.bigquery(config.bigquery);
Expand Down Expand Up @@ -536,8 +536,12 @@ export class Table extends ActionBuilder<dataform.Table> {
return this;
}

public protected() {
this.proto.protected = true;
public protected(defaultsToTrueProtected: boolean) {
// To prevent accidental data deletion, protected defaults to true if unspecified.
if (defaultsToTrueProtected === undefined || defaultsToTrueProtected === null) {
defaultsToTrueProtected = true;
}
this.proto.protected = defaultsToTrueProtected;
return this;
}

Expand Down
7 changes: 1 addition & 6 deletions core/main_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1603,8 +1603,6 @@ SELECT 1`
},
type: "table",
disabled: true,
// TODO(ekrekr): finish fixing this in https://github.com/dataform-co/dataform/pull/1718.
// protected: false,
hermeticity: "HERMETIC",
bigquery: {
additionalOptions: {
Expand Down Expand Up @@ -1697,8 +1695,6 @@ SELECT 1`
},
type: "view",
disabled: true,
// TODO(ekrekr): finish fixing this in https://github.com/dataform-co/dataform/pull/1718.
// protected: false,
hermeticity: "HERMETIC",
bigquery: {
additionalOptions: {
Expand Down Expand Up @@ -1794,8 +1790,7 @@ SELECT 1`
},
type: "incremental",
disabled: true,
// TODO(ekrekr): finish fixing this in https://github.com/dataform-co/dataform/pull/1718.
// protected: false,
protected: false,
hermeticity: "HERMETIC",
bigquery: {
additionalOptions: {
Expand Down
3 changes: 2 additions & 1 deletion tests/core/core.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ suite("@dataform/core", () => {
disabled: false,
fileName: path.basename(__filename),
type: "incremental",
enumType: "INCREMENTAL"
enumType: "INCREMENTAL",
protected: true
}
]);
});
Expand Down
Loading