Skip to content
This repository was archived by the owner on Aug 17, 2025. It is now read-only.
Draft
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
Binary file modified internal/sql/resources/sqlc-gen-ftl.wasm
Binary file not shown.
40 changes: 40 additions & 0 deletions internal/sql/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,27 @@ func TestAddDatabaseDeclsToSchema(t *testing.T) {
&schema.MetadataGenerated{},
},
},
&schema.Data{
Name: "GetNamedParamMySqlQuery",
Pos: schema.Position{
Filename: filepath.Join(tmpDir, "db/mysql/mysqldb/queries/queries.sql"),
Line: 19,
},
Metadata: []schema.Metadata{&schema.MetadataGenerated{}},
Fields: []*schema.Field{{
Name: "namedId",
Type: &schema.Int{},
Metadata: []schema.Metadata{
&schema.MetadataSQLColumn{Name: "named_id", Table: "authors"},
},
}, {
Name: "hometown",
Type: &schema.Optional{Type: &schema.String{}},
Metadata: []schema.Metadata{
&schema.MetadataSQLColumn{Name: "hometown", Table: "authors"},
},
}},
},
&schema.Data{
Name: "PsqldbAuthor",
Pos: schema.Position{
Expand Down Expand Up @@ -400,6 +421,25 @@ func TestAddDatabaseDeclsToSchema(t *testing.T) {
&schema.MetadataGenerated{},
},
},
&schema.Verb{
Pos: schema.Position{
Filename: filepath.Join(tmpDir, "db/mysql/mysqldb/queries/queries.sql"),
Line: 19,
},
Name: "getNamedParamMySql",
Request: &schema.Ref{Module: "test", Name: "GetNamedParamMySqlQuery"},
Response: &schema.Array{Element: &schema.Ref{Module: "test", Name: "Author"}},
Metadata: []schema.Metadata{
&schema.MetadataDatabases{
Uses: []*schema.Ref{{Module: "test", Name: "mysqldb"}},
},
&schema.MetadataSQLQuery{
Query: "SELECT id, bio, birth_year, hometown FROM authors WHERE id = CAST(? AS UNSIGNED) AND hometown = ?",
Command: "many",
},
&schema.MetadataGenerated{},
},
},
&schema.Verb{
Pos: schema.Position{
Filename: filepath.Join(tmpDir, "db/mysql/mysqldb/queries/queries.sql"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ SELECT bio, hometown FROM authors WHERE id = ?;

-- name: GetManyAuthorsInfoMySQL :many
SELECT bio, hometown FROM authors;

-- name: GetNamedParamMySQL :many
SELECT * FROM authors WHERE id = CAST(sqlc.arg('named_id') AS UNSIGNED) AND hometown = ?;
13 changes: 7 additions & 6 deletions sqlc-gen-ftl/src/protos/xyz.block.ftl.hotreload.v1.rs

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

17 changes: 17 additions & 0 deletions sqlc-gen-ftl/src/protos/xyz.block.ftl.test.v1.rs

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

2 changes: 2 additions & 0 deletions sqlc-gen-ftl/test/sqlc_gen_ftl_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fn get_test_queries(engine: &str) -> Vec<String> {
"INSERT INTO all_types ( big_int, small_int, some_decimal, some_numeric, some_float, some_double, some_varchar, some_text, some_char, nullable_text, some_bool, nullable_bool, some_date, some_time, some_timestamp, some_blob, some_json ) VALUES ( @big_int, @small_int, @some_decimal, @some_numeric, @some_float, @some_double, @some_varchar, @some_text, @some_char, @nullable_text, @some_bool, @nullable_bool, @some_date, @some_time, @some_timestamp, @some_blob, @some_json )".to_string(),
"INSERT INTO requests (data) VALUES (CONCAT(LOWER(?), LOWER(?)))".to_string(),
"SELECT id, data FROM requests WHERE id in (/*SLICE:request_ids*/?)".to_string(),
"SELECT * FROM authors WHERE id = CAST(sqlc.arg('named_id') AS UNSIGNED) AND hometown = ?;".to_string(),
],
"postgresql" => vec![
"SELECT id, big_int, small_int, some_decimal, some_numeric, some_float, some_double, some_varchar, some_text, some_char, nullable_text, some_bool, nullable_bool, some_date, some_time, some_timestamp, some_blob, some_json FROM all_types WHERE id = $1".to_string(),
Expand All @@ -45,6 +46,7 @@ fn get_test_queries(engine: &str) -> Vec<String> {
"INSERT INTO all_types ( big_int, small_int, some_decimal, some_numeric, some_float, some_double, some_varchar, some_text, some_char, nullable_text, some_bool, nullable_bool, some_date, some_time, some_timestamp, some_blob, some_json ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17 )".to_string(),
"INSERT INTO requests (data) VALUES (CONCAT(LOWER($1), LOWER($2)))".to_string(),
"SELECT id, data FROM requests WHERE id = ANY($1::int[])".to_string(),
"SELECT * FROM authors WHERE id = sqlc.arg('named_id')::int AND hometown = ?;".to_string(),
],
_ => vec![],
}
Expand Down
Loading