From f5ddf38abc75951d0bfad4b218d5383fc507bcab Mon Sep 17 00:00:00 2001 From: Mark Gregory Date: Wed, 11 Nov 2026 11:22:00 +0000 Subject: [PATCH] db2 driver updates --- tests/Feature/Db2/DefaultSchemaTest.php | 50 +++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/Feature/Db2/DefaultSchemaTest.php diff --git a/tests/Feature/Db2/DefaultSchemaTest.php b/tests/Feature/Db2/DefaultSchemaTest.php new file mode 100644 index 0000000..f82db33 --- /dev/null +++ b/tests/Feature/Db2/DefaultSchemaTest.php @@ -0,0 +1,50 @@ + '']] as $config) { + config(['database.connections.db2_schema_test' => $config]); + try { + $connection = DB::connection('db2_schema_test'); + $current = trim($connection->selectOne('VALUES CURRENT SCHEMA')->{'1'}); + $this->assertNotSame('', $current); + $this->assertSame($current, $connection->getConfig('schema')); + $schema = $connection->getSchemaBuilder(); + $this->assertSame($schema->getTables($current), $schema->getTables()); + } finally { + DB::purge('db2_schema_test'); + } + } + } + + /** + * Apply an explicitly configured schema to SQL and catalog lookups. + */ + public function test_explicit_schema_overrides_the_database_default(): void + { + config(['database.connections.db2_schema_test' => array_replace( + config('database.connections.db2_local'), + ['schema' => 'SYSCAT'] + )]); + + try { + $connection = DB::connection('db2_schema_test'); + $this->assertSame('SYSCAT', trim($connection->selectOne('VALUES CURRENT SCHEMA')->{'1'})); + $this->assertTrue($connection->getSchemaBuilder()->hasTable('COLUMNS')); + } finally { + DB::purge('db2_schema_test'); + } + } +}