Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion internal/compiler/selector.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package compiler

import "strings"

// selector is an interface used by a compiler for generating expressions for
// output columns in a `SELECT ...` or `RETURNING ...` statement.
//
Expand Down Expand Up @@ -39,7 +41,7 @@ func (s *sqliteSelector) ColumnExpr(name string, column *Column) string {
// outside of the database itself. For jsonb columns in SQLite, wrap values
// in `json(col)` to coerce the internal binary format to JSON parsable by
// the user-space application.
if column.DataType == "jsonb" {
if strings.EqualFold(column.DataType, "jsonb") {
return "json(" + name + ")"
}
return name
Expand Down
4 changes: 4 additions & 0 deletions internal/endtoend/testdata/jsonb/sqlite/go/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 20 additions & 4 deletions internal/endtoend/testdata/jsonb/sqlite/go/query.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions internal/endtoend/testdata/jsonb/sqlite/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@ INSERT INTO foo (
a,
b,
c,
d
d,
e,
f,
g,
h
) VALUES (
@a,
@b,
@c,
@d
@d,
@e,
@f,
@g,
@h
) RETURNING *;

-- name: SelectFoo :exec
Expand Down
6 changes: 5 additions & 1 deletion internal/endtoend/testdata/jsonb/sqlite/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ CREATE TABLE foo (
a json not null,
b jsonb not null,
c json,
d jsonb
d jsonb,
e JSON not null,
f JSONB not null,
g JSON,
h JSONB
);

Loading