Skip to content

Commit

Permalink
fix: insert mixed case value attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
proullon committed Aug 17, 2023
1 parent a7e15a6 commit e12c987
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 24 additions & 0 deletions driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,30 @@ func TestCreateTable(t *testing.T) {
}
}

func TestInsertBool(t *testing.T) {

db, err := sql.Open("ramsql", "TestInsertBool")
if err != nil {
t.Fatalf("sql.Open: %s", err)
}

_, err = db.Exec(`CREATE TABLE ttable (id BIGINT, hasBool BOOL)`)
if err != nil {
t.Fatalf("cannot create table: %s", err)
}

_, err = db.Exec(`INSERT INTO ttable (id, hasBool) VALUES (?,?)`, 1, true)
if err != nil {
t.Fatalf("cannot insert into table: %s", err)
}

err = db.Close()
if err != nil {
t.Fatalf("sql.Close : Error : %s\n", err)
}

}

func TestInsertEmptyString(t *testing.T) {

db, err := sql.Open("ramsql", "TestInsertEmptyString")
Expand Down
3 changes: 2 additions & 1 deletion engine/executor/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"reflect"
"strconv"
"strings"

"github.com/proullon/ramsql/engine/agnostic"
"github.com/proullon/ramsql/engine/log"
Expand Down Expand Up @@ -360,7 +361,7 @@ func getValues(specifiedAttrs []string, valuesDecl *parser.Decl, args []NamedVal
return nil, err
}
}
values[specifiedAttrs[i]] = v
values[strings.ToLower(specifiedAttrs[i])] = v
}

return values, nil
Expand Down

0 comments on commit e12c987

Please sign in to comment.