1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 07:36:44 +02:00

SQLite: Fix expressions in default values (bug #860)

This commit is contained in:
Jakub Vrana
2025-02-20 09:37:43 +01:00
parent e321a26ee5
commit f2e2c6e4ac
3 changed files with 4 additions and 2 deletions

View File

@@ -319,7 +319,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
"field" => $name, "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")))), "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, "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"], "null" => !$row["notnull"],
"privileges" => array("select" => 1, "insert" => 1, "update" => 1), "privileges" => array("select" => 1, "insert" => 1, "update" => 1),
"primary" => $row["pk"], "primary" => $row["pk"],

View File

@@ -294,10 +294,11 @@ function process_field($field, $type_field) {
* @return string * @return string
*/ */
function default_value($field) { function default_value($field) {
global $jush;
$default = $field["default"]; $default = $field["default"];
return ($default === null ? "" : " 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)) (!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)))
); );
} }

View File

@@ -3,6 +3,7 @@ MySQL: Fix saving bit(64) values (bug #839)
PostgreSQL: Preserve whitespace in EXPLAIN (bug #827) PostgreSQL: Preserve whitespace in EXPLAIN (bug #827)
PostgreSQL: Support SSL PostgreSQL: Support SSL
SQLite: Fix altering forign keys (bug #841) 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) MS SQL: Foreign keys in non-default schema (bug #833)
Oracle: Include tables granted by other user Oracle: Include tables granted by other user
MongoDB: Execute commands against the selected DB MongoDB: Execute commands against the selected DB