mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-01-02 12:46:35 +08:00
fix: fixed some issues
This commit is contained in:
@@ -30,7 +30,7 @@ type DumpHelper struct {
|
||||
func (dh *DumpHelper) AfterInsert(writer io.Writer, tableName string, columns []dbi.Column) {
|
||||
// 设置自增序列当前值
|
||||
for _, column := range columns {
|
||||
if column.IsIdentity {
|
||||
if column.AutoIncrement {
|
||||
seq := fmt.Sprintf("SELECT setval('%s_%s_seq', (SELECT max(%s) FROM %s));\n", tableName, column.ColumnName, column.ColumnName, tableName)
|
||||
writer.Write([]byte(seq))
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func (pd *PgsqlMetadata) GetColumns(tableNames ...string) ([]dbi.Column, error)
|
||||
ColumnComment: cast.ToString(re["columnComment"]),
|
||||
Nullable: cast.ToString(re["nullable"]) == "YES",
|
||||
IsPrimaryKey: cast.ToInt(re["isPrimaryKey"]) == 1,
|
||||
IsIdentity: cast.ToInt(re["isIdentity"]) == 1,
|
||||
AutoIncrement: cast.ToInt(re["autoIncrement"]) == 1,
|
||||
ColumnDefault: cast.ToString(re["columnDefault"]),
|
||||
NumPrecision: cast.ToInt(re["numPrecision"]),
|
||||
NumScale: cast.ToInt(re["numScale"]),
|
||||
|
||||
@@ -214,7 +214,7 @@ func (pd *SQLGenerator) genColumnBasicSql(quoter dbi.Quoter, column dbi.Column)
|
||||
}
|
||||
|
||||
// 如果是自增类型,需要转换为serial
|
||||
if column.IsIdentity {
|
||||
if column.AutoIncrement {
|
||||
if dataType == "int4" {
|
||||
column.DataType = "serial"
|
||||
} else if dataType == "int2" {
|
||||
|
||||
Reference in New Issue
Block a user