Skip to content

Commit d997e05

Browse files
committed
fix default
1 parent 8990b8b commit d997e05

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

src/Definition/Bigquery.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ public function __construct(string $type, array $options = [])
105105
if ($diff !== []) {
106106
throw new InvalidOptionException("Option '{$diff[0]}' not supported");
107107
}
108+
109+
if (array_key_exists('default', $options) && $options['default'] === '') {
110+
unset($options['default']);
111+
}
108112
parent::__construct($type, $options);
109113
}
110114

tests/BigqueryDatatypeTest.php

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,13 @@ public function expectedSqlDefinitions(): array
183183
];
184184
$tests[] = [
185185
$type,
186-
['length' => '30,2', 'default' => '(10.00)'],
187-
$type . '(30,2) DEFAULT (10.00)',
186+
['length' => '30,2', 'default' => '10.00'],
187+
$type . '(30,2) DEFAULT 10.00',
188188
];
189189
$tests[] = [
190190
$type,
191-
['length' => '30,2', 'default' => '(10.00)', 'nullable' => false],
192-
$type . '(30,2) NOT NULL DEFAULT (10.00)',
191+
['length' => '30,2', 'default' => '10.00', 'nullable' => false],
192+
$type . '(30,2) NOT NULL DEFAULT 10.00',
193193
];
194194
}
195195

@@ -211,13 +211,13 @@ public function expectedSqlDefinitions(): array
211211
];
212212
$tests[] = [
213213
$type,
214-
['length' => '76,38', 'default' => '(10.00)'],
215-
$type . '(76,38) DEFAULT (10.00)',
214+
['length' => '76,38', 'default' => '10.00'],
215+
$type . '(76,38) DEFAULT 10.00',
216216
];
217217
$tests[] = [
218218
$type,
219-
['length' => '76,38', 'default' => '(10.00)', 'nullable' => false],
220-
$type . '(76,38) NOT NULL DEFAULT (10.00)',
219+
['length' => '76,38', 'default' => '10.00', 'nullable' => false],
220+
$type . '(76,38) NOT NULL DEFAULT 10.00',
221221
];
222222
}
223223

@@ -232,6 +232,21 @@ public function expectedSqlDefinitions(): array
232232
[],
233233
$type,
234234
];
235+
$tests[] = [
236+
$type,
237+
['default' => '\'\'', 'nullable' => false],
238+
$type . ' NOT NULL DEFAULT \'\'',
239+
];
240+
$tests[] = [
241+
$type,
242+
['default' => ''],
243+
$type,
244+
];
245+
$tests[] = [
246+
$type,
247+
['default' => '', 'nullable' => false],
248+
$type . ' NOT NULL',
249+
];
235250
$tests[] = [
236251
$type,
237252
['length' => '1000'],

0 commit comments

Comments
 (0)