Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Fix double-quoted string literals on SQLite #51615

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class SQLiteGrammar extends Grammar
public function compileSqlCreateStatement($name, $type = 'table')
{
return sprintf('select "sql" from sqlite_master where type = %s and name = %s',
$this->wrap($type),
$this->wrap(str_replace('.', '__', $name))
$this->quoteString($type),
$this->quoteString(str_replace('.', '__', $name))
);
}

Expand Down Expand Up @@ -91,7 +91,7 @@ public function compileColumns($table)
return sprintf(
'select name, type, not "notnull" as "nullable", dflt_value as "default", pk as "primary", hidden as "extra" '
.'from pragma_table_xinfo(%s) order by cid asc',
$this->wrap(str_replace('.', '__', $table))
$this->quoteString(str_replace('.', '__', $table))
);
}

Expand All @@ -104,12 +104,12 @@ public function compileColumns($table)
public function compileIndexes($table)
{
return sprintf(
'select "primary" as name, group_concat(col) as columns, 1 as "unique", 1 as "primary" '
'select \'primary\' as name, group_concat(col) as columns, 1 as "unique", 1 as "primary" '
.'from (select name as col from pragma_table_info(%s) where pk > 0 order by pk, cid) group by name '
.'union select name, group_concat(col) as columns, "unique", origin = "pk" as "primary" '
.'union select name, group_concat(col) as columns, "unique", origin = \'pk\' as "primary" '
.'from (select il.*, ii.name as col from pragma_index_list(%s) il, pragma_index_info(il.name) ii order by il.seq, ii.seqno) '
.'group by name, "unique", "primary"',
$table = $this->wrap(str_replace('.', '__', $table)),
$table = $this->quoteString(str_replace('.', '__', $table)),
$table
);
}
Expand All @@ -127,7 +127,7 @@ public function compileForeignKeys($table)
.'group_concat("to") as foreign_columns, on_update, on_delete '
.'from (select * from pragma_foreign_key_list(%s) order by id desc, seq) '
.'group by id, "table", on_update, on_delete',
$this->wrap(str_replace('.', '__', $table))
$this->quoteString(str_replace('.', '__', $table))
);
}

Expand Down