Skip to content

Commit 4a7f0df

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 449d140 + 8a24f3a commit 4a7f0df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+3233
-632
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1-
name: make
1+
name: go
22
on:
33
push:
44
branches:
55
- main
66
pull_request:
77
jobs:
8-
build:
8+
test:
99
name: test
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3
13-
- uses: actions/setup-go@v4
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-go@v5
1414
with:
15-
go-version: '1.21.0'
15+
go-version: '1.21'
16+
# - run: go install github.com/sqlc-dev/sqlc/cmd/sqlc@main
17+
- uses: sqlc-dev/setup-sqlc@v4
18+
with:
19+
sqlc-version: '1.25.0'
1620
- run: make
21+
- run: make test
22+
- run: sqlc diff
23+
working-directory: examples
24+
1725
- uses: actions/upload-artifact@v3
1826
with:
1927
name: sqlc-gen-python

.github/workflows/db.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: db
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
jobs:
8+
9+
build:
10+
name: test
11+
runs-on: ubuntu-latest
12+
13+
services:
14+
postgres:
15+
image: postgres:11
16+
env:
17+
POSTGRES_USER: postgres
18+
POSTGRES_PASSWORD: postgres
19+
POSTGRES_DB: postgres
20+
ports:
21+
- 5432:5432
22+
# needed because the postgres container does not provide a healthcheck
23+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: 3.9
30+
- name: Install python dependencies
31+
working-directory: ./examples
32+
run: |
33+
python -m pip install --upgrade pip
34+
python -m pip install -r requirements.txt
35+
- name: Test python code
36+
working-directory: ./examples
37+
env:
38+
PG_USER: postgres
39+
PG_HOST: localhost
40+
PG_DATABASE: postgres
41+
PG_PASSWORD: postgres
42+
PG_PORT: ${{ job.services.postgres.ports['5432'] }}
43+
run: |
44+
pytest src/tests

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
*.wasm
1+
bin
2+
*.wasm
3+
4+
# Devenv
5+
.envrc
6+
.direnv
7+
.devenv*
8+
devenv.local.nix

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 Kyle Conroy
3+
Copyright (c) 2023 Riza, Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Makefile

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
all: sqlc-gen-python sqlc-gen-python.wasm
1+
.PHONY: build test
22

3-
sqlc-gen-python:
4-
cd plugin && go build -o ~/bin/sqlc-gen-python ./main.go
3+
build:
4+
go build ./...
55

6-
sqlc-gen-python.wasm:
7-
cd plugin && GOOS=wasip1 GOARCH=wasm go build -o sqlc-gen-python.wasm main.go
8-
openssl sha256 plugin/sqlc-gen-python.wasm
6+
test: bin/sqlc-gen-python.wasm
7+
go test ./...
8+
9+
all: bin/sqlc-gen-python bin/sqlc-gen-python.wasm
10+
11+
bin/sqlc-gen-python: bin go.mod go.sum $(wildcard **/*.go)
12+
cd plugin && go build -o ../bin/sqlc-gen-python ./main.go
13+
14+
bin/sqlc-gen-python.wasm: bin/sqlc-gen-python
15+
cd plugin && GOOS=wasip1 GOARCH=wasm go build -o ../bin/sqlc-gen-python.wasm main.go
16+
17+
bin:
18+
mkdir -p bin

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ version: '2'
66
plugins:
77
- name: py
88
wasm:
9-
url: https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.1.0.wasm
10-
sha256: ef58f143a8c116781091441770c7166caaf361dd645f62b8f05f462e9f95c3b2
9+
url: https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.2.0.wasm
10+
sha256: a6c5d174c407007c3717eea36ff0882744346e6ba991f92f71d6ab2895204c0e
1111
sql:
1212
- schema: "schema.sql"
1313
queries: "query.sql"

buf.gen.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: v1
2+
managed:
3+
enabled: true
4+
plugins:
5+
- plugin: buf.build/protocolbuffers/go:v1.30.0
6+
out: internal
7+
opt: paths=source_relative

buf.work.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version: v1
2+
directories:
3+
- protos

devenv.lock

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
{
2+
"nodes": {
3+
"devenv": {
4+
"locked": {
5+
"dir": "src/modules",
6+
"lastModified": 1698243190,
7+
"narHash": "sha256-n+SbyNQRhUcaZoU00d+7wi17HJpw/kAUrXOL4zRcqE8=",
8+
"owner": "cachix",
9+
"repo": "devenv",
10+
"rev": "86f476f7edb86159fd20764489ab4e4df6edb4b6",
11+
"type": "github"
12+
},
13+
"original": {
14+
"dir": "src/modules",
15+
"owner": "cachix",
16+
"repo": "devenv",
17+
"type": "github"
18+
}
19+
},
20+
"flake-compat": {
21+
"flake": false,
22+
"locked": {
23+
"lastModified": 1673956053,
24+
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
25+
"owner": "edolstra",
26+
"repo": "flake-compat",
27+
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
28+
"type": "github"
29+
},
30+
"original": {
31+
"owner": "edolstra",
32+
"repo": "flake-compat",
33+
"type": "github"
34+
}
35+
},
36+
"flake-utils": {
37+
"inputs": {
38+
"systems": "systems"
39+
},
40+
"locked": {
41+
"lastModified": 1685518550,
42+
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
43+
"owner": "numtide",
44+
"repo": "flake-utils",
45+
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
46+
"type": "github"
47+
},
48+
"original": {
49+
"owner": "numtide",
50+
"repo": "flake-utils",
51+
"type": "github"
52+
}
53+
},
54+
"gitignore": {
55+
"inputs": {
56+
"nixpkgs": [
57+
"pre-commit-hooks",
58+
"nixpkgs"
59+
]
60+
},
61+
"locked": {
62+
"lastModified": 1660459072,
63+
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
64+
"owner": "hercules-ci",
65+
"repo": "gitignore.nix",
66+
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
67+
"type": "github"
68+
},
69+
"original": {
70+
"owner": "hercules-ci",
71+
"repo": "gitignore.nix",
72+
"type": "github"
73+
}
74+
},
75+
"nixpkgs": {
76+
"locked": {
77+
"lastModified": 1698553279,
78+
"narHash": "sha256-T/9P8yBSLcqo/v+FTOBK+0rjzjPMctVymZydbvR/Fak=",
79+
"owner": "NixOS",
80+
"repo": "nixpkgs",
81+
"rev": "90e85bc7c1a6fc0760a94ace129d3a1c61c3d035",
82+
"type": "github"
83+
},
84+
"original": {
85+
"owner": "NixOS",
86+
"ref": "nixpkgs-unstable",
87+
"repo": "nixpkgs",
88+
"type": "github"
89+
}
90+
},
91+
"nixpkgs-stable": {
92+
"locked": {
93+
"lastModified": 1685801374,
94+
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
95+
"owner": "NixOS",
96+
"repo": "nixpkgs",
97+
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
98+
"type": "github"
99+
},
100+
"original": {
101+
"owner": "NixOS",
102+
"ref": "nixos-23.05",
103+
"repo": "nixpkgs",
104+
"type": "github"
105+
}
106+
},
107+
"pre-commit-hooks": {
108+
"inputs": {
109+
"flake-compat": "flake-compat",
110+
"flake-utils": "flake-utils",
111+
"gitignore": "gitignore",
112+
"nixpkgs": [
113+
"nixpkgs"
114+
],
115+
"nixpkgs-stable": "nixpkgs-stable"
116+
},
117+
"locked": {
118+
"lastModified": 1698227354,
119+
"narHash": "sha256-Fi5H9jbaQLmLw9qBi/mkR33CoFjNbobo5xWdX4tKz1Q=",
120+
"owner": "cachix",
121+
"repo": "pre-commit-hooks.nix",
122+
"rev": "bd38df3d508dfcdff52cd243d297f218ed2257bf",
123+
"type": "github"
124+
},
125+
"original": {
126+
"owner": "cachix",
127+
"repo": "pre-commit-hooks.nix",
128+
"type": "github"
129+
}
130+
},
131+
"root": {
132+
"inputs": {
133+
"devenv": "devenv",
134+
"nixpkgs": "nixpkgs",
135+
"pre-commit-hooks": "pre-commit-hooks"
136+
}
137+
},
138+
"systems": {
139+
"locked": {
140+
"lastModified": 1681028828,
141+
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
142+
"owner": "nix-systems",
143+
"repo": "default",
144+
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
145+
"type": "github"
146+
},
147+
"original": {
148+
"owner": "nix-systems",
149+
"repo": "default",
150+
"type": "github"
151+
}
152+
}
153+
},
154+
"root": "root",
155+
"version": 7
156+
}

devenv.nix

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{ pkgs, ... }:
2+
3+
{
4+
# https://devenv.sh/packages/
5+
packages = [
6+
pkgs.go
7+
pkgs.git
8+
pkgs.govulncheck
9+
pkgs.gopls
10+
pkgs.golint
11+
pkgs.python311
12+
];
13+
}

devenv.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
inputs:
2+
nixpkgs:
3+
url: github:NixOS/nixpkgs/nixpkgs-unstable

examples/requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pytest~=6.2.2
2+
pytest-asyncio~=0.14.0
3+
psycopg2-binary~=2.8.6
4+
asyncpg~=0.21.0
5+
sqlalchemy==1.4.0

examples/sqlc.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
version: '2'
2+
plugins:
3+
- name: py
4+
wasm:
5+
url: https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.2.0.wasm
6+
sha256: a6c5d174c407007c3717eea36ff0882744346e6ba991f92f71d6ab2895204c0e
7+
sql:
8+
- schema: "src/authors/schema.sql"
9+
queries: "src/authors/query.sql"
10+
engine: postgresql
11+
codegen:
12+
- out: src/authors
13+
plugin: py
14+
options:
15+
package: authors
16+
emit_sync_querier: true
17+
emit_async_querier: true
18+
query_parameter_limit: 5
19+
- schema: "src/booktest/schema.sql"
20+
queries: "src/booktest/query.sql"
21+
engine: postgresql
22+
codegen:
23+
- out: src/booktest
24+
plugin: py
25+
options:
26+
package: booktest
27+
emit_async_querier: true
28+
query_parameter_limit: 5
29+
- schema: "src/jets/schema.sql"
30+
queries: "src/jets/query-building.sql"
31+
engine: postgresql
32+
codegen:
33+
- out: src/jets
34+
plugin: py
35+
options:
36+
package: jets
37+
emit_async_querier: true
38+
query_parameter_limit: 5
39+
- schema: "src/ondeck/schema"
40+
queries: "src/ondeck/query"
41+
engine: postgresql
42+
codegen:
43+
- out: src/ondeck
44+
plugin: py
45+
options:
46+
package: ondeck
47+
emit_async_querier: true
48+
query_parameter_limit: 5

examples/src/authors/__init__.py

Whitespace-only changes.

examples/src/authors/models.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Code generated by sqlc. DO NOT EDIT.
2+
# versions:
3+
# sqlc v1.25.0
4+
import dataclasses
5+
from typing import Optional
6+
7+
8+
@dataclasses.dataclass()
9+
class Author:
10+
id: int
11+
name: str
12+
bio: Optional[str]

0 commit comments

Comments
 (0)