Skip to content

Commit

Permalink
remove conversion of bool to int
Browse files Browse the repository at this point in the history
  • Loading branch information
Michelle Laurenti committed Jul 22, 2024
1 parent 4f4392d commit 257278b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
14 changes: 1 addition & 13 deletions create.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,7 @@ func Create(db *gorm.DB) {

if !db.DryRun {
for idx, vals := range values.Values {
// HACK HACK: replace values one by one, assuming its value layout will be the same all the time, i.e. aligned
for idx, val := range vals {
switch v := val.(type) {
case bool:
if v {
val = 1
} else {
val = 0
}
}

stmt.Vars[idx] = val
}
copy(stmt.Vars, vals)
// and then we insert each row one by one then put the returning values back (i.e. last return id => smart insert)
// we keep track of the index so that the sub-reflected value is also correct

Expand Down
14 changes: 4 additions & 10 deletions oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,7 @@ var numericPlaceholder = regexp.MustCompile(`:(\d+)`)

func (d Dialector) Explain(sql string, vars ...interface{}) string {
return logger.ExplainSQL(sql, numericPlaceholder, `'`, funk.Map(vars, func(v interface{}) interface{} {
switch v := v.(type) {
case bool:
if v {
return 1
}
return 0
default:
return v
}
return v
}).([]interface{})...)
}

Expand All @@ -186,7 +178,9 @@ func (d Dialector) DataTypeOf(field *schema.Field) string {
var sqlType string

switch field.DataType {
case schema.Bool, schema.Int, schema.Uint, schema.Float:
case schema.Bool:
sqlType = "VARCHAR2(5)"
case schema.Int, schema.Uint, schema.Float:
sqlType = "INTEGER"

switch {
Expand Down

0 comments on commit 257278b

Please sign in to comment.