From bc3e21ea55c522241aa589abe75304568da64c59 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Tue, 20 Jun 2023 10:51:28 +0800 Subject: [PATCH] * Fix bug for format dameng sql. --- lib/dbh/dbh.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/dbh/dbh.class.php b/lib/dbh/dbh.class.php index 46b8f665b8..ff513846f0 100644 --- a/lib/dbh/dbh.class.php +++ b/lib/dbh/dbh.class.php @@ -459,8 +459,13 @@ class dbh $sql = preg_replace('/\,\s*(unique|fulltext)*\s+key[\_\"0-9a-z ]+\(+[\,\_\"0-9a-z ]+\)+/i', '', $sql); $sql = preg_replace('/ float\s*\(+[\,\_\"0-9a-z ]+\)+/i', ' float', $sql); - /* If table has datas and sql no default values defined, replace NOT NULL to NULL. */ - if(strpos($sql, "NOT NULL") !== false && strpos($sql, "DEFAULT") === false) $sql = str_replace("NOT NULL", "NULL", $sql); + /* Convert "date" datetime to "date" datetime(0) to fix bug 25725, dm database datetime default 6 */ + preg_match_all('/"[0-9a-zA-Z]+" datetime/', $sql, $datetimeMatch); + if(!empty($datetimeMatch)) + { + foreach($datetimeMatch[0] as $match) $sql = str_replace($match, $match . '(0)', $sql); + } + $sql = $this->convertAlterTableSql($sql); }