SQLite: Support ` in PRIMARY KEY

This commit is contained in:
Jakub Vrana 2018-02-07 16:43:21 +01:00
parent 964a988fef
commit 718f9d3791

View file

@ -337,9 +337,9 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
}
$return = array();
$sql = $connection2->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . q($table));
if (preg_match('~\bPRIMARY\s+KEY\s*\((([^)"]+|"[^"]*")++)~i', $sql, $match)) {
if (preg_match('~\bPRIMARY\s+KEY\s*\((([^)"]+|"[^"]*"|`[^`]*`)++)~i', $sql, $match)) {
$return[""] = array("type" => "PRIMARY", "columns" => array(), "lengths" => array(), "descs" => array());
preg_match_all('~((("[^"]*+")+)|(\S+))(\s+(ASC|DESC))?(,\s*|$)~i', $match[1], $matches, PREG_SET_ORDER);
preg_match_all('~((("[^"]*+")+|(?:`[^`]*+`)+)|(\S+))(\s+(ASC|DESC))?(,\s*|$)~i', $match[1], $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$return[""]["columns"][] = idf_unescape($match[2]) . $match[4];
$return[""]["descs"][] = (preg_match('~DESC~i', $match[5]) ? '1' : null);