fix(merge,pgsql): treat serial types as their base integer in diffs, unquote bare keyword defaults
Merge conflict detection compared bigserial (DBML) against bigint (live PostgreSQL read of an existing serial column) as incompatible types, since serial is sugar over an integer column plus a sequence default and PostgreSQL always reports back the underlying integer type. Add SerialUnderlyingType and use it when comparing column types for conflicts. QuoteDefaultValue also wrapped bare keyword expressions like CURRENT_DATE in string quotes because they contain no parentheses, unlike function-call defaults such as now(). Recognize known bare keyword defaults and leave them unquoted across CREATE TABLE, ALTER TABLE ADD COLUMN, and ALTER COLUMN SET DEFAULT generation.
This commit is contained in:
+6
-1
@@ -492,7 +492,12 @@ func extractTypeParts(col *models.Column) (baseType string, length, precision, s
|
||||
}
|
||||
}
|
||||
|
||||
typeName = pgsql.NormalizePGType(typeName)
|
||||
// serial/bigserial/smallserial are sugar over an integer column plus a
|
||||
// sequence default; PostgreSQL itself reports the underlying integer
|
||||
// type back for such columns, so treat them as equivalent here to avoid
|
||||
// spurious conflicts between a DBML "bigserial" source and a live-read
|
||||
// "bigint" target (or vice versa).
|
||||
typeName = pgsql.SerialUnderlyingType(typeName)
|
||||
|
||||
return typeName, length, precision, scale
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user