Skip to content

Commit

Permalink
Improve
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Nov 8, 2024
1 parent e84d5ad commit 2fe0944
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Column/ColumnFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnSche
if ($value[0] === "'" && $value[-1] === "'") {
$value = substr($value, 1, -1);

if (str_starts_with($value, '\\x')) {
if ($column->getType() === ColumnType::BINARY && str_starts_with($value, '\\x')) {
return hex2bin(substr($value, 2));
}

Expand Down
1 change: 1 addition & 0 deletions tests/Provider/ColumnFactoryProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public static function defaultValueRaw(): array
$defaultValueRaw[] = [ColumnType::TEXT, "'str''ing'::\"text\"", "str'ing"];
$defaultValueRaw[] = [ColumnType::INTEGER, '(-1)::"int"', -1];
$defaultValueRaw[] = [ColumnType::BIT, "B'1011'::\"bit\"", 0b1011];
$defaultValueRaw[] = [ColumnType::STRING, "'\\x737472696e67'", '\\x737472696e67'];
$defaultValueRaw[] = [ColumnType::BINARY, "'\\x737472696e67'::bytea", 'string'];

return $defaultValueRaw;
Expand Down

0 comments on commit 2fe0944

Please sign in to comment.