diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php index aa7118e2..8d9f7179 100644 --- a/adminer/drivers/sqlite.inc.php +++ b/adminer/drivers/sqlite.inc.php @@ -319,7 +319,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) { "field" => $name, "type" => (preg_match('~int~i', $type) ? "integer" : (preg_match('~char|clob|text~i', $type) ? "text" : (preg_match('~blob~i', $type) ? "blob" : (preg_match('~real|floa|doub~i', $type) ? "real" : "numeric")))), "full_type" => $type, - "default" => (preg_match("~'(.*)'~", $default, $match) ? str_replace("''", "'", $match[1]) : ($default == "NULL" ? null : $default)), + "default" => (preg_match("~^'(.*)'$~", $default, $match) ? str_replace("''", "'", $match[1]) : ($default == "NULL" ? null : $default)), "null" => !$row["notnull"], "privileges" => array("select" => 1, "insert" => 1, "update" => 1), "primary" => $row["pk"], diff --git a/adminer/include/editing.inc.php b/adminer/include/editing.inc.php index 4ef7067e..d4d2dae5 100644 --- a/adminer/include/editing.inc.php +++ b/adminer/include/editing.inc.php @@ -294,10 +294,11 @@ function process_field($field, $type_field) { * @return string */ function default_value($field) { + global $jush; $default = $field["default"]; return ($default === null ? "" : " DEFAULT " . (!preg_match('~^GENERATED ~i', $default) && (preg_match('~char|binary|text|enum|set~', $field["type"]) || preg_match('~^(?![a-z])~i', $default)) - ? q($default) : str_ireplace("current_timestamp()", "CURRENT_TIMESTAMP", $default)) + ? q($default) : str_ireplace("current_timestamp()", "CURRENT_TIMESTAMP", ($jush == "sqlite" ? "($default)" : $default))) ); } diff --git a/changes.txt b/changes.txt index 072f0525..46ca7d9c 100644 --- a/changes.txt +++ b/changes.txt @@ -3,6 +3,7 @@ MySQL: Fix saving bit(64) values (bug #839) PostgreSQL: Preserve whitespace in EXPLAIN (bug #827) PostgreSQL: Support SSL SQLite: Fix altering forign keys (bug #841) +SQLite: Fix expressions in default values (bug #860) MS SQL: Foreign keys in non-default schema (bug #833) Oracle: Include tables granted by other user MongoDB: Execute commands against the selected DB