@@ -12,7 +12,7 @@ class PostgresBuilder extends Builder
12
12
*/
13
13
public function hasTable ($ table )
14
14
{
15
- [ $ schema , $ table ] = $ this ->getSchema ($ table );
15
+ list ( $ schema , $ table) = $ this ->parseSchemaAndTable ($ table );
16
16
17
17
$ table = $ this ->connection ->getTablePrefix ().$ table ;
18
18
@@ -71,7 +71,7 @@ protected function getAllTables()
71
71
*/
72
72
public function getColumnListing ($ table )
73
73
{
74
- [ $ schema , $ table ] = $ this ->getSchema ($ table );
74
+ list ( $ schema , $ table) = $ this ->parseSchemaAndTable ($ table );
75
75
76
76
$ table = $ this ->connection ->getTablePrefix ().$ table ;
77
77
@@ -83,26 +83,23 @@ public function getColumnListing($table)
83
83
}
84
84
85
85
/**
86
- * Determines which schema should be used .
86
+ * Parse the table name and extract the schema and table .
87
87
*
88
88
* @param string $table
89
- * @return [ string, string ]
89
+ * @return array
90
90
*/
91
- protected function getSchema ($ table )
91
+ protected function parseSchemaAndTable ($ table )
92
92
{
93
93
$ table = explode ('. ' , $ table );
94
- $ schema = $ this ->connection ->getConfig ('schema ' );
95
94
96
- if (is_array ($ schema )) {
97
- if (in_array ($ table [0 ], $ schema )) { // Table contains schema prefix
95
+ if (is_array ($ schema = $ this -> connection -> getConfig ( ' schema ' ) )) {
96
+ if (in_array ($ table [0 ], $ schema )) {
98
97
return [array_shift ($ table ), implode ('. ' , $ table )];
99
98
}
100
99
101
100
$ schema = head ($ schema );
102
101
}
103
102
104
- $ schema = $ schema ?: 'public ' ;
105
-
106
- return [$ schema , implode ('. ' , $ table )];
103
+ return [$ schema ?: 'public ' , implode ('. ' , $ table )];
107
104
}
108
105
}
0 commit comments