* Fix bug for format dameng sql.

This commit is contained in:
tanghucheng
2023-06-20 10:51:28 +08:00
parent 12d6a65fcf
commit bc3e21ea55
+7 -2
View File
@@ -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);
}