作者 yangfu

fix: decimal problem

... ... @@ -12,7 +12,7 @@ func DomainFieldsToColumnSchemas(fields []*domain.Field) []domain.ColumnSchema {
if convertFiledSQLType(f.SQLType) {
res.ColumnType = domain.DECIMAL279.ToString()
}
result = append(result)
result = append(result, res)
}
return result
}
... ... @@ -69,3 +69,15 @@ func convertFiledSQLType(sqlType string) bool {
}
return false
}
func FieldsToColumnSchemas(fields []*domain.Field) []domain.ColumnSchema {
result := make([]domain.ColumnSchema, 0)
for _, f := range fields {
result = append(result, domain.ColumnSchema{
ColumnName: f.Name,
ColumnType: f.SQLType,
})
}
return result
}
... ...
... ... @@ -96,18 +96,6 @@ type ResponseCheckoutTablesSave struct {
CheckoutTableUrl string `json:"checkoutTableUrl"`
}
func FieldsToColumnSchemas(fields []*domain.Field) []domain.ColumnSchema {
result := make([]domain.ColumnSchema, 0)
for _, f := range fields {
result = append(result, domain.ColumnSchema{
ColumnName: f.Name,
ColumnType: f.SQLType,
})
}
return result
}
func ToDataLoadDataTable(data DataCheckoutTables) *domain.DataLoadDataTable {
response := &domain.DataLoadDataTable{
PageNumber: data.PageNumber,
... ...
... ... @@ -140,7 +140,11 @@ func (c Condition) SetWhere(params QueryOptions, q *gorm.DB) {
q.Where(fmt.Sprintf("%v like '%%%v%%'", c.FormatIfNull(params, c.Field), c.Like))
}
if len(c.In) > 0 {
q.Where(fmt.Sprintf("%v in %v", c.CastType(c.FormatIfNull(params, c.Field), "string"), c.InArgs(c.In)))
if c.Field.SQLType == domain.Float.ToString() {
q.Where(fmt.Sprintf("%v in %v", c.CastType(c.Field.SQLName, domain.DECIMALV2.ToString()), c.InArgs(c.In)))
} else {
q.Where(fmt.Sprintf("%v in %v", c.CastType(c.FormatIfNull(params, c.Field), "string"), c.InArgs(c.In)))
}
}
if len(c.Ex) > 0 {
in := c.InArgs(c.Ex)
... ... @@ -201,6 +205,16 @@ func (c Condition) CastType(sql, t string) string {
return castType(sql, t)
}
func (c Condition) CastTypeByField(f *domain.Field, t string) string {
if c.params.Table != nil && c.params.Table.TableType == domain.ObjectDBTable {
return f.SQLName
}
if f.SQLType == domain.Float.ToString() || f.SQLType == domain.DECIMAL279.ToString() {
return castTypeAlias(f.SQLName, domain.DECIMALV2.ToString())
}
return castType(f.SQLName, t)
}
func formatFiled(f *domain.Field) string {
if f.SQLType == domain.Float.ToString() || f.SQLType == domain.DECIMAL279.ToString() {
return castTypeAlias(f.SQLName, domain.DECIMALV2.ToString())
... ...