<- will not create the column #2022

Closed
lunny wants to merge 2 commits from lunny/load into master
5 changed files with 19 additions and 0 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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 {*/

View File

@ -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))