Skip to content

Commit

Permalink
chore(gen): Updating how the booleans are handled around the sql gen (#9
Browse files Browse the repository at this point in the history
)

* Updating how the bool arguments are handled for the sql args

* Updating patch comments
  • Loading branch information
Jacobbrewer1 authored Oct 6, 2024
1 parent 4207664 commit 887a0fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ var (
)

type SQLPatch struct {
// fields is the fields to update in the SQL statement
fields []string
args []any

// args is the arguments to use in the SQL statement
args []any

// db is the database connection to use
db *sql.DB
Expand Down
7 changes: 4 additions & 3 deletions sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ func (s *SQLPatch) patchGen(resource any) {
case reflect.String:
s.args = append(s.args, val.String())
case reflect.Bool:
boolArg := 0
if val.Bool() {
s.args = append(s.args, 1)
} else {
s.args = append(s.args, 0)
boolArg = 1
}
s.args = append(s.args, boolArg)
default:
// This is intentionally a panic as this is a programming error and should be fixed by the developer
panic("unhandled default case")
}
}
Expand Down

0 comments on commit 887a0fc

Please sign in to comment.