From 71b695237457fc83bf5d133d86a4a74dafa3f4bc Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Wed, 1 Nov 2023 16:33:34 -0700 Subject: [PATCH 1/5] test: New workflow for sqlc-gen-python --- .github/workflows/ci-python.yml | 38 ++++++++------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci-python.yml b/.github/workflows/ci-python.yml index 0edb94092a..09fc231186 100644 --- a/.github/workflows/ci-python.yml +++ b/.github/workflows/ci-python.yml @@ -10,35 +10,15 @@ jobs: name: test runs-on: ubuntu-latest - services: - postgres: - image: postgres:11 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: postgres - ports: - - 5432:5432 - # needed because the postgres container does not provide a healthcheck - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-go@v4 with: - python-version: 3.9 - - name: Install python dependencies - working-directory: ./examples/python - run: | - python -m pip install --upgrade pip - python -m pip install -r requirements.txt - - name: Test python code - working-directory: ./examples/python - env: - PG_USER: postgres - PG_HOST: localhost - PG_DATABASE: postgres - PG_PASSWORD: postgres - PG_PORT: ${{ job.services.postgres.ports['5432'] }} - run: | - pytest src/tests + go-version: '1.21.3' + - name: install ./... + run: go install ./... + - uses: actions/checkout@v4 + repository: sqlc-dev/sqlc-gen-python + path: python + - run: make test + working-directory: python From c75b9b8d913d4d7c9005d2e44e4f633490148c10 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Wed, 1 Nov 2023 16:39:34 -0700 Subject: [PATCH 2/5] fix workflow --- .github/workflows/ci-python.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-python.yml b/.github/workflows/ci-python.yml index 09fc231186..6abd1dc4ab 100644 --- a/.github/workflows/ci-python.yml +++ b/.github/workflows/ci-python.yml @@ -18,7 +18,8 @@ jobs: - name: install ./... run: go install ./... - uses: actions/checkout@v4 - repository: sqlc-dev/sqlc-gen-python - path: python + with: + repository: sqlc-dev/sqlc-gen-python + path: python - run: make test working-directory: python From 70356762cef515e210c2fb083c007e3586bd0be1 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Wed, 1 Nov 2023 16:46:00 -0700 Subject: [PATCH 3/5] Run diff in the python examples --- .github/workflows/ci-python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-python.yml b/.github/workflows/ci-python.yml index 6abd1dc4ab..d6b8251771 100644 --- a/.github/workflows/ci-python.yml +++ b/.github/workflows/ci-python.yml @@ -5,11 +5,9 @@ on: - main pull_request: jobs: - build: name: test runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v4 @@ -23,3 +21,5 @@ jobs: path: python - run: make test working-directory: python + - run: sqlc diff + working-directory: python/examples From 7aa9ef06ad12c612b15e02203b72c7b92f419d48 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Thu, 2 Nov 2023 16:55:35 -0700 Subject: [PATCH 4/5] docs: Remove Python examples They now live in sqlc-gen-python --- examples/python/requirements.txt | 5 - examples/python/sqlc.json | 79 -------- examples/python/src/authors/__init__.py | 0 examples/python/src/authors/models.py | 12 -- examples/python/src/authors/query.py | 112 ----------- examples/python/src/booktest/__init__.py | 0 examples/python/src/booktest/models.py | 30 --- examples/python/src/booktest/query.py | 211 --------------------- examples/python/src/dbtest/__init__.py | 0 examples/python/src/dbtest/migrations.py | 43 ----- examples/python/src/jets/__init__.py | 0 examples/python/src/jets/models.py | 31 --- examples/python/src/jets/query-building.py | 47 ----- examples/python/src/ondeck/__init__.py | 0 examples/python/src/ondeck/city.py | 76 -------- examples/python/src/ondeck/models.py | 35 ---- examples/python/src/ondeck/venue.py | 159 ---------------- examples/python/src/tests/__init__.py | 0 examples/python/src/tests/conftest.py | 67 ------- examples/python/src/tests/test_authors.py | 56 ------ examples/python/src/tests/test_booktest.py | 85 --------- examples/python/src/tests/test_ondeck.py | 53 ------ 22 files changed, 1101 deletions(-) delete mode 100644 examples/python/requirements.txt delete mode 100644 examples/python/sqlc.json delete mode 100644 examples/python/src/authors/__init__.py delete mode 100644 examples/python/src/authors/models.py delete mode 100644 examples/python/src/authors/query.py delete mode 100644 examples/python/src/booktest/__init__.py delete mode 100644 examples/python/src/booktest/models.py delete mode 100644 examples/python/src/booktest/query.py delete mode 100644 examples/python/src/dbtest/__init__.py delete mode 100644 examples/python/src/dbtest/migrations.py delete mode 100644 examples/python/src/jets/__init__.py delete mode 100644 examples/python/src/jets/models.py delete mode 100644 examples/python/src/jets/query-building.py delete mode 100644 examples/python/src/ondeck/__init__.py delete mode 100644 examples/python/src/ondeck/city.py delete mode 100644 examples/python/src/ondeck/models.py delete mode 100644 examples/python/src/ondeck/venue.py delete mode 100644 examples/python/src/tests/__init__.py delete mode 100644 examples/python/src/tests/conftest.py delete mode 100644 examples/python/src/tests/test_authors.py delete mode 100644 examples/python/src/tests/test_booktest.py delete mode 100644 examples/python/src/tests/test_ondeck.py diff --git a/examples/python/requirements.txt b/examples/python/requirements.txt deleted file mode 100644 index 26f645a169..0000000000 --- a/examples/python/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -pytest~=6.2.2 -pytest-asyncio~=0.14.0 -psycopg2-binary~=2.8.6 -asyncpg~=0.21.0 -sqlalchemy==1.4.0 diff --git a/examples/python/sqlc.json b/examples/python/sqlc.json deleted file mode 100644 index 29d3cc8464..0000000000 --- a/examples/python/sqlc.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "version": "2", - "plugins": [ - { - "name": "py", - "wasm": { - "url": "https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.1.0.wasm", - "sha256": "ef58f143a8c116781091441770c7166caaf361dd645f62b8f05f462e9f95c3b2" - } - } - ], - "sql": [ - { - "schema": "../authors/postgresql/schema.sql", - "queries": "../authors/postgresql/query.sql", - "engine": "postgresql", - "codegen": [ - { - "out": "src/authors", - "plugin": "py", - "options": { - "package": "authors", - "emit_sync_querier": true, - "emit_async_querier": true, - "query_parameter_limit": 5 - } - } - ] - }, - { - "schema": "../booktest/postgresql/schema.sql", - "queries": "../booktest/postgresql/query.sql", - "engine": "postgresql", - "codegen": [ - { - "out": "src/booktest", - "plugin": "py", - "options": { - "package": "booktest", - "emit_async_querier": true, - "query_parameter_limit": 5 - } - } - ] - }, - { - "schema": "../jets/postgresql/schema.sql", - "queries": "../jets/postgresql/query-building.sql", - "engine": "postgresql", - "codegen": [ - { - "out": "src/jets", - "plugin": "py", - "options": { - "package": "jets", - "emit_async_querier": true, - "query_parameter_limit": 5 - } - } - ] - }, - { - "schema": "../ondeck/postgresql/schema", - "queries": "../ondeck/postgresql/query", - "engine": "postgresql", - "codegen": [ - { - "out": "src/ondeck", - "plugin": "py", - "options": { - "package": "ondeck", - "emit_async_querier": true, - "query_parameter_limit": 5 - } - } - ] - } - ] -} diff --git a/examples/python/src/authors/__init__.py b/examples/python/src/authors/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/python/src/authors/models.py b/examples/python/src/authors/models.py deleted file mode 100644 index a8d25d0c34..0000000000 --- a/examples/python/src/authors/models.py +++ /dev/null @@ -1,12 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -import dataclasses -from typing import Optional - - -@dataclasses.dataclass() -class Author: - id: int - name: str - bio: Optional[str] diff --git a/examples/python/src/authors/query.py b/examples/python/src/authors/query.py deleted file mode 100644 index 58eccb90fa..0000000000 --- a/examples/python/src/authors/query.py +++ /dev/null @@ -1,112 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -# source: query.sql -from typing import AsyncIterator, Iterator, Optional - -import sqlalchemy -import sqlalchemy.ext.asyncio - -from authors import models - - -CREATE_AUTHOR = """-- name: create_author \\:one -INSERT INTO authors ( - name, bio -) VALUES ( - :p1, :p2 -) -RETURNING id, name, bio -""" - - -DELETE_AUTHOR = """-- name: delete_author \\:exec -DELETE FROM authors -WHERE id = :p1 -""" - - -GET_AUTHOR = """-- name: get_author \\:one -SELECT id, name, bio FROM authors -WHERE id = :p1 LIMIT 1 -""" - - -LIST_AUTHORS = """-- name: list_authors \\:many -SELECT id, name, bio FROM authors -ORDER BY name -""" - - -class Querier: - def __init__(self, conn: sqlalchemy.engine.Connection): - self._conn = conn - - def create_author(self, *, name: str, bio: Optional[str]) -> Optional[models.Author]: - row = self._conn.execute(sqlalchemy.text(CREATE_AUTHOR), {"p1": name, "p2": bio}).first() - if row is None: - return None - return models.Author( - id=row[0], - name=row[1], - bio=row[2], - ) - - def delete_author(self, *, id: int) -> None: - self._conn.execute(sqlalchemy.text(DELETE_AUTHOR), {"p1": id}) - - def get_author(self, *, id: int) -> Optional[models.Author]: - row = self._conn.execute(sqlalchemy.text(GET_AUTHOR), {"p1": id}).first() - if row is None: - return None - return models.Author( - id=row[0], - name=row[1], - bio=row[2], - ) - - def list_authors(self) -> Iterator[models.Author]: - result = self._conn.execute(sqlalchemy.text(LIST_AUTHORS)) - for row in result: - yield models.Author( - id=row[0], - name=row[1], - bio=row[2], - ) - - -class AsyncQuerier: - def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): - self._conn = conn - - async def create_author(self, *, name: str, bio: Optional[str]) -> Optional[models.Author]: - row = (await self._conn.execute(sqlalchemy.text(CREATE_AUTHOR), {"p1": name, "p2": bio})).first() - if row is None: - return None - return models.Author( - id=row[0], - name=row[1], - bio=row[2], - ) - - async def delete_author(self, *, id: int) -> None: - await self._conn.execute(sqlalchemy.text(DELETE_AUTHOR), {"p1": id}) - - async def get_author(self, *, id: int) -> Optional[models.Author]: - row = (await self._conn.execute(sqlalchemy.text(GET_AUTHOR), {"p1": id})).first() - if row is None: - return None - return models.Author( - id=row[0], - name=row[1], - bio=row[2], - ) - - async def list_authors(self) -> AsyncIterator[models.Author]: - result = await self._conn.stream(sqlalchemy.text(LIST_AUTHORS)) - async for row in result: - yield models.Author( - id=row[0], - name=row[1], - bio=row[2], - ) diff --git a/examples/python/src/booktest/__init__.py b/examples/python/src/booktest/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/python/src/booktest/models.py b/examples/python/src/booktest/models.py deleted file mode 100644 index 712f16663f..0000000000 --- a/examples/python/src/booktest/models.py +++ /dev/null @@ -1,30 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -import dataclasses -import datetime -import enum -from typing import List - - -class BookType(str, enum.Enum): - FICTION = "FICTION" - NONFICTION = "NONFICTION" - - -@dataclasses.dataclass() -class Author: - author_id: int - name: str - - -@dataclasses.dataclass() -class Book: - book_id: int - author_id: int - isbn: str - book_type: BookType - title: str - year: int - available: datetime.datetime - tags: List[str] diff --git a/examples/python/src/booktest/query.py b/examples/python/src/booktest/query.py deleted file mode 100644 index 94b8565bc0..0000000000 --- a/examples/python/src/booktest/query.py +++ /dev/null @@ -1,211 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -# source: query.sql -import dataclasses -import datetime -from typing import AsyncIterator, List, Optional - -import sqlalchemy -import sqlalchemy.ext.asyncio - -from booktest import models - - -BOOKS_BY_TAGS = """-- name: books_by_tags \\:many -SELECT - book_id, - title, - name, - isbn, - tags -FROM books -LEFT JOIN authors ON books.author_id = authors.author_id -WHERE tags && :p1\\:\\:varchar[] -""" - - -@dataclasses.dataclass() -class BooksByTagsRow: - book_id: int - title: str - name: Optional[str] - isbn: str - tags: List[str] - - -BOOKS_BY_TITLE_YEAR = """-- name: books_by_title_year \\:many -SELECT book_id, author_id, isbn, book_type, title, year, available, tags FROM books -WHERE title = :p1 AND year = :p2 -""" - - -CREATE_AUTHOR = """-- name: create_author \\:one -INSERT INTO authors (name) VALUES (:p1) -RETURNING author_id, name -""" - - -CREATE_BOOK = """-- name: create_book \\:one -INSERT INTO books ( - author_id, - isbn, - book_type, - title, - year, - available, - tags -) VALUES ( - :p1, - :p2, - :p3, - :p4, - :p5, - :p6, - :p7 -) -RETURNING book_id, author_id, isbn, book_type, title, year, available, tags -""" - - -@dataclasses.dataclass() -class CreateBookParams: - author_id: int - isbn: str - book_type: models.BookType - title: str - year: int - available: datetime.datetime - tags: List[str] - - -DELETE_BOOK = """-- name: delete_book \\:exec -DELETE FROM books -WHERE book_id = :p1 -""" - - -GET_AUTHOR = """-- name: get_author \\:one -SELECT author_id, name FROM authors -WHERE author_id = :p1 -""" - - -GET_BOOK = """-- name: get_book \\:one -SELECT book_id, author_id, isbn, book_type, title, year, available, tags FROM books -WHERE book_id = :p1 -""" - - -UPDATE_BOOK = """-- name: update_book \\:exec -UPDATE books -SET title = :p1, tags = :p2 -WHERE book_id = :p3 -""" - - -UPDATE_BOOK_ISBN = """-- name: update_book_isbn \\:exec -UPDATE books -SET title = :p1, tags = :p2, isbn = :p4 -WHERE book_id = :p3 -""" - - -class AsyncQuerier: - def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): - self._conn = conn - - async def books_by_tags(self, *, dollar_1: List[str]) -> AsyncIterator[BooksByTagsRow]: - result = await self._conn.stream(sqlalchemy.text(BOOKS_BY_TAGS), {"p1": dollar_1}) - async for row in result: - yield BooksByTagsRow( - book_id=row[0], - title=row[1], - name=row[2], - isbn=row[3], - tags=row[4], - ) - - async def books_by_title_year(self, *, title: str, year: int) -> AsyncIterator[models.Book]: - result = await self._conn.stream(sqlalchemy.text(BOOKS_BY_TITLE_YEAR), {"p1": title, "p2": year}) - async for row in result: - yield models.Book( - book_id=row[0], - author_id=row[1], - isbn=row[2], - book_type=row[3], - title=row[4], - year=row[5], - available=row[6], - tags=row[7], - ) - - async def create_author(self, *, name: str) -> Optional[models.Author]: - row = (await self._conn.execute(sqlalchemy.text(CREATE_AUTHOR), {"p1": name})).first() - if row is None: - return None - return models.Author( - author_id=row[0], - name=row[1], - ) - - async def create_book(self, arg: CreateBookParams) -> Optional[models.Book]: - row = (await self._conn.execute(sqlalchemy.text(CREATE_BOOK), { - "p1": arg.author_id, - "p2": arg.isbn, - "p3": arg.book_type, - "p4": arg.title, - "p5": arg.year, - "p6": arg.available, - "p7": arg.tags, - })).first() - if row is None: - return None - return models.Book( - book_id=row[0], - author_id=row[1], - isbn=row[2], - book_type=row[3], - title=row[4], - year=row[5], - available=row[6], - tags=row[7], - ) - - async def delete_book(self, *, book_id: int) -> None: - await self._conn.execute(sqlalchemy.text(DELETE_BOOK), {"p1": book_id}) - - async def get_author(self, *, author_id: int) -> Optional[models.Author]: - row = (await self._conn.execute(sqlalchemy.text(GET_AUTHOR), {"p1": author_id})).first() - if row is None: - return None - return models.Author( - author_id=row[0], - name=row[1], - ) - - async def get_book(self, *, book_id: int) -> Optional[models.Book]: - row = (await self._conn.execute(sqlalchemy.text(GET_BOOK), {"p1": book_id})).first() - if row is None: - return None - return models.Book( - book_id=row[0], - author_id=row[1], - isbn=row[2], - book_type=row[3], - title=row[4], - year=row[5], - available=row[6], - tags=row[7], - ) - - async def update_book(self, *, title: str, tags: List[str], book_id: int) -> None: - await self._conn.execute(sqlalchemy.text(UPDATE_BOOK), {"p1": title, "p2": tags, "p3": book_id}) - - async def update_book_isbn(self, *, title: str, tags: List[str], book_id: int, isbn: str) -> None: - await self._conn.execute(sqlalchemy.text(UPDATE_BOOK_ISBN), { - "p1": title, - "p2": tags, - "p3": book_id, - "p4": isbn, - }) diff --git a/examples/python/src/dbtest/__init__.py b/examples/python/src/dbtest/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/python/src/dbtest/migrations.py b/examples/python/src/dbtest/migrations.py deleted file mode 100644 index 6ace6bcd63..0000000000 --- a/examples/python/src/dbtest/migrations.py +++ /dev/null @@ -1,43 +0,0 @@ -import os -from typing import List - -import sqlalchemy -import sqlalchemy.ext.asyncio - - -def apply_migrations(conn: sqlalchemy.engine.Connection, paths: List[str]): - files = _find_sql_files(paths) - - for file in files: - with open(file, "r") as fd: - blob = fd.read() - stmts = blob.split(";") - for stmt in stmts: - if stmt.strip(): - conn.execute(sqlalchemy.text(stmt)) - - -async def apply_migrations_async(conn: sqlalchemy.ext.asyncio.AsyncConnection, paths: List[str]): - files = _find_sql_files(paths) - - for file in files: - with open(file, "r") as fd: - blob = fd.read() - raw_conn = await conn.get_raw_connection() - # The asyncpg sqlalchemy adapter uses a prepared statement cache which can't handle the migration statements - await raw_conn._connection.execute(blob) - - -def _find_sql_files(paths: List[str]) -> List[str]: - files = [] - for path in paths: - if not os.path.exists(path): - raise FileNotFoundError(f"{path} does not exist") - if os.path.isdir(path): - for file in os.listdir(path): - if file.endswith(".sql"): - files.append(os.path.join(path, file)) - else: - files.append(path) - files.sort() - return files diff --git a/examples/python/src/jets/__init__.py b/examples/python/src/jets/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/python/src/jets/models.py b/examples/python/src/jets/models.py deleted file mode 100644 index 7d3063aba2..0000000000 --- a/examples/python/src/jets/models.py +++ /dev/null @@ -1,31 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -import dataclasses - - -@dataclasses.dataclass() -class Jet: - id: int - pilot_id: int - age: int - name: str - color: str - - -@dataclasses.dataclass() -class Language: - id: int - language: str - - -@dataclasses.dataclass() -class Pilot: - id: int - name: str - - -@dataclasses.dataclass() -class PilotLanguage: - pilot_id: int - language_id: int diff --git a/examples/python/src/jets/query-building.py b/examples/python/src/jets/query-building.py deleted file mode 100644 index 6fe42dfaa7..0000000000 --- a/examples/python/src/jets/query-building.py +++ /dev/null @@ -1,47 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -# source: query-building.sql -from typing import AsyncIterator, Optional - -import sqlalchemy -import sqlalchemy.ext.asyncio - -from jets import models - - -COUNT_PILOTS = """-- name: count_pilots \\:one -SELECT COUNT(*) FROM pilots -""" - - -DELETE_PILOT = """-- name: delete_pilot \\:exec -DELETE FROM pilots WHERE id = :p1 -""" - - -LIST_PILOTS = """-- name: list_pilots \\:many -SELECT id, name FROM pilots LIMIT 5 -""" - - -class AsyncQuerier: - def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): - self._conn = conn - - async def count_pilots(self) -> Optional[int]: - row = (await self._conn.execute(sqlalchemy.text(COUNT_PILOTS))).first() - if row is None: - return None - return row[0] - - async def delete_pilot(self, *, id: int) -> None: - await self._conn.execute(sqlalchemy.text(DELETE_PILOT), {"p1": id}) - - async def list_pilots(self) -> AsyncIterator[models.Pilot]: - result = await self._conn.stream(sqlalchemy.text(LIST_PILOTS)) - async for row in result: - yield models.Pilot( - id=row[0], - name=row[1], - ) diff --git a/examples/python/src/ondeck/__init__.py b/examples/python/src/ondeck/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/python/src/ondeck/city.py b/examples/python/src/ondeck/city.py deleted file mode 100644 index e32873eeb6..0000000000 --- a/examples/python/src/ondeck/city.py +++ /dev/null @@ -1,76 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -# source: city.sql -from typing import AsyncIterator, Optional - -import sqlalchemy -import sqlalchemy.ext.asyncio - -from ondeck import models - - -CREATE_CITY = """-- name: create_city \\:one -INSERT INTO city ( - name, - slug -) VALUES ( - :p1, - :p2 -) RETURNING slug, name -""" - - -GET_CITY = """-- name: get_city \\:one -SELECT slug, name -FROM city -WHERE slug = :p1 -""" - - -LIST_CITIES = """-- name: list_cities \\:many -SELECT slug, name -FROM city -ORDER BY name -""" - - -UPDATE_CITY_NAME = """-- name: update_city_name \\:exec -UPDATE city -SET name = :p2 -WHERE slug = :p1 -""" - - -class AsyncQuerier: - def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): - self._conn = conn - - async def create_city(self, *, name: str, slug: str) -> Optional[models.City]: - row = (await self._conn.execute(sqlalchemy.text(CREATE_CITY), {"p1": name, "p2": slug})).first() - if row is None: - return None - return models.City( - slug=row[0], - name=row[1], - ) - - async def get_city(self, *, slug: str) -> Optional[models.City]: - row = (await self._conn.execute(sqlalchemy.text(GET_CITY), {"p1": slug})).first() - if row is None: - return None - return models.City( - slug=row[0], - name=row[1], - ) - - async def list_cities(self) -> AsyncIterator[models.City]: - result = await self._conn.stream(sqlalchemy.text(LIST_CITIES)) - async for row in result: - yield models.City( - slug=row[0], - name=row[1], - ) - - async def update_city_name(self, *, slug: str, name: str) -> None: - await self._conn.execute(sqlalchemy.text(UPDATE_CITY_NAME), {"p1": slug, "p2": name}) diff --git a/examples/python/src/ondeck/models.py b/examples/python/src/ondeck/models.py deleted file mode 100644 index 71c98c14ab..0000000000 --- a/examples/python/src/ondeck/models.py +++ /dev/null @@ -1,35 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -import dataclasses -import datetime -import enum -from typing import List, Optional - - -class Status(str, enum.Enum): - """Venues can be either open or closed""" - OPEN = "op!en" - CLOSED = "clo@sed" - - -@dataclasses.dataclass() -class City: - slug: str - name: str - - -@dataclasses.dataclass() -class Venue: - """Venues are places where muisc happens""" - id: int - status: Status - statuses: Optional[List[Status]] - # This value appears in public URLs - slug: str - name: str - city: str - spotify_playlist: str - songkick_id: Optional[str] - tags: Optional[List[str]] - created_at: datetime.datetime diff --git a/examples/python/src/ondeck/venue.py b/examples/python/src/ondeck/venue.py deleted file mode 100644 index 88e4a56467..0000000000 --- a/examples/python/src/ondeck/venue.py +++ /dev/null @@ -1,159 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -# source: venue.sql -import dataclasses -from typing import AsyncIterator, List, Optional - -import sqlalchemy -import sqlalchemy.ext.asyncio - -from ondeck import models - - -CREATE_VENUE = """-- name: create_venue \\:one -INSERT INTO venue ( - slug, - name, - city, - created_at, - spotify_playlist, - status, - statuses, - tags -) VALUES ( - :p1, - :p2, - :p3, - NOW(), - :p4, - :p5, - :p6, - :p7 -) RETURNING id -""" - - -@dataclasses.dataclass() -class CreateVenueParams: - slug: str - name: str - city: str - spotify_playlist: str - status: models.Status - statuses: Optional[List[models.Status]] - tags: Optional[List[str]] - - -DELETE_VENUE = """-- name: delete_venue \\:exec -DELETE FROM venue -WHERE slug = :p1 AND slug = :p1 -""" - - -GET_VENUE = """-- name: get_venue \\:one -SELECT id, status, statuses, slug, name, city, spotify_playlist, songkick_id, tags, created_at -FROM venue -WHERE slug = :p1 AND city = :p2 -""" - - -LIST_VENUES = """-- name: list_venues \\:many -SELECT id, status, statuses, slug, name, city, spotify_playlist, songkick_id, tags, created_at -FROM venue -WHERE city = :p1 -ORDER BY name -""" - - -UPDATE_VENUE_NAME = """-- name: update_venue_name \\:one -UPDATE venue -SET name = :p2 -WHERE slug = :p1 -RETURNING id -""" - - -VENUE_COUNT_BY_CITY = """-- name: venue_count_by_city \\:many -SELECT - city, - count(*) -FROM venue -GROUP BY 1 -ORDER BY 1 -""" - - -@dataclasses.dataclass() -class VenueCountByCityRow: - city: str - count: int - - -class AsyncQuerier: - def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): - self._conn = conn - - async def create_venue(self, arg: CreateVenueParams) -> Optional[int]: - row = (await self._conn.execute(sqlalchemy.text(CREATE_VENUE), { - "p1": arg.slug, - "p2": arg.name, - "p3": arg.city, - "p4": arg.spotify_playlist, - "p5": arg.status, - "p6": arg.statuses, - "p7": arg.tags, - })).first() - if row is None: - return None - return row[0] - - async def delete_venue(self, *, slug: str) -> None: - await self._conn.execute(sqlalchemy.text(DELETE_VENUE), {"p1": slug}) - - async def get_venue(self, *, slug: str, city: str) -> Optional[models.Venue]: - row = (await self._conn.execute(sqlalchemy.text(GET_VENUE), {"p1": slug, "p2": city})).first() - if row is None: - return None - return models.Venue( - id=row[0], - status=row[1], - statuses=row[2], - slug=row[3], - name=row[4], - city=row[5], - spotify_playlist=row[6], - songkick_id=row[7], - tags=row[8], - created_at=row[9], - ) - - async def list_venues(self, *, city: str) -> AsyncIterator[models.Venue]: - result = await self._conn.stream(sqlalchemy.text(LIST_VENUES), {"p1": city}) - async for row in result: - yield models.Venue( - id=row[0], - status=row[1], - statuses=row[2], - slug=row[3], - name=row[4], - city=row[5], - spotify_playlist=row[6], - songkick_id=row[7], - tags=row[8], - created_at=row[9], - ) - - async def update_venue_name(self, *, slug: str, name: str) -> Optional[int]: - row = (await self._conn.execute(sqlalchemy.text(UPDATE_VENUE_NAME), {"p1": slug, "p2": name})).first() - if row is None: - return None - return row[0] - - async def venue_count_by_city(self) -> AsyncIterator[VenueCountByCityRow]: - result = await self._conn.stream(sqlalchemy.text(VENUE_COUNT_BY_CITY)) - async for row in result: - yield VenueCountByCityRow( - city=row[0], - count=row[1], - ) diff --git a/examples/python/src/tests/__init__.py b/examples/python/src/tests/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/python/src/tests/conftest.py b/examples/python/src/tests/conftest.py deleted file mode 100644 index f807209229..0000000000 --- a/examples/python/src/tests/conftest.py +++ /dev/null @@ -1,67 +0,0 @@ -import asyncio -import os -import random - -import pytest -import sqlalchemy -import sqlalchemy.ext.asyncio - - -@pytest.fixture(scope="session") -def postgres_uri() -> str: - pg_host = os.environ.get("PG_HOST", "postgres") - pg_port = os.environ.get("PG_PORT", 5432) - pg_user = os.environ.get("PG_USER", "postgres") - pg_password = os.environ.get("PG_PASSWORD", "mysecretpassword") - pg_db = os.environ.get("PG_DATABASE", "dinotest") - - return f"postgresql://{pg_user}:{pg_password}@{pg_host}:{pg_port}/{pg_db}" - - -@pytest.fixture(scope="session") -def sqlalchemy_connection(postgres_uri) -> sqlalchemy.engine.Connection: - engine = sqlalchemy.create_engine(postgres_uri, future=True) - with engine.connect() as conn: - yield conn - - -@pytest.fixture(scope="function") -def db(sqlalchemy_connection: sqlalchemy.engine.Connection) -> sqlalchemy.engine.Connection: - conn = sqlalchemy_connection - schema_name = f"sqltest_{random.randint(0, 1000)}" - conn.execute(sqlalchemy.text(f"CREATE SCHEMA {schema_name}")) - conn.execute(sqlalchemy.text(f"SET search_path TO {schema_name}")) - conn.commit() - yield conn - conn.rollback() - conn.execute(sqlalchemy.text(f"DROP SCHEMA {schema_name} CASCADE")) - conn.execute(sqlalchemy.text("SET search_path TO public")) - - -@pytest.fixture(scope="session") -async def async_sqlalchemy_connection(postgres_uri) -> sqlalchemy.ext.asyncio.AsyncConnection: - postgres_uri = postgres_uri.replace("postgresql", "postgresql+asyncpg") - engine = sqlalchemy.ext.asyncio.create_async_engine(postgres_uri) - async with engine.connect() as conn: - yield conn - - -@pytest.fixture(scope="function") -async def async_db(async_sqlalchemy_connection: sqlalchemy.ext.asyncio.AsyncConnection) -> sqlalchemy.ext.asyncio.AsyncConnection: - conn = async_sqlalchemy_connection - schema_name = f"sqltest_{random.randint(0, 1000)}" - await conn.execute(sqlalchemy.text(f"CREATE SCHEMA {schema_name}")) - await conn.execute(sqlalchemy.text(f"SET search_path TO {schema_name}")) - await conn.commit() - yield conn - await conn.rollback() - await conn.execute(sqlalchemy.text(f"DROP SCHEMA {schema_name} CASCADE")) - await conn.execute(sqlalchemy.text("SET search_path TO public")) - - -@pytest.fixture(scope="session") -def event_loop(): - """Change event_loop fixture to session level.""" - loop = asyncio.get_event_loop_policy().new_event_loop() - yield loop - loop.close() diff --git a/examples/python/src/tests/test_authors.py b/examples/python/src/tests/test_authors.py deleted file mode 100644 index 7b0a954276..0000000000 --- a/examples/python/src/tests/test_authors.py +++ /dev/null @@ -1,56 +0,0 @@ -import os - -import pytest -import sqlalchemy.ext.asyncio - -from authors import query -from dbtest.migrations import apply_migrations, apply_migrations_async - - -def test_authors(db: sqlalchemy.engine.Connection): - apply_migrations(db, [os.path.dirname(__file__) + "/../../../authors/postgresql/schema.sql"]) - - querier = query.Querier(db) - - authors = list(querier.list_authors()) - assert authors == [] - - author_name = "Brian Kernighan" - author_bio = "Co-author of The C Programming Language and The Go Programming Language" - new_author = querier.create_author(name=author_name, bio=author_bio) - assert new_author.id > 0 - assert new_author.name == author_name - assert new_author.bio == author_bio - - db_author = querier.get_author(id=new_author.id) - assert db_author == new_author - - author_list = list(querier.list_authors()) - assert len(author_list) == 1 - assert author_list[0] == new_author - - -@pytest.mark.asyncio -async def test_authors_async(async_db: sqlalchemy.ext.asyncio.AsyncConnection): - await apply_migrations_async(async_db, [os.path.dirname(__file__) + "/../../../authors/postgresql/schema.sql"]) - - querier = query.AsyncQuerier(async_db) - - async for _ in querier.list_authors(): - assert False, "No authors should exist" - - author_name = "Brian Kernighan" - author_bio = "Co-author of The C Programming Language and The Go Programming Language" - new_author = await querier.create_author(name=author_name, bio=author_bio) - assert new_author.id > 0 - assert new_author.name == author_name - assert new_author.bio == author_bio - - db_author = await querier.get_author(id=new_author.id) - assert db_author == new_author - - author_list = [] - async for author in querier.list_authors(): - author_list.append(author) - assert len(author_list) == 1 - assert author_list[0] == new_author diff --git a/examples/python/src/tests/test_booktest.py b/examples/python/src/tests/test_booktest.py deleted file mode 100644 index 6106d9d3fd..0000000000 --- a/examples/python/src/tests/test_booktest.py +++ /dev/null @@ -1,85 +0,0 @@ -import datetime -import os - -import pytest -import sqlalchemy.ext.asyncio - -from booktest import query, models -from dbtest.migrations import apply_migrations_async - - -@pytest.mark.asyncio -async def test_books(async_db: sqlalchemy.ext.asyncio.AsyncConnection): - await apply_migrations_async(async_db, [os.path.dirname(__file__) + "/../../../booktest/postgresql/schema.sql"]) - - querier = query.AsyncQuerier(async_db) - - author = await querier.create_author(name="Unknown Master") - assert author is not None - - now = datetime.datetime.now() - await querier.create_book(query.CreateBookParams( - author_id=author.author_id, - isbn="1", - title="my book title", - book_type=models.BookType.FICTION, - year=2016, - available=now, - tags=[], - )) - - b1 = await querier.create_book(query.CreateBookParams( - author_id=author.author_id, - isbn="2", - title="the second book", - book_type=models.BookType.FICTION, - year=2016, - available=now, - tags=["cool", "unique"], - )) - - await querier.update_book(book_id=b1.book_id, title="changed second title", tags=["cool", "disastor"]) - - b3 = await querier.create_book(query.CreateBookParams( - author_id=author.author_id, - isbn="3", - title="the third book", - book_type=models.BookType.FICTION, - year=2001, - available=now, - tags=["cool"], - )) - - b4 = await querier.create_book(query.CreateBookParams( - author_id=author.author_id, - isbn="4", - title="4th place finisher", - book_type=models.BookType.NONFICTION, - year=2011, - available=now, - tags=["other"], - )) - - await querier.update_book_isbn(book_id=b4.book_id, isbn="NEW ISBN", title="never ever gonna finish, a quatrain", tags=["someother"]) - - books0 = querier.books_by_title_year(title="my book title", year=2016) - expected_titles = {"my book title"} - async for book in books0: - expected_titles.remove(book.title) # raises a key error if the title does not exist - assert len(book.tags) == 0 - - author = await querier.get_author(author_id=book.author_id) - assert author.name == "Unknown Master" - assert len(expected_titles) == 0 - - books = querier.books_by_tags(dollar_1=["cool", "other", "someother"]) - expected_titles = {"changed second title", "the third book", "never ever gonna finish, a quatrain"} - async for book in books: - expected_titles.remove(book.title) - assert len(expected_titles) == 0 - - b5 = await querier.get_book(book_id=b3.book_id) - assert b5 is not None - await querier.delete_book(book_id=b5.book_id) - b6 = await querier.get_book(book_id=b5.book_id) - assert b6 is None diff --git a/examples/python/src/tests/test_ondeck.py b/examples/python/src/tests/test_ondeck.py deleted file mode 100644 index 68cfbc9bcb..0000000000 --- a/examples/python/src/tests/test_ondeck.py +++ /dev/null @@ -1,53 +0,0 @@ -import os - -import pytest -import sqlalchemy.ext.asyncio - -from ondeck import models -from ondeck import city as city_queries -from ondeck import venue as venue_queries -from dbtest.migrations import apply_migrations_async - - -@pytest.mark.asyncio -async def test_ondeck(async_db: sqlalchemy.ext.asyncio.AsyncConnection): - await apply_migrations_async(async_db, [os.path.dirname(__file__) + "/../../../ondeck/postgresql/schema"]) - - city_querier = city_queries.AsyncQuerier(async_db) - venue_querier = venue_queries.AsyncQuerier(async_db) - - city = await city_querier.create_city(slug="san-francisco", name="San Francisco") - assert city is not None - - venue_id = await venue_querier.create_venue(venue_queries.CreateVenueParams( - slug="the-fillmore", - name="The Fillmore", - city=city.slug, - spotify_playlist="spotify:uri", - status=models.Status.OPEN, - statuses=[models.Status.OPEN, models.Status.CLOSED], - tags=["rock", "punk"], - )) - assert venue_id is not None - - venue = await venue_querier.get_venue(slug="the-fillmore", city=city.slug) - assert venue is not None - assert venue.id == venue_id - - assert city == await city_querier.get_city(slug=city.slug) - assert [venue_queries.VenueCountByCityRow(city=city.slug, count=1)] == await _to_list(venue_querier.venue_count_by_city()) - assert [city] == await _to_list(city_querier.list_cities()) - assert [venue] == await _to_list(venue_querier.list_venues(city=city.slug)) - - await city_querier.update_city_name(slug=city.slug, name="SF") - _id = await venue_querier.update_venue_name(slug=venue.slug, name="Fillmore") - assert _id == venue_id - - await venue_querier.delete_venue(slug=venue.slug) - - -async def _to_list(it): - out = [] - async for i in it: - out.append(i) - return out From b9d22b78516288e9f275fe6ff0495624dc81716d Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Thu, 2 Nov 2023 16:57:30 -0700 Subject: [PATCH 5/5] test: Remove all python tests They've been ported to the Python repository --- .../postgresql/__init__.py | 0 .../emit_pydantic_models/postgresql/models.py | 11 -- .../emit_pydantic_models/postgresql/query.py | 112 ------------------ .../emit_pydantic_models/postgresql/query.sql | 19 --- .../postgresql/schema.sql | 5 - .../testdata/emit_pydantic_models/sqlc.json | 31 ----- .../python_postgresql/python/models.py | 9 -- .../python_postgresql/python/query.py | 29 ----- .../exec_result/python_postgresql/query.sql | 2 - .../exec_result/python_postgresql/schema.sql | 2 - .../exec_result/python_postgresql/sqlc.json | 30 ----- .../python_postgresql/python/models.py | 9 -- .../python_postgresql/python/query.py | 31 ----- .../exec_rows/python_postgresql/query.sql | 2 - .../exec_rows/python_postgresql/schema.sql | 2 - .../exec_rows/python_postgresql/sqlc.json | 30 ----- .../python_postgresql/python/models.py | 22 ---- .../python_postgresql/python/query.py | 89 -------------- .../python_postgresql/query.sql | 8 -- .../python_postgresql/schema.sql | 4 - .../python_postgresql/sqlc.json | 34 ------ .../-1/python_postgresql/query.sql | 5 - .../-1/python_postgresql/schema.sql | 1 - .../-1/python_postgresql/sqlc.json | 31 ----- .../-1/python_postgresql/stderr.txt | 2 - .../0/python_postgresql/python/models.py | 10 -- .../0/python_postgresql/python/query.py | 57 --------- .../0/python_postgresql/query.sql | 5 - .../0/python_postgresql/schema.sql | 2 - .../0/python_postgresql/sqlc.json | 31 ----- .../2/python_postgresql/python/models.py | 10 -- .../2/python_postgresql/python/query.py | 44 ------- .../2/python_postgresql/query.sql | 5 - .../2/python_postgresql/schema.sql | 2 - .../2/python_postgresql/sqlc.json | 31 ----- .../python_postgresql/python/models.py | 12 -- .../python_postgresql/python/query.py | 58 --------- .../undefined/python_postgresql/query.sql | 10 -- .../undefined/python_postgresql/schema.sql | 7 -- .../undefined/python_postgresql/sqlc.json | 30 ----- 40 files changed, 834 deletions(-) delete mode 100644 internal/endtoend/testdata/emit_pydantic_models/postgresql/__init__.py delete mode 100644 internal/endtoend/testdata/emit_pydantic_models/postgresql/models.py delete mode 100644 internal/endtoend/testdata/emit_pydantic_models/postgresql/query.py delete mode 100644 internal/endtoend/testdata/emit_pydantic_models/postgresql/query.sql delete mode 100644 internal/endtoend/testdata/emit_pydantic_models/postgresql/schema.sql delete mode 100644 internal/endtoend/testdata/emit_pydantic_models/sqlc.json delete mode 100644 internal/endtoend/testdata/exec_result/python_postgresql/python/models.py delete mode 100644 internal/endtoend/testdata/exec_result/python_postgresql/python/query.py delete mode 100644 internal/endtoend/testdata/exec_result/python_postgresql/query.sql delete mode 100644 internal/endtoend/testdata/exec_result/python_postgresql/schema.sql delete mode 100644 internal/endtoend/testdata/exec_result/python_postgresql/sqlc.json delete mode 100644 internal/endtoend/testdata/exec_rows/python_postgresql/python/models.py delete mode 100644 internal/endtoend/testdata/exec_rows/python_postgresql/python/query.py delete mode 100644 internal/endtoend/testdata/exec_rows/python_postgresql/query.sql delete mode 100644 internal/endtoend/testdata/exec_rows/python_postgresql/schema.sql delete mode 100644 internal/endtoend/testdata/exec_rows/python_postgresql/sqlc.json delete mode 100644 internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/python/models.py delete mode 100644 internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/python/query.py delete mode 100644 internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/query.sql delete mode 100644 internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/schema.sql delete mode 100644 internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/sqlc.json delete mode 100644 internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/query.sql delete mode 100644 internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/schema.sql delete mode 100644 internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/sqlc.json delete mode 100644 internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/stderr.txt delete mode 100644 internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/python/models.py delete mode 100644 internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/python/query.py delete mode 100644 internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/query.sql delete mode 100644 internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/schema.sql delete mode 100644 internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/sqlc.json delete mode 100644 internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/python/models.py delete mode 100644 internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/python/query.py delete mode 100644 internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/query.sql delete mode 100644 internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/schema.sql delete mode 100644 internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/sqlc.json delete mode 100644 internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/python/models.py delete mode 100644 internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/python/query.py delete mode 100644 internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/query.sql delete mode 100644 internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/schema.sql delete mode 100644 internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/sqlc.json diff --git a/internal/endtoend/testdata/emit_pydantic_models/postgresql/__init__.py b/internal/endtoend/testdata/emit_pydantic_models/postgresql/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/internal/endtoend/testdata/emit_pydantic_models/postgresql/models.py b/internal/endtoend/testdata/emit_pydantic_models/postgresql/models.py deleted file mode 100644 index 7ac0da3afe..0000000000 --- a/internal/endtoend/testdata/emit_pydantic_models/postgresql/models.py +++ /dev/null @@ -1,11 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -import pydantic -from typing import Optional - - -class Author(pydantic.BaseModel): - id: int - name: str - bio: Optional[str] diff --git a/internal/endtoend/testdata/emit_pydantic_models/postgresql/query.py b/internal/endtoend/testdata/emit_pydantic_models/postgresql/query.py deleted file mode 100644 index be41e04650..0000000000 --- a/internal/endtoend/testdata/emit_pydantic_models/postgresql/query.py +++ /dev/null @@ -1,112 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -# source: query.sql -from typing import AsyncIterator, Iterator, Optional - -import sqlalchemy -import sqlalchemy.ext.asyncio - -from postgresql import models - - -CREATE_AUTHOR = """-- name: create_author \\:one -INSERT INTO authors ( - name, bio -) VALUES ( - :p1, :p2 -) -RETURNING id, name, bio -""" - - -DELETE_AUTHOR = """-- name: delete_author \\:exec -DELETE FROM authors -WHERE id = :p1 -""" - - -GET_AUTHOR = """-- name: get_author \\:one -SELECT id, name, bio FROM authors -WHERE id = :p1 LIMIT 1 -""" - - -LIST_AUTHORS = """-- name: list_authors \\:many -SELECT id, name, bio FROM authors -ORDER BY name -""" - - -class Querier: - def __init__(self, conn: sqlalchemy.engine.Connection): - self._conn = conn - - def create_author(self, *, name: str, bio: Optional[str]) -> Optional[models.Author]: - row = self._conn.execute(sqlalchemy.text(CREATE_AUTHOR), {"p1": name, "p2": bio}).first() - if row is None: - return None - return models.Author( - id=row[0], - name=row[1], - bio=row[2], - ) - - def delete_author(self, *, id: int) -> None: - self._conn.execute(sqlalchemy.text(DELETE_AUTHOR), {"p1": id}) - - def get_author(self, *, id: int) -> Optional[models.Author]: - row = self._conn.execute(sqlalchemy.text(GET_AUTHOR), {"p1": id}).first() - if row is None: - return None - return models.Author( - id=row[0], - name=row[1], - bio=row[2], - ) - - def list_authors(self) -> Iterator[models.Author]: - result = self._conn.execute(sqlalchemy.text(LIST_AUTHORS)) - for row in result: - yield models.Author( - id=row[0], - name=row[1], - bio=row[2], - ) - - -class AsyncQuerier: - def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): - self._conn = conn - - async def create_author(self, *, name: str, bio: Optional[str]) -> Optional[models.Author]: - row = (await self._conn.execute(sqlalchemy.text(CREATE_AUTHOR), {"p1": name, "p2": bio})).first() - if row is None: - return None - return models.Author( - id=row[0], - name=row[1], - bio=row[2], - ) - - async def delete_author(self, *, id: int) -> None: - await self._conn.execute(sqlalchemy.text(DELETE_AUTHOR), {"p1": id}) - - async def get_author(self, *, id: int) -> Optional[models.Author]: - row = (await self._conn.execute(sqlalchemy.text(GET_AUTHOR), {"p1": id})).first() - if row is None: - return None - return models.Author( - id=row[0], - name=row[1], - bio=row[2], - ) - - async def list_authors(self) -> AsyncIterator[models.Author]: - result = await self._conn.stream(sqlalchemy.text(LIST_AUTHORS)) - async for row in result: - yield models.Author( - id=row[0], - name=row[1], - bio=row[2], - ) diff --git a/internal/endtoend/testdata/emit_pydantic_models/postgresql/query.sql b/internal/endtoend/testdata/emit_pydantic_models/postgresql/query.sql deleted file mode 100644 index 75e38b2caf..0000000000 --- a/internal/endtoend/testdata/emit_pydantic_models/postgresql/query.sql +++ /dev/null @@ -1,19 +0,0 @@ --- name: GetAuthor :one -SELECT * FROM authors -WHERE id = $1 LIMIT 1; - --- name: ListAuthors :many -SELECT * FROM authors -ORDER BY name; - --- name: CreateAuthor :one -INSERT INTO authors ( - name, bio -) VALUES ( - $1, $2 -) -RETURNING *; - --- name: DeleteAuthor :exec -DELETE FROM authors -WHERE id = $1; diff --git a/internal/endtoend/testdata/emit_pydantic_models/postgresql/schema.sql b/internal/endtoend/testdata/emit_pydantic_models/postgresql/schema.sql deleted file mode 100644 index b4fad78497..0000000000 --- a/internal/endtoend/testdata/emit_pydantic_models/postgresql/schema.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE authors ( - id BIGSERIAL PRIMARY KEY, - name text NOT NULL, - bio text -); diff --git a/internal/endtoend/testdata/emit_pydantic_models/sqlc.json b/internal/endtoend/testdata/emit_pydantic_models/sqlc.json deleted file mode 100644 index 65ca70df70..0000000000 --- a/internal/endtoend/testdata/emit_pydantic_models/sqlc.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "version": "2", - "plugins": [ - { - "name": "py", - "wasm": { - "url": "https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.1.0.wasm", - "sha256": "ef58f143a8c116781091441770c7166caaf361dd645f62b8f05f462e9f95c3b2" - } - } - ], - "sql": [ - { - "schema": "postgresql/schema.sql", - "queries": "postgresql/query.sql", - "engine": "postgresql", - "codegen": [ - { - "plugin": "py", - "out": "postgresql", - "options": { - "package": "postgresql", - "emit_sync_querier": true, - "emit_async_querier": true, - "emit_pydantic_models": true - } - } - ] - } - ] -} diff --git a/internal/endtoend/testdata/exec_result/python_postgresql/python/models.py b/internal/endtoend/testdata/exec_result/python_postgresql/python/models.py deleted file mode 100644 index d2293ed70c..0000000000 --- a/internal/endtoend/testdata/exec_result/python_postgresql/python/models.py +++ /dev/null @@ -1,9 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -import dataclasses - - -@dataclasses.dataclass() -class Bar: - id: int diff --git a/internal/endtoend/testdata/exec_result/python_postgresql/python/query.py b/internal/endtoend/testdata/exec_result/python_postgresql/python/query.py deleted file mode 100644 index ceccd51027..0000000000 --- a/internal/endtoend/testdata/exec_result/python_postgresql/python/query.py +++ /dev/null @@ -1,29 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -# source: query.sql -import sqlalchemy -import sqlalchemy.ext.asyncio - -from querytest import models - - -DELETE_BAR_BY_ID = """-- name: delete_bar_by_id \\:execresult -DELETE FROM bar WHERE id = :p1 -""" - - -class Querier: - def __init__(self, conn: sqlalchemy.engine.Connection): - self._conn = conn - - def delete_bar_by_id(self, *, id: int) -> sqlalchemy.engine.Result: - return self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID), {"p1": id}) - - -class AsyncQuerier: - def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): - self._conn = conn - - async def delete_bar_by_id(self, *, id: int) -> sqlalchemy.engine.Result: - return await self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID), {"p1": id}) diff --git a/internal/endtoend/testdata/exec_result/python_postgresql/query.sql b/internal/endtoend/testdata/exec_result/python_postgresql/query.sql deleted file mode 100644 index 73917782cb..0000000000 --- a/internal/endtoend/testdata/exec_result/python_postgresql/query.sql +++ /dev/null @@ -1,2 +0,0 @@ --- name: DeleteBarByID :execresult -DELETE FROM bar WHERE id = $1; diff --git a/internal/endtoend/testdata/exec_result/python_postgresql/schema.sql b/internal/endtoend/testdata/exec_result/python_postgresql/schema.sql deleted file mode 100644 index 638370ab15..0000000000 --- a/internal/endtoend/testdata/exec_result/python_postgresql/schema.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE TABLE bar (id serial not null); - diff --git a/internal/endtoend/testdata/exec_result/python_postgresql/sqlc.json b/internal/endtoend/testdata/exec_result/python_postgresql/sqlc.json deleted file mode 100644 index 5eae79b795..0000000000 --- a/internal/endtoend/testdata/exec_result/python_postgresql/sqlc.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "version": "2", - "plugins": [ - { - "name": "py", - "wasm": { - "url": "https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.1.0.wasm", - "sha256": "ef58f143a8c116781091441770c7166caaf361dd645f62b8f05f462e9f95c3b2" - } - } - ], - "sql": [ - { - "schema": "schema.sql", - "queries": "query.sql", - "engine": "postgresql", - "codegen": [ - { - "plugin": "py", - "out": "python", - "options": { - "package": "querytest", - "emit_sync_querier": true, - "emit_async_querier": true - } - } - ] - } - ] -} diff --git a/internal/endtoend/testdata/exec_rows/python_postgresql/python/models.py b/internal/endtoend/testdata/exec_rows/python_postgresql/python/models.py deleted file mode 100644 index d2293ed70c..0000000000 --- a/internal/endtoend/testdata/exec_rows/python_postgresql/python/models.py +++ /dev/null @@ -1,9 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -import dataclasses - - -@dataclasses.dataclass() -class Bar: - id: int diff --git a/internal/endtoend/testdata/exec_rows/python_postgresql/python/query.py b/internal/endtoend/testdata/exec_rows/python_postgresql/python/query.py deleted file mode 100644 index 904f42836c..0000000000 --- a/internal/endtoend/testdata/exec_rows/python_postgresql/python/query.py +++ /dev/null @@ -1,31 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -# source: query.sql -import sqlalchemy -import sqlalchemy.ext.asyncio - -from querytest import models - - -DELETE_BAR_BY_ID = """-- name: delete_bar_by_id \\:execrows -DELETE FROM bar WHERE id = :p1 -""" - - -class Querier: - def __init__(self, conn: sqlalchemy.engine.Connection): - self._conn = conn - - def delete_bar_by_id(self, *, id: int) -> int: - result = self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID), {"p1": id}) - return result.rowcount - - -class AsyncQuerier: - def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): - self._conn = conn - - async def delete_bar_by_id(self, *, id: int) -> int: - result = await self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID), {"p1": id}) - return result.rowcount diff --git a/internal/endtoend/testdata/exec_rows/python_postgresql/query.sql b/internal/endtoend/testdata/exec_rows/python_postgresql/query.sql deleted file mode 100644 index 94d2d09f90..0000000000 --- a/internal/endtoend/testdata/exec_rows/python_postgresql/query.sql +++ /dev/null @@ -1,2 +0,0 @@ --- name: DeleteBarByID :execrows -DELETE FROM bar WHERE id = $1; diff --git a/internal/endtoend/testdata/exec_rows/python_postgresql/schema.sql b/internal/endtoend/testdata/exec_rows/python_postgresql/schema.sql deleted file mode 100644 index 638370ab15..0000000000 --- a/internal/endtoend/testdata/exec_rows/python_postgresql/schema.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE TABLE bar (id serial not null); - diff --git a/internal/endtoend/testdata/exec_rows/python_postgresql/sqlc.json b/internal/endtoend/testdata/exec_rows/python_postgresql/sqlc.json deleted file mode 100644 index 5eae79b795..0000000000 --- a/internal/endtoend/testdata/exec_rows/python_postgresql/sqlc.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "version": "2", - "plugins": [ - { - "name": "py", - "wasm": { - "url": "https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.1.0.wasm", - "sha256": "ef58f143a8c116781091441770c7166caaf361dd645f62b8f05f462e9f95c3b2" - } - } - ], - "sql": [ - { - "schema": "schema.sql", - "queries": "query.sql", - "engine": "postgresql", - "codegen": [ - { - "plugin": "py", - "out": "python", - "options": { - "package": "querytest", - "emit_sync_querier": true, - "emit_async_querier": true - } - } - ] - } - ] -} diff --git a/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/python/models.py b/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/python/models.py deleted file mode 100644 index b01f524b88..0000000000 --- a/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/python/models.py +++ /dev/null @@ -1,22 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -import dataclasses - - -@dataclasses.dataclass() -class Bar: - id: int - name: str - - -@dataclasses.dataclass() -class Exclusions: - id: int - name: str - - -@dataclasses.dataclass() -class MyData: - id: int - name: str diff --git a/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/python/query.py b/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/python/query.py deleted file mode 100644 index 100bef3789..0000000000 --- a/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/python/query.py +++ /dev/null @@ -1,89 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -# source: query.sql -from typing import Optional - -import sqlalchemy -import sqlalchemy.ext.asyncio - -from querytest import models - - -DELETE_BAR_BY_ID = """-- name: delete_bar_by_id \\:one -DELETE FROM bars WHERE id = :p1 RETURNING id, name -""" - - -DELETE_EXCLUSION_BY_ID = """-- name: delete_exclusion_by_id \\:one -DELETE FROM exclusions WHERE id = :p1 RETURNING id, name -""" - - -DELETE_MY_DATA_BY_ID = """-- name: delete_my_data_by_id \\:one -DELETE FROM my_data WHERE id = :p1 RETURNING id, name -""" - - -class Querier: - def __init__(self, conn: sqlalchemy.engine.Connection): - self._conn = conn - - def delete_bar_by_id(self, *, id: int) -> Optional[models.Bar]: - row = self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID), {"p1": id}).first() - if row is None: - return None - return models.Bar( - id=row[0], - name=row[1], - ) - - def delete_exclusion_by_id(self, *, id: int) -> Optional[models.Exclusions]: - row = self._conn.execute(sqlalchemy.text(DELETE_EXCLUSION_BY_ID), {"p1": id}).first() - if row is None: - return None - return models.Exclusions( - id=row[0], - name=row[1], - ) - - def delete_my_data_by_id(self, *, id: int) -> Optional[models.MyData]: - row = self._conn.execute(sqlalchemy.text(DELETE_MY_DATA_BY_ID), {"p1": id}).first() - if row is None: - return None - return models.MyData( - id=row[0], - name=row[1], - ) - - -class AsyncQuerier: - def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): - self._conn = conn - - async def delete_bar_by_id(self, *, id: int) -> Optional[models.Bar]: - row = (await self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID), {"p1": id})).first() - if row is None: - return None - return models.Bar( - id=row[0], - name=row[1], - ) - - async def delete_exclusion_by_id(self, *, id: int) -> Optional[models.Exclusions]: - row = (await self._conn.execute(sqlalchemy.text(DELETE_EXCLUSION_BY_ID), {"p1": id})).first() - if row is None: - return None - return models.Exclusions( - id=row[0], - name=row[1], - ) - - async def delete_my_data_by_id(self, *, id: int) -> Optional[models.MyData]: - row = (await self._conn.execute(sqlalchemy.text(DELETE_MY_DATA_BY_ID), {"p1": id})).first() - if row is None: - return None - return models.MyData( - id=row[0], - name=row[1], - ) diff --git a/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/query.sql b/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/query.sql deleted file mode 100644 index f279a10738..0000000000 --- a/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/query.sql +++ /dev/null @@ -1,8 +0,0 @@ --- name: DeleteBarByID :one -DELETE FROM bars WHERE id = $1 RETURNING id, name; - --- name: DeleteMyDataByID :one -DELETE FROM my_data WHERE id = $1 RETURNING id, name; - --- name: DeleteExclusionByID :one -DELETE FROM exclusions WHERE id = $1 RETURNING id, name; diff --git a/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/schema.sql b/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/schema.sql deleted file mode 100644 index ea5b797e08..0000000000 --- a/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/schema.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE bars (id serial not null, name text not null, primary key (id)); -CREATE TABLE my_data (id serial not null, name text not null, primary key (id)); -CREATE TABLE exclusions (id serial not null, name text not null, primary key (id)); - diff --git a/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/sqlc.json b/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/sqlc.json deleted file mode 100644 index 8a8691c3a5..0000000000 --- a/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/sqlc.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "version": "2", - "plugins": [ - { - "name": "py", - "wasm": { - "url": "https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.0.0.wasm", - "sha256": "aca83e1f59f8ffdc604774c2f6f9eb321a2b23e07dc83fc12289d25305fa065b" - } - } - ], - "sql": [ - { - "schema": "schema.sql", - "queries": "query.sql", - "engine": "postgresql", - "codegen": [ - { - "plugin": "py", - "out": "python", - "options": { - "package": "querytest", - "emit_sync_querier": true, - "emit_async_querier": true, - "inflection_exclude_table_names": [ - "my_data", - "exclusions" - ] - } - } - ] - } - ] -} diff --git a/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/query.sql b/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/query.sql deleted file mode 100644 index b96c66b9b3..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/query.sql +++ /dev/null @@ -1,5 +0,0 @@ --- name: DeleteBarByID :execrows -DELETE FROM bar WHERE id = $1; - --- name: DeleteBarByIDAndName :execrows -DELETE FROM bar WHERE id = $1 AND name = $2; diff --git a/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/schema.sql b/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/schema.sql deleted file mode 100644 index fd3ca97902..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/schema.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE TABLE bar (id serial not null, name text not null, primary key (id)); \ No newline at end of file diff --git a/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/sqlc.json b/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/sqlc.json deleted file mode 100644 index d431feabb5..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/sqlc.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "version": "2", - "plugins": [ - { - "name": "py", - "wasm": { - "url": "https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.1.0.wasm", - "sha256": "ef58f143a8c116781091441770c7166caaf361dd645f62b8f05f462e9f95c3b2" - } - } - ], - "sql": [ - { - "schema": "schema.sql", - "queries": "query.sql", - "engine": "postgresql", - "codegen": [ - { - "plugin": "py", - "out": "python", - "options": { - "package": "querytest", - "emit_sync_querier": true, - "emit_async_querier": true, - "query_parameter_limit": -1 - } - } - ] - } - ] -} diff --git a/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/stderr.txt b/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/stderr.txt deleted file mode 100644 index efed0cc10b..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/stderr.txt +++ /dev/null @@ -1,2 +0,0 @@ -# package py -error generating code: error generating output: invalid query parameter limit diff --git a/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/python/models.py b/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/python/models.py deleted file mode 100644 index 9bc595f2a0..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/python/models.py +++ /dev/null @@ -1,10 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -import dataclasses - - -@dataclasses.dataclass() -class Bar: - id: int - name: str diff --git a/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/python/query.py b/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/python/query.py deleted file mode 100644 index 2a4251704f..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/python/query.py +++ /dev/null @@ -1,57 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -# source: query.sql -import dataclasses - -import sqlalchemy -import sqlalchemy.ext.asyncio - -from querytest import models - - -DELETE_BAR_BY_ID = """-- name: delete_bar_by_id \\:execrows -DELETE FROM bar WHERE id = :p1 -""" - - -@dataclasses.dataclass() -class DeleteBarByIDParams: - id: int - - -DELETE_BAR_BY_ID_AND_NAME = """-- name: delete_bar_by_id_and_name \\:execrows -DELETE FROM bar WHERE id = :p1 AND name = :p2 -""" - - -@dataclasses.dataclass() -class DeleteBarByIDAndNameParams: - id: int - name: str - - -class Querier: - def __init__(self, conn: sqlalchemy.engine.Connection): - self._conn = conn - - def delete_bar_by_id(self, arg: DeleteBarByIDParams) -> int: - result = self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID), {"p1": arg.id}) - return result.rowcount - - def delete_bar_by_id_and_name(self, arg: DeleteBarByIDAndNameParams) -> int: - result = self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID_AND_NAME), {"p1": arg.id, "p2": arg.name}) - return result.rowcount - - -class AsyncQuerier: - def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): - self._conn = conn - - async def delete_bar_by_id(self, arg: DeleteBarByIDParams) -> int: - result = await self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID), {"p1": arg.id}) - return result.rowcount - - async def delete_bar_by_id_and_name(self, arg: DeleteBarByIDAndNameParams) -> int: - result = await self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID_AND_NAME), {"p1": arg.id, "p2": arg.name}) - return result.rowcount diff --git a/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/query.sql b/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/query.sql deleted file mode 100644 index b96c66b9b3..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/query.sql +++ /dev/null @@ -1,5 +0,0 @@ --- name: DeleteBarByID :execrows -DELETE FROM bar WHERE id = $1; - --- name: DeleteBarByIDAndName :execrows -DELETE FROM bar WHERE id = $1 AND name = $2; diff --git a/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/schema.sql b/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/schema.sql deleted file mode 100644 index a27c312e36..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/schema.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE TABLE bar (id serial not null, name text not null, primary key (id)); - diff --git a/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/sqlc.json b/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/sqlc.json deleted file mode 100644 index 2bda86ec51..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/sqlc.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "version": "2", - "plugins": [ - { - "name": "py", - "wasm": { - "url": "https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.1.0.wasm", - "sha256": "ef58f143a8c116781091441770c7166caaf361dd645f62b8f05f462e9f95c3b2" - } - } - ], - "sql": [ - { - "schema": "schema.sql", - "queries": "query.sql", - "engine": "postgresql", - "codegen": [ - { - "plugin": "py", - "out": "python", - "options": { - "package": "querytest", - "emit_sync_querier": true, - "emit_async_querier": true, - "query_parameter_limit": 0 - } - } - ] - } - ] -} diff --git a/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/python/models.py b/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/python/models.py deleted file mode 100644 index 9bc595f2a0..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/python/models.py +++ /dev/null @@ -1,10 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -import dataclasses - - -@dataclasses.dataclass() -class Bar: - id: int - name: str diff --git a/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/python/query.py b/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/python/query.py deleted file mode 100644 index 3ca9cba99f..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/python/query.py +++ /dev/null @@ -1,44 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -# source: query.sql -import sqlalchemy -import sqlalchemy.ext.asyncio - -from querytest import models - - -DELETE_BAR_BY_ID = """-- name: delete_bar_by_id \\:execrows -DELETE FROM bar WHERE id = :p1 -""" - - -DELETE_BAR_BY_ID_AND_NAME = """-- name: delete_bar_by_id_and_name \\:execrows -DELETE FROM bar WHERE id = :p1 AND name = :p2 -""" - - -class Querier: - def __init__(self, conn: sqlalchemy.engine.Connection): - self._conn = conn - - def delete_bar_by_id(self, *, id: int) -> int: - result = self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID), {"p1": id}) - return result.rowcount - - def delete_bar_by_id_and_name(self, *, id: int, name: str) -> int: - result = self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID_AND_NAME), {"p1": id, "p2": name}) - return result.rowcount - - -class AsyncQuerier: - def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): - self._conn = conn - - async def delete_bar_by_id(self, *, id: int) -> int: - result = await self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID), {"p1": id}) - return result.rowcount - - async def delete_bar_by_id_and_name(self, *, id: int, name: str) -> int: - result = await self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID_AND_NAME), {"p1": id, "p2": name}) - return result.rowcount diff --git a/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/query.sql b/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/query.sql deleted file mode 100644 index b96c66b9b3..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/query.sql +++ /dev/null @@ -1,5 +0,0 @@ --- name: DeleteBarByID :execrows -DELETE FROM bar WHERE id = $1; - --- name: DeleteBarByIDAndName :execrows -DELETE FROM bar WHERE id = $1 AND name = $2; diff --git a/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/schema.sql b/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/schema.sql deleted file mode 100644 index a27c312e36..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/schema.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE TABLE bar (id serial not null, name text not null, primary key (id)); - diff --git a/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/sqlc.json b/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/sqlc.json deleted file mode 100644 index a0c6fd8680..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/sqlc.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "version": "2", - "plugins": [ - { - "name": "py", - "wasm": { - "url": "https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.1.0.wasm", - "sha256": "ef58f143a8c116781091441770c7166caaf361dd645f62b8f05f462e9f95c3b2" - } - } - ], - "sql": [ - { - "schema": "schema.sql", - "queries": "query.sql", - "engine": "postgresql", - "codegen": [ - { - "plugin": "py", - "out": "python", - "options": { - "package": "querytest", - "emit_sync_querier": true, - "emit_async_querier": true, - "query_parameter_limit": 2 - } - } - ] - } - ] -} diff --git a/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/python/models.py b/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/python/models.py deleted file mode 100644 index 5e2f6558cf..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/python/models.py +++ /dev/null @@ -1,12 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -import dataclasses - - -@dataclasses.dataclass() -class Bar: - id: int - name1: str - name2: str - name3: str diff --git a/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/python/query.py b/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/python/query.py deleted file mode 100644 index 4dccfa9968..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/python/query.py +++ /dev/null @@ -1,58 +0,0 @@ -# Code generated by sqlc. DO NOT EDIT. -# versions: -# sqlc v1.23.0 -# source: query.sql -import sqlalchemy -import sqlalchemy.ext.asyncio - -from querytest import models - - -DELETE_BAR_BY_ID = """-- name: delete_bar_by_id \\:execrows -DELETE FROM bar WHERE id = :p1 -""" - - -DELETE_BAR_BY_ID_AND_NAME = """-- name: delete_bar_by_id_and_name \\:execrows -DELETE FROM bar -WHERE id = :p1 -AND name1 = :p2 -AND name2 = :p3 -AND name3 = :p4 -""" - - -class Querier: - def __init__(self, conn: sqlalchemy.engine.Connection): - self._conn = conn - - def delete_bar_by_id(self, *, id: int) -> int: - result = self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID), {"p1": id}) - return result.rowcount - - def delete_bar_by_id_and_name(self, *, id: int, name1: str, name2: str, name3: str) -> int: - result = self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID_AND_NAME), { - "p1": id, - "p2": name1, - "p3": name2, - "p4": name3, - }) - return result.rowcount - - -class AsyncQuerier: - def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): - self._conn = conn - - async def delete_bar_by_id(self, *, id: int) -> int: - result = await self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID), {"p1": id}) - return result.rowcount - - async def delete_bar_by_id_and_name(self, *, id: int, name1: str, name2: str, name3: str) -> int: - result = await self._conn.execute(sqlalchemy.text(DELETE_BAR_BY_ID_AND_NAME), { - "p1": id, - "p2": name1, - "p3": name2, - "p4": name3, - }) - return result.rowcount diff --git a/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/query.sql b/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/query.sql deleted file mode 100644 index aea85112e0..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/query.sql +++ /dev/null @@ -1,10 +0,0 @@ --- name: DeleteBarByID :execrows -DELETE FROM bar WHERE id = $1; - --- name: DeleteBarByIDAndName :execrows -DELETE FROM bar -WHERE id = $1 -AND name1 = $2 -AND name2 = $3 -AND name3 = $4 -; diff --git a/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/schema.sql b/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/schema.sql deleted file mode 100644 index 1d9131f472..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE bar ( - id serial not null, - name1 text not null, - name2 text not null, - name3 text not null, - primary key (id)); - diff --git a/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/sqlc.json b/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/sqlc.json deleted file mode 100644 index c20cad43af..0000000000 --- a/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/sqlc.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "version": "2", - "plugins": [ - { - "name": "py", - "wasm": { - "url": "https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.0.0.wasm", - "sha256": "aca83e1f59f8ffdc604774c2f6f9eb321a2b23e07dc83fc12289d25305fa065b" - } - } - ], - "sql": [ - { - "schema": "schema.sql", - "queries": "query.sql", - "engine": "postgresql", - "codegen": [ - { - "plugin": "py", - "out": "python", - "options": { - "package": "querytest", - "emit_sync_querier": true, - "emit_async_querier": true - } - } - ] - } - ] -}