You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update the postgres generated clause to GENERATED BY DEFAULT to allow database seeding.
* Copied insert statements from PdoAdapter and updated to include OVERRIDING SYSTEM VALUE to allow database seeding when a column was created with GENERATED ALWAYS.
* Update PostgresAdapter unit tests with expected output.
* Update PostgresAdapter unit tests with default generated clause.
* Only override system value if Postgres version is greater than or equal to 10.
* Add checks for Postgres version and coding standard fix.
* Another Postgres version check.
@@ -2233,7 +2233,7 @@ public function testDumpCreateTable()
2233
2233
->save();
2234
2234
2235
2235
if ($this->usingPostgres10()) {
2236
-
$expectedOutput = 'CREATE TABLE "public"."table1" ("id" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY, "column1" CHARACTER VARYING (255) ' .
2236
+
$expectedOutput = 'CREATE TABLE "public"."table1" ("id" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY, "column1" CHARACTER VARYING (255) ' .
2237
2237
'NULL, "column2" INTEGER NULL, "column3" CHARACTER VARYING (255) NOT NULL DEFAULT \'test\', CONSTRAINT ' .
2238
2238
'"table1_pkey" PRIMARY KEY ("id"));';
2239
2239
} else {
@@ -2265,7 +2265,7 @@ public function testDumpCreateTableWithSchema()
2265
2265
->save();
2266
2266
2267
2267
if ($this->usingPostgres10()) {
2268
-
$expectedOutput = 'CREATE TABLE "schema1"."table1" ("id" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY, "column1" CHARACTER VARYING (255) ' .
2268
+
$expectedOutput = 'CREATE TABLE "schema1"."table1" ("id" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY, "column1" CHARACTER VARYING (255) ' .
2269
2269
'NULL, "column2" INTEGER NULL, "column3" CHARACTER VARYING (255) NOT NULL DEFAULT \'test\', CONSTRAINT ' .
2270
2270
'"table1_pkey" PRIMARY KEY ("id"));';
2271
2271
} else {
@@ -2312,10 +2312,19 @@ public function testDumpInsert()
2312
2312
]);
2313
2313
2314
2314
$expectedOutput = <<<'OUTPUT'
2315
+
INSERT INTO "public"."table1" ("string_col") OVERRIDING SYSTEM VALUE VALUES ('test data');
2316
+
INSERT INTO "public"."table1" ("string_col") OVERRIDING SYSTEM VALUE VALUES (null);
2317
+
INSERT INTO "public"."table1" ("int_col") OVERRIDING SYSTEM VALUE VALUES (23);
2318
+
OUTPUT;
2319
+
2320
+
if (!$this->usingPostgres10()) {
2321
+
$expectedOutput = <<<'OUTPUT'
2315
2322
INSERT INTO "public"."table1" ("string_col") VALUES ('test data');
2316
2323
INSERT INTO "public"."table1" ("string_col") VALUES (null);
2317
2324
INSERT INTO "public"."table1" ("int_col") VALUES (23);
2318
2325
OUTPUT;
2326
+
}
2327
+
2319
2328
$actualOutput = $consoleOutput->fetch();
2320
2329
$this->assertStringContainsString(
2321
2330
$expectedOutput,
@@ -2359,8 +2368,15 @@ public function testDumpBulkinsert()
2359
2368
]);
2360
2369
2361
2370
$expectedOutput = <<<'OUTPUT'
2371
+
INSERT INTO "public"."table1" ("string_col", "int_col") OVERRIDING SYSTEM VALUE VALUES ('test_data1', 23), (null, 42);
2372
+
OUTPUT;
2373
+
2374
+
if (!$this->usingPostgres10()) {
2375
+
$expectedOutput = <<<'OUTPUT'
2362
2376
INSERT INTO "public"."table1" ("string_col", "int_col") VALUES ('test_data1', 23), (null, 42);
2363
2377
OUTPUT;
2378
+
}
2379
+
2364
2380
$actualOutput = $consoleOutput->fetch();
2365
2381
$this->assertStringContainsString(
2366
2382
$expectedOutput,
@@ -2395,8 +2411,16 @@ public function testDumpCreateTableAndThenInsert()
2395
2411
2396
2412
$expectedOutput = <<<'OUTPUT'
2397
2413
CREATE TABLE "schema1"."table1" ("column1" CHARACTER VARYING (255) NOT NULL, "column2" INTEGER NULL, CONSTRAINT "table1_pkey" PRIMARY KEY ("column1"));
2414
+
INSERT INTO "schema1"."table1" ("column1", "column2") OVERRIDING SYSTEM VALUE VALUES ('id1', 1);
2415
+
OUTPUT;
2416
+
2417
+
if (!$this->usingPostgres10()) {
2418
+
$expectedOutput = <<<'OUTPUT'
2419
+
CREATE TABLE "schema1"."table1" ("column1" CHARACTER VARYING (255) NOT NULL, "column2" INTEGER NULL, CONSTRAINT "table1_pkey" PRIMARY KEY ("column1"));
2398
2420
INSERT INTO "schema1"."table1" ("column1", "column2") VALUES ('id1', 1);
2399
2421
OUTPUT;
2422
+
}
2423
+
2400
2424
$actualOutput = $consoleOutput->fetch();
2401
2425
$this->assertStringContainsString($expectedOutput, $actualOutput, 'Passing the --dry-run option does not dump create and then insert table queries to the output');
0 commit comments