Skip to content

Commit

Permalink
fix(sqlite): Correctly skip unknown statements (#3239)
Browse files Browse the repository at this point in the history
* fix(sqlite): Correctly skip unknown statements

Without updating loc, the unknown statement would be included in the
text of the next query.

* Pick sqlc-gen-typescript to a release
  • Loading branch information
kyleconroy authored Mar 4, 2024
1 parent b8160b5 commit 014d6fc
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci-typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ jobs:
with:
repository: sqlc-dev/sqlc-gen-typescript
path: typescript
# v0.1.3
ref: daaf539092421adc15f6c3164279a3470716b560
- run: sqlc diff
working-directory: typescript/examples
31 changes: 31 additions & 0 deletions internal/endtoend/testdata/sqlite_skip_todo/db/db.go

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

13 changes: 13 additions & 0 deletions internal/endtoend/testdata/sqlite_skip_todo/db/models.go

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

66 changes: 66 additions & 0 deletions internal/endtoend/testdata/sqlite_skip_todo/db/query.sql.go

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

16 changes: 16 additions & 0 deletions internal/endtoend/testdata/sqlite_skip_todo/query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- name: PragmaForeignKeysEnable :exec
PRAGMA foreign_keys = 1;

-- name: ListFoo :many
SELECT * FROM foo;

-- name: PragmaForeignKeysDisable :exec
PRAGMA foreign_keys = 0;

-- name: PragmaForeignKeysGet :one
PRAGMA foreign_keys;

-- name: GetFoo :many
SELECT * FROM foo
WHERE bar = ?;

3 changes: 3 additions & 0 deletions internal/endtoend/testdata/sqlite_skip_todo/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE TABLE foo (
bar text
);
16 changes: 16 additions & 0 deletions internal/endtoend/testdata/sqlite_skip_todo/sqlc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "2",
"sql": [
{
"engine": "sqlite",
"queries": "query.sql",
"schema": "schema.sql",
"gen": {
"go": {
"package": "db",
"out": "db"
}
}
}
]
}
1 change: 1 addition & 0 deletions internal/engine/sqlite/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (p *Parser) Parse(r io.Reader) ([]ast.Statement, error) {
converter := &cc{}
out := converter.convert(stmt)
if _, ok := out.(*ast.TODO); ok {
loc = stmt.GetStop().GetStop() + 2
continue
}
len := (stmt.GetStop().GetStop() + 1) - loc
Expand Down

0 comments on commit 014d6fc

Please sign in to comment.