@@ -48,6 +48,41 @@ public function test_immutability_on_conflict_do_update(): void
4848 static ::assertStringContainsString ('DO UPDATE ' , $ query2 ->toSql ());
4949 }
5050
51+ public function test_insert_into_schema_qualified_table (): void
52+ {
53+ $ query = BulkInsert::into ('enriched.production ' , ['a ' , 'b ' ], 1 );
54+
55+ static ::assertSame ('INSERT INTO "enriched"."production" ("a", "b") VALUES ($1, $2) ' , $ query ->toSql ());
56+ }
57+
58+ public function test_insert_into_three_part_qualified_table (): void
59+ {
60+ $ query = BulkInsert::into ('db.enriched.production ' , ['a ' ], 1 );
61+
62+ static ::assertSame ('INSERT INTO "db"."enriched"."production" ("a") VALUES ($1) ' , $ query ->toSql ());
63+ }
64+
65+ public function test_insert_into_already_quoted_qualified_table (): void
66+ {
67+ $ query = BulkInsert::into ('enriched."my.table" ' , ['a ' ], 1 );
68+
69+ static ::assertSame ('INSERT INTO "enriched"."my.table" ("a") VALUES ($1) ' , $ query ->toSql ());
70+ }
71+
72+ public function test_schema_qualified_table_with_on_conflict_do_update (): void
73+ {
74+ $ query = BulkInsert::into (
75+ 'enriched.production ' ,
76+ ['email ' , 'name ' ],
77+ 1 ,
78+ )->onConflictDoUpdate (ConflictTarget::columns (['email ' ]));
79+
80+ static ::assertSame (
81+ 'INSERT INTO "enriched"."production" ("email", "name") VALUES ($1, $2) ON CONFLICT ("email") DO UPDATE SET "name" = EXCLUDED."name" ' ,
82+ $ query ->toSql (),
83+ );
84+ }
85+
5186 public function test_insert_with_many_columns (): void
5287 {
5388 $ query = BulkInsert::into ('products ' , ['id ' , 'name ' , 'price ' , 'category ' , 'stock ' ], 2 );
0 commit comments