- Notifications
You must be signed in to change notification settings - Fork39
fix: enum generation if it does contain only equality-sign#59
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
dswistowski wants to merge1 commit intosqlc-dev:mainChoose a base branch fromdswistowski:main
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletioninternal/endtoend/testdata/emit_pydantic_models/sqlc.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Empty file.
20 changes: 20 additions & 0 deletionsinternal/endtoend/testdata/enum_with_eq/db/models.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Code generated by sqlc. DO NOT EDIT. | ||
| # versions: | ||
| # sqlc v1.27.0 | ||
| import enum | ||
| import pydantic | ||
| from typing import Optional | ||
| class Operator(str, enum.Enum): | ||
| EQ = "=" | ||
| GT = ">" | ||
| LT = "<" | ||
| GTEQ = ">=" | ||
| LTEQ = "<=" | ||
| class Operation(pydantic.BaseModel): | ||
| a: Optional[int] | ||
| b: Optional[int] | ||
| operation: Optional[Operator] |
43 changes: 43 additions & 0 deletionsinternal/endtoend/testdata/enum_with_eq/db/query.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Code generated by sqlc. DO NOT EDIT. | ||
| # versions: | ||
| # sqlc v1.27.0 | ||
| # source: query.sql | ||
| from typing import AsyncIterator, Iterator | ||
| import sqlalchemy | ||
| import sqlalchemy.ext.asyncio | ||
| from db import models | ||
| LIST = """-- name: list \\:many | ||
| SELECT a, b, operation FROM operations | ||
| """ | ||
| class Querier: | ||
| def __init__(self, conn: sqlalchemy.engine.Connection): | ||
| self._conn = conn | ||
| def list(self) -> Iterator[models.Operation]: | ||
| result = self._conn.execute(sqlalchemy.text(LIST)) | ||
| for row in result: | ||
| yield models.Operation( | ||
| a=row[0], | ||
| b=row[1], | ||
| operation=row[2], | ||
| ) | ||
| class AsyncQuerier: | ||
| def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): | ||
| self._conn = conn | ||
| async def list(self) -> AsyncIterator[models.Operation]: | ||
| result = await self._conn.stream(sqlalchemy.text(LIST)) | ||
| async for row in result: | ||
| yield models.Operation( | ||
| a=row[0], | ||
| b=row[1], | ||
| operation=row[2], | ||
| ) |
2 changes: 2 additions & 0 deletionsinternal/endtoend/testdata/enum_with_eq/query.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -- name: list :many | ||
| SELECT * FROM operations; |
13 changes: 13 additions & 0 deletionsinternal/endtoend/testdata/enum_with_eq/schema.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| CREATE TYPE operator AS ENUM ( | ||
| '=', | ||
| '>', | ||
| '<', | ||
| '>=', | ||
| '<=' | ||
| ); | ||
| CREATE TABLE operations ( | ||
| a int, | ||
| b int, | ||
| operation operator | ||
| ); |
18 changes: 18 additions & 0 deletionsinternal/endtoend/testdata/enum_with_eq/sqlc.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| version: '2' | ||
| plugins: | ||
| - name: py | ||
| wasm: | ||
| url: file://../../../../bin/sqlc-gen-python.wasm | ||
| sha256: "4950a23b591192c23b87ec6b7e0a3826e17335e35ea6cbee745703920a252164" | ||
| sql: | ||
| - schema: schema.sql | ||
| queries: query.sql | ||
| engine: postgresql | ||
| codegen: | ||
| - plugin: py | ||
| out: db | ||
| options: | ||
| package: db | ||
| emit_sync_querier: true | ||
| emit_async_querier: true | ||
| emit_pydantic_models: true |
2 changes: 1 addition & 1 deletioninternal/endtoend/testdata/exec_result/sqlc.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletioninternal/endtoend/testdata/exec_rows/sqlc.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletioninternal/endtoend/testdata/inflection_exclude_table_names/sqlc.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletioninternal/endtoend/testdata/query_parameter_limit_two/sqlc.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletioninternal/endtoend/testdata/query_parameter_limit_undefined/sqlc.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletioninternal/endtoend/testdata/query_parameter_limit_zero/sqlc.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletioninternal/endtoend/testdata/query_parameter_no_limit/sqlc.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletionsinternal/gen.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.