<- will not create the column #2022
|
@ -133,6 +133,10 @@ func (db *Base) CreateTableSQL(ctx context.Context, queryer core.Queryer, table
|
|||
|
||||
for i, colName := range table.ColumnsSeq() {
|
||||
col := table.GetColumn(colName)
|
||||
if !col.Creatable() { // ignore <- tag column
|
||||
continue
|
||||
}
|
||||
|
||||
s, _ := ColumnString(db.dialect, col, col.IsPrimaryKey && len(table.PrimaryKeys) == 1, false)
|
||||
b.WriteString(s)
|
||||
|
||||
|
|
|
@ -650,6 +650,9 @@ func (db *mssql) CreateTableSQL(ctx context.Context, queryer core.Queryer, table
|
|||
|
||||
for i, colName := range table.ColumnsSeq() {
|
||||
col := table.GetColumn(colName)
|
||||
if !col.Creatable() { // ignore <- tag column
|
||||
continue
|
||||
}
|
||||
s, _ := ColumnString(db.dialect, col, col.IsPrimaryKey && len(table.PrimaryKeys) == 1, true)
|
||||
b.WriteString(s)
|
||||
|
||||
|
|
|
@ -661,6 +661,10 @@ func (db *mysql) CreateTableSQL(ctx context.Context, queryer core.Queryer, table
|
|||
|
||||
for i, colName := range table.ColumnsSeq() {
|
||||
col := table.GetColumn(colName)
|
||||
if !col.Creatable() { // ignore <- tag column
|
||||
continue
|
||||
}
|
||||
|
||||
s, _ := ColumnString(db.dialect, col, col.IsPrimaryKey && len(table.PrimaryKeys) == 1, true)
|
||||
b.WriteString(s)
|
||||
|
||||
|
|
|
@ -625,6 +625,9 @@ func (db *oracle) CreateTableSQL(ctx context.Context, queryer core.Queryer, tabl
|
|||
|
||||
for _, colName := range table.ColumnsSeq() {
|
||||
col := table.GetColumn(colName)
|
||||
if !col.Creatable() { // ignore <- tag column
|
||||
continue
|
||||
}
|
||||
/*if col.IsPrimaryKey && len(pkList) == 1 {
|
||||
sql += col.String(b.dialect)
|
||||
} else {*/
|
||||
|
|
|
@ -75,6 +75,11 @@ func NewColumn(name, fieldName string, sqlType SQLType, len1, len2 int64, nullab
|
|||
}
|
||||
}
|
||||
|
||||
// Creatable returns true if the column needs to be created when sync
|
||||
func (col *Column) Creatable() bool {
|
||||
return col.MapType != ONLYFROMDB
|
||||
}
|
||||
|
||||
// ValueOf returns column's filed of struct's value
|
||||
func (col *Column) ValueOf(bean interface{}) (*reflect.Value, error) {
|
||||
dataStruct := reflect.Indirect(reflect.ValueOf(bean))
|
||||
|
|
Loading…
Reference in New Issue
Block a user