Skip to content

Commit 6cbabeb

Browse files
Fix reliese#5 - Add missing backticks to database queries
1 parent eee29e1 commit 6cbabeb

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/Meta/Blueprint.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -119,22 +119,6 @@ public function hasColumn($name)
119119
return array_key_exists($name, $this->columns);
120120
}
121121

122-
/**
123-
* @param $pattern
124-
*
125-
* @return bool
126-
*/
127-
public function columnIs($pattern)
128-
{
129-
foreach ($this->columns as $column => $data) {
130-
if (Str::is($pattern, $column)) {
131-
return true;
132-
}
133-
}
134-
135-
return false;
136-
}
137-
138122
/**
139123
* @param string $name
140124
*

src/Meta/MySql/Schema.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected function load()
7878
*/
7979
protected function fetchTables($schema)
8080
{
81-
$rows = $this->connection->select('SHOW TABLES FROM '.$schema);
81+
$rows = $this->connection->select('SHOW TABLES FROM '.$this->wrap($schema));
8282
$tables = Arr::flatten($rows);
8383

8484
return array_diff($tables, [
@@ -91,7 +91,7 @@ protected function fetchTables($schema)
9191
*/
9292
protected function fillColumns(Blueprint $blueprint)
9393
{
94-
$rows = $this->connection->select('SHOW FULL COLUMNS FROM '.$blueprint->qualifiedTable());
94+
$rows = $this->connection->select('SHOW FULL COLUMNS FROM '.$this->wrap($blueprint->qualifiedTable()));
9595
foreach ($rows as $column) {
9696
$blueprint->withColumn(
9797
$this->parseColumn($column)
@@ -114,7 +114,7 @@ protected function parseColumn($metadata)
114114
*/
115115
protected function fillConstraints(Blueprint $blueprint)
116116
{
117-
$row = $this->connection->select('SHOW CREATE TABLE '.$blueprint->qualifiedTable());
117+
$row = $this->connection->select('SHOW CREATE TABLE '.$this->wrap($blueprint->qualifiedTable()));
118118
$row = array_change_key_case($row[0]);
119119
$sql = $row['create table'];
120120
$sql = str_replace('`', '', $sql);
@@ -201,6 +201,22 @@ protected function columnize($columns)
201201
return array_map('trim', explode(',', $columns));
202202
}
203203

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+
204220
/**
205221
* @param string $table
206222
* @param \Reliese\Meta\Blueprint $blueprint

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy