Skip to content

Commit

Permalink
Merge pull request #1380 from keboola/jirka-ct-1673-test-bq-set-required
Browse files Browse the repository at this point in the history
CT-1673 test BQ column cannot be set as required
  • Loading branch information
jirkasemmler committed Jul 30, 2024
2 parents 10adaea + 091b400 commit f978051
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apiary.apib
Original file line number Diff line number Diff line change
Expand Up @@ -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 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)
Expand Down
28 changes: 22 additions & 6 deletions tests/Backend/Bigquery/TableDefinitionOperationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1824,7 +1824,7 @@ public function testUpdateTableDefinition(): void
'length' => '12,1',
],
],
//drop nullable
// nullable
[
'name' => 'longint_nullable',
'definition' => [
Expand Down Expand Up @@ -1873,20 +1873,29 @@ public function testUpdateTableDefinition(): void
'default' => null,
],
);
//add nullable
// required -> required
$this->_client->updateTableColumnDefinition(
$tableId,
'longint_non_nullable',
[
'nullable' => true,
'nullable' => false,
],
);
//drop nullable
// nullable -> nullable
$this->_client->updateTableColumnDefinition(
$tableId,
'longint_nullable',
[
'nullable' => false,
'nullable' => true,
],
);
// add nullable
// - actual change which is allowed. Drop nullable is not allowed -> testInvalidUpdateTableDefinition
$this->_client->updateTableColumnDefinition(
$tableId,
'longint_non_nullable',
[
'nullable' => true,
],
);
//increase length of text column
Expand Down Expand Up @@ -1932,7 +1941,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' => [
Expand Down Expand Up @@ -2062,6 +2070,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',
[
Expand Down

0 comments on commit f978051

Please sign in to comment.