<- 不创建数据库字段
This commit is contained in:
parent
f22b0cc369
commit
2fd18aa1b3
|
@ -629,6 +629,9 @@ func (db *mssql) CreateTableSQL(table *schemas.Table, tableName string) ([]strin
|
||||||
|
|
||||||
for _, colName := range table.ColumnsSeq() {
|
for _, colName := range table.ColumnsSeq() {
|
||||||
col := table.GetColumn(colName)
|
col := table.GetColumn(colName)
|
||||||
|
if !col.Creatable() { // ignore <- tag column
|
||||||
|
continue
|
||||||
|
}
|
||||||
s, _ := ColumnString(db, col, col.IsPrimaryKey && len(pkList) == 1)
|
s, _ := ColumnString(db, col, col.IsPrimaryKey && len(pkList) == 1)
|
||||||
sql += s
|
sql += s
|
||||||
sql = strings.TrimSpace(sql)
|
sql = strings.TrimSpace(sql)
|
||||||
|
|
|
@ -641,6 +641,9 @@ func (db *mysql) CreateTableSQL(table *schemas.Table, tableName string) ([]strin
|
||||||
|
|
||||||
for _, colName := range table.ColumnsSeq() {
|
for _, colName := range table.ColumnsSeq() {
|
||||||
col := table.GetColumn(colName)
|
col := table.GetColumn(colName)
|
||||||
|
if !col.Creatable() { // ignore <- tag column
|
||||||
|
continue
|
||||||
|
}
|
||||||
s, _ := ColumnString(db, col, col.IsPrimaryKey && len(pkList) == 1)
|
s, _ := ColumnString(db, col, col.IsPrimaryKey && len(pkList) == 1)
|
||||||
sql += s
|
sql += s
|
||||||
sql = strings.TrimSpace(sql)
|
sql = strings.TrimSpace(sql)
|
||||||
|
|
|
@ -612,9 +612,9 @@ func (db *oracle) CreateTableSQL(table *schemas.Table, tableName string) ([]stri
|
||||||
|
|
||||||
for _, colName := range table.ColumnsSeq() {
|
for _, colName := range table.ColumnsSeq() {
|
||||||
col := table.GetColumn(colName)
|
col := table.GetColumn(colName)
|
||||||
/*if col.IsPrimaryKey && len(pkList) == 1 {
|
if !col.Creatable() { // ignore <- tag column
|
||||||
sql += col.String(b.dialect)
|
continue
|
||||||
} else {*/
|
}
|
||||||
s, _ := ColumnString(db, col, false)
|
s, _ := ColumnString(db, col, false)
|
||||||
sql += s
|
sql += s
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -981,6 +981,10 @@ func (db *postgres) CreateTableSQL(table *schemas.Table, tableName string) ([]st
|
||||||
|
|
||||||
for _, colName := range table.ColumnsSeq() {
|
for _, colName := range table.ColumnsSeq() {
|
||||||
col := table.GetColumn(colName)
|
col := table.GetColumn(colName)
|
||||||
|
if !col.Creatable() { // ignore <- tag column
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
s, _ := ColumnString(db, col, col.IsPrimaryKey && len(pkList) == 1)
|
s, _ := ColumnString(db, col, col.IsPrimaryKey && len(pkList) == 1)
|
||||||
sql += s
|
sql += s
|
||||||
sql = strings.TrimSpace(sql)
|
sql = strings.TrimSpace(sql)
|
||||||
|
|
|
@ -301,6 +301,10 @@ func (db *sqlite3) CreateTableSQL(table *schemas.Table, tableName string) ([]str
|
||||||
|
|
||||||
for _, colName := range table.ColumnsSeq() {
|
for _, colName := range table.ColumnsSeq() {
|
||||||
col := table.GetColumn(colName)
|
col := table.GetColumn(colName)
|
||||||
|
if !col.Creatable() { // ignore <- tag column
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
s, _ := ColumnString(db, col, col.IsPrimaryKey && len(pkList) == 1)
|
s, _ := ColumnString(db, col, col.IsPrimaryKey && len(pkList) == 1)
|
||||||
sql += s
|
sql += s
|
||||||
sql = strings.TrimSpace(sql)
|
sql = strings.TrimSpace(sql)
|
||||||
|
|
|
@ -74,6 +74,11 @@ func NewColumn(name, fieldName string, sqlType SQLType, len1, len2 int, nullable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
// ValueOf returns column's filed of struct's value
|
||||||
func (col *Column) ValueOf(bean interface{}) (*reflect.Value, error) {
|
func (col *Column) ValueOf(bean interface{}) (*reflect.Value, error) {
|
||||||
dataStruct := reflect.Indirect(reflect.ValueOf(bean))
|
dataStruct := reflect.Indirect(reflect.ValueOf(bean))
|
||||||
|
|
Loading…
Reference in New Issue