From 145846e124243faa0c9ba55bb6fa29545ba7cc99 Mon Sep 17 00:00:00 2001 From: Jiri Semmler Date: Tue, 30 Jul 2024 01:22:33 +0200 Subject: [PATCH 1/6] CT-1673 test BQ column cannot be set as required --- tests/Backend/Bigquery/TableDefinitionOperationsTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/Backend/Bigquery/TableDefinitionOperationsTest.php b/tests/Backend/Bigquery/TableDefinitionOperationsTest.php index c056d064b..0bee7e64d 100644 --- a/tests/Backend/Bigquery/TableDefinitionOperationsTest.php +++ b/tests/Backend/Bigquery/TableDefinitionOperationsTest.php @@ -2062,6 +2062,14 @@ public function testInvalidUpdateTableDefinition( public function failedOperationsProvider(): Generator { + yield 'set as required' => [ + 'decrease_precision', + [ + 'nullable' => false, + ], + 'Invalid request: + - nullable: "BigQuery column cannot be set as required"', + ]; yield 'decrease_length' => [ 'decrease_length', [ From cafe6aa623a1fba12f103deb9351b904ba5dfb3e Mon Sep 17 00:00:00 2001 From: Jiri Semmler Date: Tue, 30 Jul 2024 01:24:39 +0200 Subject: [PATCH 2/6] CT-1673 docs --- apiary.apib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apiary.apib b/apiary.apib index 99d059527..1ce602548 100644 --- a/apiary.apib +++ b/apiary.apib @@ -2602,7 +2602,7 @@ Supported alterations: + Attributes + length (string) - optional, supports numeric value for all columns (e.g. `12`) and complex length for numeric columns (e.g. `12,2`) - + nullable (boolean) - optional + + nullable (boolean) - optional, on BigQuery, if set, it has to be set as true + default (string) - optional, default value for column, null unsets default value + Request (application/json) From 4880974e1ea2c9ad6f554370402bdeacf600d308 Mon Sep 17 00:00:00 2001 From: Jiri Semmler Date: Tue, 30 Jul 2024 09:11:34 +0200 Subject: [PATCH 3/6] CT-1673 add test cases --- .../TableDefinitionOperationsTest.php | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/Backend/Bigquery/TableDefinitionOperationsTest.php b/tests/Backend/Bigquery/TableDefinitionOperationsTest.php index 0bee7e64d..064f93590 100644 --- a/tests/Backend/Bigquery/TableDefinitionOperationsTest.php +++ b/tests/Backend/Bigquery/TableDefinitionOperationsTest.php @@ -1824,7 +1824,7 @@ public function testUpdateTableDefinition(): void 'length' => '12,1', ], ], - //drop nullable + // nullable [ 'name' => 'longint_nullable', 'definition' => [ @@ -1873,20 +1873,30 @@ public function testUpdateTableDefinition(): void 'default' => null, ], ); - //add nullable + // required -> required $this->_client->updateTableColumnDefinition( $tableId, 'longint_non_nullable', [ - 'nullable' => true, + 'nullable' => false, ], ); - //drop nullable + $tableDetail = $this->_client->getTable($tableId); + // nullable -> nullable $this->_client->updateTableColumnDefinition( $tableId, 'longint_nullable', [ - 'nullable' => false, + 'nullable' => true, + ], + ); + $tableDetail = $this->_client->getTable($tableId); + //add nullable + $this->_client->updateTableColumnDefinition( + $tableId, + 'longint_non_nullable', + [ + 'nullable' => true, ], ); //increase length of text column From 7862330ee5a8e900e1a3c560b3f0864fd9671468 Mon Sep 17 00:00:00 2001 From: Jiri Semmler Date: Tue, 30 Jul 2024 09:13:46 +0200 Subject: [PATCH 4/6] note in docs --- apiary.apib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apiary.apib b/apiary.apib index 1ce602548..7aa9daa2e 100644 --- a/apiary.apib +++ b/apiary.apib @@ -2602,7 +2602,7 @@ Supported alterations: + Attributes + length (string) - optional, supports numeric value for all columns (e.g. `12`) and complex length for numeric columns (e.g. `12,2`) - + nullable (boolean) - optional, on BigQuery, if set, it has to be set as true + + nullable (boolean) - optional, on BigQuery operation "set as required" (nullable=true -> nullable=false) is not allowed + default (string) - optional, default value for column, null unsets default value + Request (application/json) From 3a3e293ff6cb0d4b0a8c4d4ca96ea804399f39d1 Mon Sep 17 00:00:00 2001 From: Jiri Semmler Date: Tue, 30 Jul 2024 09:23:31 +0200 Subject: [PATCH 5/6] remove vars --- tests/Backend/Bigquery/TableDefinitionOperationsTest.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/Backend/Bigquery/TableDefinitionOperationsTest.php b/tests/Backend/Bigquery/TableDefinitionOperationsTest.php index 064f93590..27157e99a 100644 --- a/tests/Backend/Bigquery/TableDefinitionOperationsTest.php +++ b/tests/Backend/Bigquery/TableDefinitionOperationsTest.php @@ -1881,7 +1881,6 @@ public function testUpdateTableDefinition(): void 'nullable' => false, ], ); - $tableDetail = $this->_client->getTable($tableId); // nullable -> nullable $this->_client->updateTableColumnDefinition( $tableId, @@ -1890,7 +1889,6 @@ public function testUpdateTableDefinition(): void 'nullable' => true, ], ); - $tableDetail = $this->_client->getTable($tableId); //add nullable $this->_client->updateTableColumnDefinition( $tableId, @@ -1942,7 +1940,6 @@ public function testUpdateTableDefinition(): void 'basetype' => 'NUMERIC', 'canBeFiltered' => true, ], - //drop nullable - won't have any affect because in BQ nullable->required is not possible [ 'name' => 'longint_nullable', 'definition' => [ From 091b4008c2b37e9636281c5daaf77373e4c8faa6 Mon Sep 17 00:00:00 2001 From: Jiri Semmler Date: Tue, 30 Jul 2024 09:24:57 +0200 Subject: [PATCH 6/6] note --- tests/Backend/Bigquery/TableDefinitionOperationsTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Backend/Bigquery/TableDefinitionOperationsTest.php b/tests/Backend/Bigquery/TableDefinitionOperationsTest.php index 27157e99a..8579792d1 100644 --- a/tests/Backend/Bigquery/TableDefinitionOperationsTest.php +++ b/tests/Backend/Bigquery/TableDefinitionOperationsTest.php @@ -1889,7 +1889,8 @@ public function testUpdateTableDefinition(): void 'nullable' => true, ], ); - //add nullable + // add nullable + // - actual change which is allowed. Drop nullable is not allowed -> testInvalidUpdateTableDefinition $this->_client->updateTableColumnDefinition( $tableId, 'longint_non_nullable',