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
PostgresBuilder fixes for renamed config('database.connections.pgsql.search_path')
1. `PostgresBuilder::parseSchemaAndTable()`
* Needs a fallback to <= 8.x `config('database.connections.pgsql.schema')`
when 9.x renamed `config('database.connections.pgsql.search_path')`
is missing.
* Remove duplicate `$user` variable `config('database.connections.pgsql.username')`
replacement handling already done by `parseSearchPath()`.
2. `PostgresBuilder::getAllTables()` + `getAllViews()` + `parseSchemaAndTable()`
Apply the `parseSearchPath()` fixes applied to PostgresConnector:
laravel#41088
3. `DatabasePostgresBuilderTest`
Add more test cases and use terse method names instead of extensive
comments to concisely communicate each case.
$grammar->shouldReceive('compileTableExists')->andReturn("select * from information_schema.tables where table_catalog = ? and table_schema = ? and table_name = ? and table_type = 'BASE TABLE'");
@@ -67,13 +62,7 @@ public function testWhenSearchPathEmptyHasTableWithUnqualifiedReferenceIsCorrect
67
62
$builder->hasTable('foo');
68
63
}
69
64
70
-
/**
71
-
* Ensure that when the reference is unqualified (i.e., does not contain a
72
-
* database name or a schema), and the first schema in the search_path is
73
-
* NOT the default ('public'), the database specified on the connection is
74
-
* used, and the first schema in the search_path is used.
$grammar->shouldReceive('compileTableExists')->andReturn("select * from information_schema.tables where table_catalog = ? and table_schema = ? and table_name = ? and table_type = 'BASE TABLE'");
88
+
$connection->shouldReceive('select')->with("select * from information_schema.tables where table_catalog = ? and table_schema = ? and table_name = ? and table_type = 'BASE TABLE'", ['laravel', 'myapp', 'foo'])->andReturn(['countable_result']);
$grammar->shouldReceive('compileColumnListing')->andReturn('select column_name from information_schema.columns where table_catalog = ? and table_schema = ? and table_name = ?');
@@ -175,13 +158,7 @@ public function testWhenSearchPathEmptyGetColumnListingWithUnqualifiedReferenceI
175
158
$builder->getColumnListing('foo');
176
159
}
177
160
178
-
/**
179
-
* Ensure that when the reference is unqualified (i.e., does not contain a
180
-
* database name or a schema), and the first schema in the search_path is
181
-
* NOT the default ('public'), the database specified on the connection is
182
-
* used, and the first schema in the search_path is used.
$grammar->shouldReceive('compileGetAllTables')->with(['foouser', 'public', 'foo_bar-Baz.Áüõß'])->andReturn("select tablename from pg_catalog.pg_tables where schemaname in ('foouser','public','foo_bar-Baz.Áüõß')");
259
+
$connection->shouldReceive('select')->with("select tablename from pg_catalog.pg_tables where schemaname in ('foouser','public','foo_bar-Baz.Áüõß')")->andReturn(['users', 'users']);
$grammar->shouldReceive('compileGetAllTables')->with(['foouser', 'public'])->andReturn("select tablename from pg_catalog.pg_tables where schemaname in ('foouser','public')");
311
-
$connection->shouldReceive('select')->with("select tablename from pg_catalog.pg_tables where schemaname in ('foouser','public')")->andReturn(['users', 'users']);
280
+
$grammar->shouldReceive('compileGetAllTables')->with(['foouser', 'dev', 'test', 'spaced schema'])->andReturn("select tablename from pg_catalog.pg_tables where schemaname in ('foouser','dev','test','spaced schema')");
281
+
$connection->shouldReceive('select')->with("select tablename from pg_catalog.pg_tables where schemaname in ('foouser','dev','test','spaced schema')")->andReturn(['users', 'users']);
0 commit comments