Skip to content

Commit

Permalink
Fix UUID expression
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Dec 1, 2024
1 parent ba9a538 commit ee609b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/Column/ColumnDefinitionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ final class ColumnDefinitionBuilder extends AbstractColumnDefinitionBuilder
{
protected const AUTO_INCREMENT_KEYWORD = 'AUTOINCREMENT';

protected const GENERATE_UUID_EXPRESSION =
"(unhex(format('%016X', random() & 0xFFFFFFFFFFFF4FFF | 0x4000) || format('%016X', random() & 0xBFFFFFFFFFFFFFFF | 0xB000000000000000)))";
protected const GENERATE_UUID_EXPRESSION = '(randomblob(16))';

protected const TYPES_WITH_SIZE = [
'bit',
Expand Down
6 changes: 3 additions & 3 deletions tests/Provider/QueryBuilderProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,15 @@ public static function buildColumnDefinition(): array
$values[PseudoType::UPK][0] = 'integer PRIMARY KEY AUTOINCREMENT NOT NULL';
$values[PseudoType::BIGPK][0] = 'integer PRIMARY KEY AUTOINCREMENT NOT NULL';
$values[PseudoType::UBIGPK][0] = 'integer PRIMARY KEY AUTOINCREMENT NOT NULL';
$values[PseudoType::UUID_PK][0] = "blob(16) PRIMARY KEY NOT NULL DEFAULT (unhex(format('%016X', random() & 0xFFFFFFFFFFFF4FFF | 0x4000) || format('%016X', random() & 0xBFFFFFFFFFFFFFFF | 0xB000000000000000)))";
$values[PseudoType::UUID_PK_SEQ][0] = "blob(16) PRIMARY KEY NOT NULL DEFAULT (unhex(format('%016X', random() & 0xFFFFFFFFFFFF4FFF | 0x4000) || format('%016X', random() & 0xBFFFFFFFFFFFFFFF | 0xB000000000000000)))";
$values[PseudoType::UUID_PK][0] = 'blob(16) PRIMARY KEY NOT NULL DEFAULT (randomblob(16))';
$values[PseudoType::UUID_PK_SEQ][0] = 'blob(16) PRIMARY KEY NOT NULL DEFAULT (randomblob(16))';
$values['primaryKey()'][0] = 'integer PRIMARY KEY AUTOINCREMENT NOT NULL';
$values['primaryKey(false)'][0] = 'integer PRIMARY KEY NOT NULL';
$values['smallPrimaryKey()'][0] = 'integer PRIMARY KEY AUTOINCREMENT NOT NULL';
$values['smallPrimaryKey(false)'][0] = 'smallint PRIMARY KEY NOT NULL';
$values['bigPrimaryKey()'][0] = 'integer PRIMARY KEY AUTOINCREMENT NOT NULL';
$values['bigPrimaryKey(false)'][0] = 'bigint PRIMARY KEY NOT NULL';
$values['uuidPrimaryKey()'][0] = "blob(16) PRIMARY KEY NOT NULL DEFAULT (unhex(format('%016X', random() & 0xFFFFFFFFFFFF4FFF | 0x4000) || format('%016X', random() & 0xBFFFFFFFFFFFFFFF | 0xB000000000000000)))";
$values['uuidPrimaryKey()'][0] = 'blob(16) PRIMARY KEY NOT NULL DEFAULT (randomblob(16))';
$values['uuidPrimaryKey(false)'][0] = 'blob(16) PRIMARY KEY NOT NULL';
$values['money()'][0] = 'decimal(19,4)';
$values['money(10)'][0] = 'decimal(10,4)';
Expand Down

0 comments on commit ee609b3

Please sign in to comment.