@@ -78,7 +78,7 @@ protected function load()
78
78
*/
79
79
protected function fetchTables ($ schema )
80
80
{
81
- $ rows = $ this ->connection ->select ('SHOW TABLES FROM ' .$ schema );
81
+ $ rows = $ this ->connection ->select ('SHOW TABLES FROM ' .$ this -> wrap ( $ schema) );
82
82
$ tables = Arr::flatten ($ rows );
83
83
84
84
return array_diff ($ tables , [
@@ -91,7 +91,7 @@ protected function fetchTables($schema)
91
91
*/
92
92
protected function fillColumns (Blueprint $ blueprint )
93
93
{
94
- $ rows = $ this ->connection ->select ('SHOW FULL COLUMNS FROM ' .$ blueprint ->qualifiedTable ());
94
+ $ rows = $ this ->connection ->select ('SHOW FULL COLUMNS FROM ' .$ this -> wrap ( $ blueprint ->qualifiedTable () ));
95
95
foreach ($ rows as $ column ) {
96
96
$ blueprint ->withColumn (
97
97
$ this ->parseColumn ($ column )
@@ -114,7 +114,7 @@ protected function parseColumn($metadata)
114
114
*/
115
115
protected function fillConstraints (Blueprint $ blueprint )
116
116
{
117
- $ row = $ this ->connection ->select ('SHOW CREATE TABLE ' .$ blueprint ->qualifiedTable ());
117
+ $ row = $ this ->connection ->select ('SHOW CREATE TABLE ' .$ this -> wrap ( $ blueprint ->qualifiedTable () ));
118
118
$ row = array_change_key_case ($ row [0 ]);
119
119
$ sql = $ row ['create table ' ];
120
120
$ sql = str_replace ('` ' , '' , $ sql );
@@ -201,6 +201,22 @@ protected function columnize($columns)
201
201
return array_map ('trim ' , explode (', ' , $ columns ));
202
202
}
203
203
204
+ /**
205
+ * Wrap within backticks
206
+ *
207
+ * @param string $table
208
+ *
209
+ * @return string
210
+ */
211
+ protected function wrap ($ table )
212
+ {
213
+ $ pieces = explode ('. ' , str_replace ('` ' , '' , $ table ));
214
+
215
+ return implode ('. ' , array_map (function ($ piece ) {
216
+ return "` $ piece` " ;
217
+ }, $ pieces ));
218
+ }
219
+
204
220
/**
205
221
* @param string $table
206
222
* @param \Reliese\Meta\Blueprint $blueprint
0 commit comments