|
5 | 5 | namespace Yiisoft\Db\Pgsql\Tests\Provider;
|
6 | 6 |
|
7 | 7 | use Yiisoft\Db\Constant\ColumnType;
|
| 8 | +use Yiisoft\Db\Constant\PseudoType; |
8 | 9 | use Yiisoft\Db\Expression\ArrayExpression;
|
9 | 10 | use Yiisoft\Db\Expression\Expression;
|
10 | 11 | use Yiisoft\Db\Expression\JsonExpression;
|
@@ -536,4 +537,60 @@ public static function overlapsCondition(): array
|
536 | 537 |
|
537 | 538 | return $data;
|
538 | 539 | }
|
| 540 | + |
| 541 | + public static function buildColumnDefinition(): array |
| 542 | + { |
| 543 | + $values = parent::buildColumnDefinition(); |
| 544 | + |
| 545 | + $values[PseudoType::PK][0] = 'serial PRIMARY KEY'; |
| 546 | + $values[PseudoType::UPK][0] = 'serial PRIMARY KEY'; |
| 547 | + $values[PseudoType::BIGPK][0] = 'bigserial PRIMARY KEY'; |
| 548 | + $values[PseudoType::UBIGPK][0] = 'bigserial PRIMARY KEY'; |
| 549 | + $values[PseudoType::UUID_PK][0] = 'uuid PRIMARY KEY DEFAULT gen_random_uuid()'; |
| 550 | + $values[PseudoType::UUID_PK_SEQ][0] = 'uuid PRIMARY KEY DEFAULT gen_random_uuid()'; |
| 551 | + $values['primaryKey()'][0] = 'serial PRIMARY KEY'; |
| 552 | + $values['smallPrimaryKey()'][0] = 'smallserial PRIMARY KEY'; |
| 553 | + $values['bigPrimaryKey()'][0] = 'bigserial PRIMARY KEY'; |
| 554 | + $values['uuidPrimaryKey()'][0] = 'uuid PRIMARY KEY DEFAULT gen_random_uuid()'; |
| 555 | + $values['bit()'][0] = 'varbit'; |
| 556 | + $values['bit(1)'][0] = 'varbit(1)'; |
| 557 | + $values['bit(8)'][0] = 'varbit(8)'; |
| 558 | + $values['bit(1000)'][0] = 'varbit(1000)'; |
| 559 | + $values['tinyint()'][0] = 'smallint'; |
| 560 | + $values['tinyint(2)'][0] = 'smallint'; |
| 561 | + $values['smallint(4)'][0] = 'smallint'; |
| 562 | + $values['integer(8)'][0] = 'integer'; |
| 563 | + $values['bigint(15)'][0] = 'bigint'; |
| 564 | + $values['float()'][0] = 'real'; |
| 565 | + $values['float(10)'][0] = 'real'; |
| 566 | + $values['float(10,2)'][0] = 'real'; |
| 567 | + $values['double()'][0] = 'double precision'; |
| 568 | + $values['double(10)'][0] = 'double precision'; |
| 569 | + $values['double(10,2)'][0] = 'double precision'; |
| 570 | + $values['decimal()'][0] = 'numeric(10,0)'; |
| 571 | + $values['decimal(5)'][0] = 'numeric(5,0)'; |
| 572 | + $values['decimal(5,2)'][0] = 'numeric(5,2)'; |
| 573 | + $values['decimal(null)'][0] = 'numeric'; |
| 574 | + $values['money()'][0] = 'money'; |
| 575 | + $values['money(10)'][0] = 'money'; |
| 576 | + $values['money(10,2)'][0] = 'money'; |
| 577 | + $values['money(null)'][0] = 'money'; |
| 578 | + $values['text(1000)'][0] = 'text'; |
| 579 | + $values['binary()'][0] = 'bytea'; |
| 580 | + $values['binary(1000)'][0] = 'bytea'; |
| 581 | + $values['uuid()'][0] = 'uuid'; |
| 582 | + $values['datetime()'][0] = 'timestamp(0)'; |
| 583 | + $values['datetime(6)'][0] = 'timestamp(6)'; |
| 584 | + $values['datetime(null)'][0] = 'timestamp'; |
| 585 | + $values['array()'][0] = 'varchar[]'; |
| 586 | + $values['structured()'][0] = 'jsonb'; |
| 587 | + $values["structured('structured_type')"][0] = 'structured_type'; |
| 588 | + $values['json()'][0] = 'jsonb'; |
| 589 | + $values['json(100)'][0] = 'jsonb'; |
| 590 | + $values['unsigned()'][0] = 'integer'; |
| 591 | + $values['scale(2)'][0] = 'numeric(10,2)'; |
| 592 | + $values['integer(8)->scale(2)'][0] = 'integer'; |
| 593 | + |
| 594 | + return $values; |
| 595 | + } |
539 | 596 | }
|
0 commit comments