Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: emit_module, emit_generators and emit_async flags#15

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
kevinvalk wants to merge10 commits intosqlc-dev:main
base:main
Choose a base branch
Loading
fromcodean-io:main
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
10 commits
Select commitHold shift + click to select a range
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
30 changes: 30 additions & 0 deletions.github/workflows/ci.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
name: go
on:
push:
tags:
- v*
branches:
- main
pull_request:
Expand All@@ -21,3 +23,31 @@ jobs:
- run: make test
- run: sqlc diff
working-directory: examples

- name: Generate checksum
id: checksum
run: |-
echo "sha256=$(sha256sum bin/sqlc-gen-python.wasm | awk '{ print $1 }')" >> $GITHUB_OUTPUT

- uses: actions/upload-artifact@v4
with:
name: sqlc-gen-python
path: bin/sqlc-gen-python.wasm

- name: Release the build on tag
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
body: |
# Configuration
```yaml
version: '2'
plugins:
- name: py
wasm:
url: ${{ github.server_url }}/${{ github.repository}}/releases/download/${{ github.ref_name }}/sqlc-gen-python.wasm
sha256: ${{ steps.checksum.outputs.sha256 }}
```
generate_release_notes: true
files: |
bin/sqlc-gen-python.wasm
16 changes: 14 additions & 2 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
# README
## Usage

```yaml
Expand All@@ -16,6 +17,17 @@ sql:
plugin: py
options:
package: authors
emit_sync_querier: true
emit_async_querier: true
emit_module: false
emit_generators: true
emit_async: false
```

## Multiple packages
If you have have a mono-repository setup you may want to split the output of queries and models. You can achieve this by using the `output_models_file_name`
and `output_querier_file` fields. If `output_models_file_name` is set to `null` for it will not output the `models.py` file. Setting `output_querier_file` to false will prevent outputting any query files. Combining these you can set one codegen to only output models while the other codegen outputs only queries. Make sure the `package` configuration is set equally so the query files import correctly the models.

SQLC needs at least one query, so you may need to add a unused query like the following in your schema and reuse the `schema` as `queries`.
```sql
-- name: Skip :one
SELECT 1;
```
375 changes: 193 additions & 182 deletionsinternal/ast/ast.pb.go
View file
Open in desktop

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletionsinternal/config.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
package python

// TODO: Where are these properly documented?
type Config struct {
EmitAsync bool `json:"emit_async"` // Emits async code instead of sync
EmitExactTableNames bool `json:"emit_exact_table_names"`
EmitSyncQuerier bool `json:"emit_sync_querier"`
EmitAsyncQuerier bool `json:"emit_async_querier"`
Package string `json:"package"`
Out string `json:"out"`
EmitGenerators bool `json:"emit_generators"` // Will we use generators or lists, defaults to false
EmitModule bool `json:"emit_module"` // If true emits functions in module, else wraps in a class.
EmitPydanticModels bool `json:"emit_pydantic_models"`
QueryParameterLimit *int32 `json:"query_parameter_limit"`
EmitSyncQuerier bool `json:"emit_sync_querier"` // DEPRECATED ALIAS FOR: emit_type = 'class', emit_generators = True
EmitAsyncQuerier bool `json:"emit_async_querier"` // DEPRECATED ALIAS FOR: emit_type = 'class', emit_generators = True
InflectionExcludeTableNames []string `json:"inflection_exclude_table_names"`
Out string `json:"out"`
OutputModelsFileName *string `json:"output_models_file_name,omitempty"` // Can be string or null to exclude generating models file
OutputQuerierFile bool `json:"output_querier_file,omitempty"` // Skips outputting queries
Package string `json:"package"`
QueryParameterLimit *int32 `json:"query_parameter_limit"`
}
3 changes: 2 additions & 1 deletioninternal/endtoend/endtoend_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,8 +100,9 @@ func TestGenerate(t *testing.T) {
cmd := exec.Command(sqlc, "diff")
cmd.Dir = dir
got, err := cmd.CombinedOutput()
// TODO: We are diffing patches! Does this make sense and what should we provide to the end user?
if diff := cmp.Diff(string(want), string(got)); diff != "" {
t.Errorf("sqlc diff mismatch (-want +got):\n%s",diff)
t.Errorf("sqlc diff mismatch (-want +got):\n%s",string(got))
}
if len(want) == 0 && err != nil {
t.Error(err)
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ plugins:
- name: py
wasm:
url: file://../../../../bin/sqlc-gen-python.wasm
sha256: "a6c5d174c407007c3717eea36ff0882744346e6ba991f92f71d6ab2895204c0e"
sha256: "c97fad53818679a948c68f3ffe84530d7ca4999f636d3f3d89202c6c08ee224d"
sql:
- schema: schema.sql
queries: query.sql
Expand Down
2 changes: 1 addition & 1 deletioninternal/endtoend/testdata/exec_result/sqlc.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ plugins:
- name: py
wasm:
url: file://../../../../bin/sqlc-gen-python.wasm
sha256: "a6c5d174c407007c3717eea36ff0882744346e6ba991f92f71d6ab2895204c0e"
sha256: "c97fad53818679a948c68f3ffe84530d7ca4999f636d3f3d89202c6c08ee224d"
sql:
- schema: schema.sql
queries: query.sql
Expand Down
2 changes: 1 addition & 1 deletioninternal/endtoend/testdata/exec_rows/sqlc.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ plugins:
- name: py
wasm:
url: file://../../../../bin/sqlc-gen-python.wasm
sha256: "a6c5d174c407007c3717eea36ff0882744346e6ba991f92f71d6ab2895204c0e"
sha256: "c97fad53818679a948c68f3ffe84530d7ca4999f636d3f3d89202c6c08ee224d"
sql:
- schema: schema.sql
queries: query.sql
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ plugins:
- name: py
wasm:
url: file://../../../../bin/sqlc-gen-python.wasm
sha256: "a6c5d174c407007c3717eea36ff0882744346e6ba991f92f71d6ab2895204c0e"
sha256: "c97fad53818679a948c68f3ffe84530d7ca4999f636d3f3d89202c6c08ee224d"
sql:
- schema: schema.sql
queries: query.sql
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ plugins:
- name: py
wasm:
url: file://../../../../bin/sqlc-gen-python.wasm
sha256: "a6c5d174c407007c3717eea36ff0882744346e6ba991f92f71d6ab2895204c0e"
sha256: "c97fad53818679a948c68f3ffe84530d7ca4999f636d3f3d89202c6c08ee224d"
sql:
- schema: schema.sql
queries: query.sql
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ plugins:
- name: py
wasm:
url: file://../../../../bin/sqlc-gen-python.wasm
sha256: "a6c5d174c407007c3717eea36ff0882744346e6ba991f92f71d6ab2895204c0e"
sha256: "c97fad53818679a948c68f3ffe84530d7ca4999f636d3f3d89202c6c08ee224d"
sql:
- schema: schema.sql
queries: query.sql
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ plugins:
- name: py
wasm:
url: file://../../../../bin/sqlc-gen-python.wasm
sha256: "a6c5d174c407007c3717eea36ff0882744346e6ba991f92f71d6ab2895204c0e"
sha256: "c97fad53818679a948c68f3ffe84530d7ca4999f636d3f3d89202c6c08ee224d"
sql:
- schema: schema.sql
queries: query.sql
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ plugins:
- name: py
wasm:
url: file://../../../../bin/sqlc-gen-python.wasm
sha256: "a6c5d174c407007c3717eea36ff0882744346e6ba991f92f71d6ab2895204c0e"
sha256: "c97fad53818679a948c68f3ffe84530d7ca4999f636d3f3d89202c6c08ee224d"
sql:
- schema: schema.sql
queries: query.sql
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp