Skip to content
Open
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ jobs:
- name: Install sqlc
uses: sqlc-dev/setup-sqlc@v4
with:
sqlc-version: '1.28.0'
sqlc-version: '1.29.0'

- name: Run sqlc verify via nox
run: |
Expand All @@ -187,7 +187,7 @@ jobs:
- name: Install sqlc
uses: sqlc-dev/setup-sqlc@v4
with:
sqlc-version: '1.28.0'
sqlc-version: '1.29.0'

- name: Run sqlc verify via nox
run: |
Expand All @@ -207,7 +207,7 @@ jobs:
- name: Install sqlc
uses: sqlc-dev/setup-sqlc@v4
with:
sqlc-version: '1.28.0'
sqlc-version: '1.29.0'

- name: Run sqlc verify via nox
run: |
Expand Down
61 changes: 52 additions & 9 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
from __future__ import annotations

import hashlib
import os
import pathlib
import typing

import nox
import yaml
from nox import options

if typing.TYPE_CHECKING:
import collections.abc

PATH_TO_PROJECT = pathlib.Path(__name__).parent
PATH_TO_PROJECT = pathlib.Path(__name__).parent.absolute()
SCRIPT_PATHS = ["noxfile.py", PATH_TO_PROJECT / "scripts", PATH_TO_PROJECT / "test"]
TESTS_PATH = PATH_TO_PROJECT / "test"

DRIVER_PATHS = {
"asyncpg": PATH_TO_PROJECT / "test" / "driver_asyncpg",
"aiosqlite": PATH_TO_PROJECT / "test" / "driver_aiosqlite",
"sqlite3": PATH_TO_PROJECT / "test" / "driver_sqlite3",
"asyncpg": TESTS_PATH / "driver_asyncpg",
"aiosqlite": TESTS_PATH / "driver_aiosqlite",
"sqlite3": TESTS_PATH / "driver_sqlite3",
}

SQLC_CONFIGS = ["sqlc.yaml"]
Expand Down Expand Up @@ -84,10 +87,52 @@ def sqlc_check(session: nox.Session, driver: str) -> None:


@nox.session(reuse_venv=True)
def update_test_plugin(session: nox.Session) -> None:
# Build the plugin
wasm_path = TESTS_PATH / "sqlc-gen-better-python.wasm"

with session.chdir("plugin"):
session.run(
"go",
"build",
"-o",
str(wasm_path),
env={"GOOS": "wasip1", "GOARCH": "wasm"},
external=True,
)

# Calculate the SHA256 hash
sha256_hasher = hashlib.sha256()
with wasm_path.open("rb") as fp:
while True:
data = fp.read(65536) # 64kb chunks
if not data:
break

sha256_hasher.update(data)

plugin_hash = sha256_hasher.hexdigest()

# Update the SHA256 in the config files
for driver_name, driver_path in DRIVER_PATHS.items():
for config_filename in SQLC_CONFIGS:
config_path = driver_path / config_filename

with config_path.open() as fp:
config = yaml.safe_load(fp)

config["plugins"][0]["wasm"]["sha256"] = plugin_hash

with config_path.open("w") as fp:
yaml.safe_dump(config, fp)

sqlc_generate(session, driver_name)


@nox.session(reuse_venv=True, requires=["update_test_plugin"])
def sqlite3(session: nox.Session) -> None:
uv_sync(session, include_self=True, groups=["pyright", "ruff"])

sqlc_generate(session, "sqlite3")
session.run("pyright", DRIVER_PATHS["sqlite3"])
session.run("ruff", "check", *session.posargs, DRIVER_PATHS["sqlite3"])

Expand All @@ -101,11 +146,10 @@ def sqlite3_check(session: nox.Session) -> None:
session.run("ruff", "check", *session.posargs, DRIVER_PATHS["sqlite3"])


@nox.session(reuse_venv=True)
@nox.session(reuse_venv=True, requires=["update_test_plugin"])
def aiosqlite(session: nox.Session) -> None:
uv_sync(session, include_self=True, groups=["pyright", "ruff"])

sqlc_generate(session, "aiosqlite")
session.run("pyright", DRIVER_PATHS["aiosqlite"])
session.run("ruff", "check", *session.posargs, DRIVER_PATHS["aiosqlite"])

Expand All @@ -119,11 +163,10 @@ def aiosqlite_check(session: nox.Session) -> None:
session.run("ruff", "check", *session.posargs, DRIVER_PATHS["aiosqlite"])


@nox.session(reuse_venv=True)
@nox.session(reuse_venv=True, requires=["update_test_plugin"])
def asyncpg(session: nox.Session) -> None:
uv_sync(session, include_self=True, groups=["pyright", "ruff"])

sqlc_generate(session, "asyncpg")
session.run("pyright", DRIVER_PATHS["asyncpg"])
session.run("ruff", "check", *session.posargs, DRIVER_PATHS["asyncpg"])

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies = [
[dependency-groups]
dev = [
"nox>=2025.5.1",
"pyyaml>=6.0.2",
]
dev-complete = [
"nox>=2025.5.1",
Expand Down
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/attrs/classes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Package containing queries and models automatically generated using sqlc-gen-better-python."""
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/attrs/classes/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Module containing models."""
from __future__ import annotations

Expand Down
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/attrs/classes/queries.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Module containing queries from file queries.sql."""
from __future__ import annotations

Expand Down
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/attrs/functions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Package containing queries and models automatically generated using sqlc-gen-better-python."""
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/attrs/functions/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Module containing models."""
from __future__ import annotations

Expand Down
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/attrs/functions/queries.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Module containing queries from file queries.sql."""
from __future__ import annotations

Expand Down
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/dataclass/classes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Package containing queries and models automatically generated using sqlc-gen-better-python."""
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/dataclass/classes/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Module containing models."""
from __future__ import annotations

Expand Down
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/dataclass/classes/queries.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Module containing queries from file queries.sql."""
from __future__ import annotations

Expand Down
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/dataclass/functions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Package containing queries and models automatically generated using sqlc-gen-better-python."""
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/dataclass/functions/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Module containing models."""
from __future__ import annotations

Expand Down
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/dataclass/functions/queries.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Module containing queries from file queries.sql."""
from __future__ import annotations

Expand Down
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/msgspec/classes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Package containing queries and models automatically generated using sqlc-gen-better-python."""
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/msgspec/classes/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Module containing models."""
from __future__ import annotations

Expand Down
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/msgspec/classes/queries.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Module containing queries from file queries.sql."""
from __future__ import annotations

Expand Down
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/msgspec/functions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Package containing queries and models automatically generated using sqlc-gen-better-python."""
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/msgspec/functions/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Module containing models."""
from __future__ import annotations

Expand Down
4 changes: 2 additions & 2 deletions test/driver_aiosqlite/msgspec/functions/queries.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.28.0
# sqlc-gen-better-python v0.4.3
# sqlc v1.29.0
# sqlc-gen-better-python v0.4.4
"""Module containing queries from file queries.sql."""
from __future__ import annotations

Expand Down
Loading