Skip to content

Commit

Permalink
Fix protected default, add a unit test for SQLX config parameters (#1718
Browse files Browse the repository at this point in the history
)

* Fix protected default, add a general unit test for SQLX config parameters

* Tidy

* Remove test for incremental tables that is now duplicate

* Remove protected field from being expected in actions where it is invalid

* Reset run_tests script
  • Loading branch information
Ekrekr committed Jun 26, 2024
1 parent b787f18 commit c52cabb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
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

0 comments on commit c52cabb

Please sign in to comment.