Skip to content

Commit

Permalink
Remove PostgresAdapter::getDefaultValueDefinition method override (#2118
Browse files Browse the repository at this point in the history
)
  • Loading branch information
MasterOdin authored Oct 9, 2022
1 parent 81fd976 commit eccde74
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
20 changes: 0 additions & 20 deletions src/Phinx/Db/Adapter/PostgresAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1206,26 +1206,6 @@ public function dropDatabase($name): void
$this->connect();
}

/**
* Get the defintion for a `DEFAULT` statement.
*
* @param mixed $default default value
* @param string|null $columnType column type added
* @return string
*/
protected function getDefaultValueDefinition($default, ?string $columnType = null): string
{
if (is_string($default) && $default !== 'CURRENT_TIMESTAMP') {
$default = $this->getConnection()->quote($default);
} elseif (is_bool($default)) {
$default = $this->castToBool($default);
} elseif ($columnType === static::PHINX_TYPE_BOOLEAN) {
$default = $this->castToBool((bool)$default);
}

return isset($default) ? 'DEFAULT ' . $default : '';
}

/**
* Gets the PostgreSQL Column Definition for a Column object.
*
Expand Down
8 changes: 4 additions & 4 deletions tests/Phinx/Db/Adapter/PostgresAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2182,11 +2182,11 @@ public function testDumpCreateTable()

if ($this->usingPostgres10()) {
$expectedOutput = 'CREATE TABLE "public"."table1" ("id" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY, "column1" CHARACTER VARYING (255) ' .
'NULL, "column2" INTEGER NULL, "column3" CHARACTER VARYING (255) NOT NULL DEFAULT \'test\', CONSTRAINT ' .
'NULL, "column2" INTEGER NULL, "column3" CHARACTER VARYING (255) NOT NULL DEFAULT \'test\', CONSTRAINT ' .
'"table1_pkey" PRIMARY KEY ("id"));';
} else {
$expectedOutput = 'CREATE TABLE "public"."table1" ("id" SERIAL NOT NULL, "column1" CHARACTER VARYING (255) ' .
'NULL, "column2" INTEGER NULL, "column3" CHARACTER VARYING (255) NOT NULL DEFAULT \'test\', CONSTRAINT ' .
'NULL, "column2" INTEGER NULL, "column3" CHARACTER VARYING (255) NOT NULL DEFAULT \'test\', CONSTRAINT ' .
'"table1_pkey" PRIMARY KEY ("id"));';
}
$actualOutput = $consoleOutput->fetch();
Expand Down Expand Up @@ -2214,11 +2214,11 @@ public function testDumpCreateTableWithSchema()

if ($this->usingPostgres10()) {
$expectedOutput = 'CREATE TABLE "schema1"."table1" ("id" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY, "column1" CHARACTER VARYING (255) ' .
'NULL, "column2" INTEGER NULL, "column3" CHARACTER VARYING (255) NOT NULL DEFAULT \'test\', CONSTRAINT ' .
'NULL, "column2" INTEGER NULL, "column3" CHARACTER VARYING (255) NOT NULL DEFAULT \'test\', CONSTRAINT ' .
'"table1_pkey" PRIMARY KEY ("id"));';
} else {
$expectedOutput = 'CREATE TABLE "schema1"."table1" ("id" SERIAL NOT NULL, "column1" CHARACTER VARYING (255) ' .
'NULL, "column2" INTEGER NULL, "column3" CHARACTER VARYING (255) NOT NULL DEFAULT \'test\', CONSTRAINT ' .
'NULL, "column2" INTEGER NULL, "column3" CHARACTER VARYING (255) NOT NULL DEFAULT \'test\', CONSTRAINT ' .
'"table1_pkey" PRIMARY KEY ("id"));';
}
$actualOutput = $consoleOutput->fetch();
Expand Down

0 comments on commit eccde74

Please sign in to comment.