db2 driver updates
This commit is contained in:
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Db2;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class DefaultSchemaTest extends Db2TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Resolve the connection's default schema for unqualified catalog lookups.
|
||||||
|
*/
|
||||||
|
public function test_missing_and_blank_schema_use_the_database_default(): void
|
||||||
|
{
|
||||||
|
$base = config('database.connections.db2_local');
|
||||||
|
unset($base['schema']);
|
||||||
|
|
||||||
|
foreach ([$base, $base + ['schema' => '']] 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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user