Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sqlite): Correctly skip unknown statements #3239

Merged
merged 2 commits into from
Mar 4, 2024
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
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
Loading