Skip to content

Commit

Permalink
[11.x] Fix double-quoted string literals on SQLite (#51615)
Browse files Browse the repository at this point in the history
* fix double-quoted string literals

* fix a left one

* fix a left one
  • Loading branch information
hafezdivandari authored May 29, 2024
1 parent 8b769a0 commit 956a63b
Showing 1 changed file with 7 additions and 7 deletions.
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

0 comments on commit 956a63b

Please sign in to comment.