diff --git a/.changes/unreleased/Fixed-duplicate-params.yaml b/.changes/unreleased/Fixed-duplicate-params.yaml new file mode 100644 index 0000000..899b0ea --- /dev/null +++ b/.changes/unreleased/Fixed-duplicate-params.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Queries mixing a positional reference with a same-named sqlc.arg() no longer generate a duplicate function parameter +time: 2026-06-09T00:00:01.0000000Z +custom: + Author: Mic92 + PR: "164" diff --git a/.changes/unreleased/Fixed-field-singularization.yaml b/.changes/unreleased/Fixed-field-singularization.yaml new file mode 100644 index 0000000..ce58317 --- /dev/null +++ b/.changes/unreleased/Fixed-field-singularization.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Column field names are no longer singularized (`outputs` generated an `output` field); duplicate selected columns get suffixed fields instead of an invalid class +time: 2026-06-09T00:00:00.0000000Z +custom: + Author: Mic92 + PR: "164" diff --git a/.changes/unreleased/Fixed-queryresults-sequence.yaml b/.changes/unreleased/Fixed-queryresults-sequence.yaml new file mode 100644 index 0000000..d6d6bbc --- /dev/null +++ b/.changes/unreleased/Fixed-queryresults-sequence.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: QueryResultsArgsType includes Sequence so array parameters of :many queries type-check +time: 2026-06-09T00:00:02.0000000Z +custom: + Author: Mic92 + PR: "164" diff --git a/internal/builders.go b/internal/builders.go index c091558..803644a 100644 --- a/internal/builders.go +++ b/internal/builders.go @@ -261,9 +261,19 @@ func (gen *PythonGenerator) buildQueries(tables []core.Table) ([]core.Query, err }} } else if len(query.Params) >= 1 { var values []core.QueryValue + // Positional ($n) and named (sqlc.arg) references + // can infer the same name; suffix duplicates to keep + // the function definition valid. + seenParams := map[string]int{} for _, p := range query.Params { + baseName := core.Escape(core.ParamName(p)) + name := baseName + if n := seenParams[baseName]; n > 0 { + name = fmt.Sprintf("%s_%d", baseName, n+1) + } + seenParams[baseName]++ values = append(values, core.QueryValue{ - Name: core.Escape(core.ParamName(p)), + Name: name, DBName: p.Column.GetName(), Typ: gen.makePythonType(p.Column), Column: p.Column, @@ -370,11 +380,23 @@ func (gen *PythonGenerator) columnsToStruct(name string, columns []goColumn, use fieldName = fmt.Sprintf("%s_%d", fieldName, suffix) } - f := core.Column{ - Name: inflection.Singular(inflection.SingularParams{ - Name: core.ColumnName(c.Column, i), + // Singularizing belongs to table names only; on columns it + // renames e.g. "outputs" to "output". Embedded fields are + // singularized: they hold one row of the joined table. + // Duplicate columns need the suffix in the field name, + // otherwise the class ends up with duplicate fields. + pyFieldName := core.ColumnName(c.Column, i) + if c.embed != nil { + pyFieldName = inflection.Singular(inflection.SingularParams{ + Name: pyFieldName, Exclusions: gen.config.InflectionExcludeTableNames, - }), + }) + } + if suffix > 0 { + pyFieldName = fmt.Sprintf("%s_%d", pyFieldName, suffix) + } + f := core.Column{ + Name: pyFieldName, DBName: colName, Column: c.Column, } diff --git a/internal/core/importer.go b/internal/core/importer.go index 3e2ec67..a183497 100644 --- a/internal/core/importer.go +++ b/internal/core/importer.go @@ -325,7 +325,9 @@ func (i *Importer) queryImports(fileName string) ([]string, []string, []string) if IsInMultipleMaps("datetime", std, typeCheck) { queryResultsArgsType += " | datetime.date | datetime.time | datetime.datetime | datetime.timedelta" } - queryResultsArgsType += " | None" + // asyncpg passes array-typed parameters (e.g. text[]) as + // sequences. + queryResultsArgsType += " | collections.abc.Sequence[typing.Any] | None" typeLines = append(typeLines, queryResultsArgsType) } diff --git a/test/driver_aiosqlite/attrs/classes/__init__.py b/test/driver_aiosqlite/attrs/classes/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_aiosqlite/attrs/classes/__init__.py +++ b/test/driver_aiosqlite/attrs/classes/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_aiosqlite/attrs/classes/models.py b/test/driver_aiosqlite/attrs/classes/models.py index 36327a6..0a7057f 100644 --- a/test/driver_aiosqlite/attrs/classes/models.py +++ b/test/driver_aiosqlite/attrs/classes/models.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations diff --git a/test/driver_aiosqlite/attrs/classes/queries.py b/test/driver_aiosqlite/attrs/classes/queries.py index ebe8e26..5dac97b 100644 --- a/test/driver_aiosqlite/attrs/classes/queries.py +++ b/test/driver_aiosqlite/attrs/classes/queries.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations @@ -22,7 +22,7 @@ import collections.abc import sqlite3 - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None from test.driver_aiosqlite.attrs.classes import models diff --git a/test/driver_aiosqlite/attrs/functions/__init__.py b/test/driver_aiosqlite/attrs/functions/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_aiosqlite/attrs/functions/__init__.py +++ b/test/driver_aiosqlite/attrs/functions/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_aiosqlite/attrs/functions/models.py b/test/driver_aiosqlite/attrs/functions/models.py index 36327a6..0a7057f 100644 --- a/test/driver_aiosqlite/attrs/functions/models.py +++ b/test/driver_aiosqlite/attrs/functions/models.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations diff --git a/test/driver_aiosqlite/attrs/functions/queries.py b/test/driver_aiosqlite/attrs/functions/queries.py index 3860631..2ccc162 100644 --- a/test/driver_aiosqlite/attrs/functions/queries.py +++ b/test/driver_aiosqlite/attrs/functions/queries.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations @@ -59,7 +59,7 @@ import collections.abc import sqlite3 - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None from test.driver_aiosqlite.attrs.functions import models diff --git a/test/driver_aiosqlite/dataclass/classes/__init__.py b/test/driver_aiosqlite/dataclass/classes/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_aiosqlite/dataclass/classes/__init__.py +++ b/test/driver_aiosqlite/dataclass/classes/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_aiosqlite/dataclass/classes/models.py b/test/driver_aiosqlite/dataclass/classes/models.py index 086490f..46bbf22 100644 --- a/test/driver_aiosqlite/dataclass/classes/models.py +++ b/test/driver_aiosqlite/dataclass/classes/models.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations diff --git a/test/driver_aiosqlite/dataclass/classes/queries.py b/test/driver_aiosqlite/dataclass/classes/queries.py index da4a5d7..0487100 100644 --- a/test/driver_aiosqlite/dataclass/classes/queries.py +++ b/test/driver_aiosqlite/dataclass/classes/queries.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations @@ -21,7 +21,7 @@ import collections.abc import sqlite3 - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None from test.driver_aiosqlite.dataclass.classes import models diff --git a/test/driver_aiosqlite/dataclass/functions/__init__.py b/test/driver_aiosqlite/dataclass/functions/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_aiosqlite/dataclass/functions/__init__.py +++ b/test/driver_aiosqlite/dataclass/functions/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_aiosqlite/dataclass/functions/models.py b/test/driver_aiosqlite/dataclass/functions/models.py index 086490f..46bbf22 100644 --- a/test/driver_aiosqlite/dataclass/functions/models.py +++ b/test/driver_aiosqlite/dataclass/functions/models.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations diff --git a/test/driver_aiosqlite/dataclass/functions/queries.py b/test/driver_aiosqlite/dataclass/functions/queries.py index 511af5c..33ac96a 100644 --- a/test/driver_aiosqlite/dataclass/functions/queries.py +++ b/test/driver_aiosqlite/dataclass/functions/queries.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations @@ -59,7 +59,7 @@ import collections.abc import sqlite3 - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None from test.driver_aiosqlite.dataclass.functions import models diff --git a/test/driver_aiosqlite/msgspec/classes/__init__.py b/test/driver_aiosqlite/msgspec/classes/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_aiosqlite/msgspec/classes/__init__.py +++ b/test/driver_aiosqlite/msgspec/classes/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_aiosqlite/msgspec/classes/models.py b/test/driver_aiosqlite/msgspec/classes/models.py index 0819a9c..36e4a60 100644 --- a/test/driver_aiosqlite/msgspec/classes/models.py +++ b/test/driver_aiosqlite/msgspec/classes/models.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations diff --git a/test/driver_aiosqlite/msgspec/classes/queries.py b/test/driver_aiosqlite/msgspec/classes/queries.py index 4225502..58477d1 100644 --- a/test/driver_aiosqlite/msgspec/classes/queries.py +++ b/test/driver_aiosqlite/msgspec/classes/queries.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations @@ -21,7 +21,7 @@ import collections.abc import sqlite3 - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None from test.driver_aiosqlite.msgspec.classes import models diff --git a/test/driver_aiosqlite/msgspec/functions/__init__.py b/test/driver_aiosqlite/msgspec/functions/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_aiosqlite/msgspec/functions/__init__.py +++ b/test/driver_aiosqlite/msgspec/functions/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_aiosqlite/msgspec/functions/models.py b/test/driver_aiosqlite/msgspec/functions/models.py index 0819a9c..36e4a60 100644 --- a/test/driver_aiosqlite/msgspec/functions/models.py +++ b/test/driver_aiosqlite/msgspec/functions/models.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations diff --git a/test/driver_aiosqlite/msgspec/functions/queries.py b/test/driver_aiosqlite/msgspec/functions/queries.py index cfd5328..3b8bc83 100644 --- a/test/driver_aiosqlite/msgspec/functions/queries.py +++ b/test/driver_aiosqlite/msgspec/functions/queries.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations @@ -59,7 +59,7 @@ import collections.abc import sqlite3 - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None from test.driver_aiosqlite.msgspec.functions import models diff --git a/test/driver_aiosqlite/sqlc-gen-better-python.wasm b/test/driver_aiosqlite/sqlc-gen-better-python.wasm index 56caaa4..1088cd1 100644 Binary files a/test/driver_aiosqlite/sqlc-gen-better-python.wasm and b/test/driver_aiosqlite/sqlc-gen-better-python.wasm differ diff --git a/test/driver_aiosqlite/sqlc.yaml b/test/driver_aiosqlite/sqlc.yaml index 157a046..e93b73d 100644 --- a/test/driver_aiosqlite/sqlc.yaml +++ b/test/driver_aiosqlite/sqlc.yaml @@ -3,7 +3,7 @@ plugins: - name: python wasm: url: file://sqlc-gen-better-python.wasm - sha256: ee7bd0c07b784b80ea8c5853d9a6a04c51a7abbfd2663f470e9a5d2f623b967e + sha256: 53c4de16a585391d2ff2a545b12d04bce82b6e194873042706d471d343f2bbc2 sql: - schema: schema.sql queries: queries.sql diff --git a/test/driver_asyncpg/attrs/classes/__init__.py b/test/driver_asyncpg/attrs/classes/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_asyncpg/attrs/classes/__init__.py +++ b/test/driver_asyncpg/attrs/classes/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_asyncpg/attrs/classes/models.py b/test/driver_asyncpg/attrs/classes/models.py index 3c99c99..84651e5 100644 --- a/test/driver_asyncpg/attrs/classes/models.py +++ b/test/driver_asyncpg/attrs/classes/models.py @@ -1,11 +1,12 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations __all__: collections.abc.Sequence[str] = ( + "TestFieldNaming", "TestInnerPostgresType", "TestPostgresType", "TestTypeOverride", @@ -22,6 +23,23 @@ import uuid +@attrs.define() +class TestFieldNaming: + """Model representing TestFieldNaming. + + Attributes + ---------- + id : int + outputs : str + groups : collections.abc.Sequence[str] + + """ + + id: int + outputs: str + groups: collections.abc.Sequence[str] + + @attrs.define() class TestInnerPostgresType: """Model representing TestInnerPostgresType. diff --git a/test/driver_asyncpg/attrs/classes/queries.py b/test/driver_asyncpg/attrs/classes/queries.py index 7332b46..c26905d 100644 --- a/test/driver_asyncpg/attrs/classes/queries.py +++ b/test/driver_asyncpg/attrs/classes/queries.py @@ -1,13 +1,14 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations __all__: collections.abc.Sequence[str] = ( "GetAllEmbeddedTestPostgresTypeRow", "GetEmbeddedTestPostgresTypeRow", + "GetFieldNamingDuplicateColumnsRow", "Queries", "QueryResults", "TestCopyFromParams", @@ -26,7 +27,7 @@ import decimal import uuid - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | uuid.UUID | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | uuid.UUID | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None ConnectionLike: typing.TypeAlias = asyncpg.Connection[asyncpg.Record] | asyncpg.pool.PoolConnectionProxy[asyncpg.Record] @@ -133,6 +134,21 @@ class GetEmbeddedTestPostgresTypeRow: test_inner_postgres_type: models.TestInnerPostgresType +@attrs.define() +class GetFieldNamingDuplicateColumnsRow: + """Model representing GetFieldNamingDuplicateColumnsRow. + + Attributes + ---------- + outputs : str + outputs_2 : str + + """ + + outputs: str + outputs_2: str + + @attrs.define() class TestCopyFromParams: """Model representing TestCopyFromParams. @@ -378,6 +394,19 @@ class TestCopyFromParams: WHERE test_postgres_types.id = $1 """ +GET_FIELD_NAMING: typing.Final[str] = """-- name: GetFieldNaming :one +SELECT id, outputs, groups +FROM test_field_namings +WHERE id = $1 LIMIT 1 +""" + +GET_FIELD_NAMING_DUPLICATE_COLUMNS: typing.Final[str] = """-- name: GetFieldNamingDuplicateColumns :one +SELECT a.outputs, b.outputs +FROM test_field_namings a +JOIN test_field_namings b ON a.id = b.id +WHERE a.id = $1 LIMIT 1 +""" + GET_MANY_TEST_BYTEA_POSTGRES_TYPE: typing.Final[str] = """-- name: GetManyTestByteaPostgresType :many SELECT bytea_test FROM test_postgres_types @@ -454,6 +483,12 @@ class TestCopyFromParams: VALUES ($1, $2, $3) """ +UPDATE_FIELD_NAMING_MIXED_PARAMS: typing.Final[str] = """-- name: UpdateFieldNamingMixedParams :exec +UPDATE test_field_namings +SET outputs = $2 +WHERE id = $1 AND outputs <> $3::jsonb +""" + UPDATE_RESULT_TEST_POSTGRES_TYPE: typing.Final[str] = """-- name: UpdateResultTestPostgresType :execresult UPDATE test_postgres_types SET serial_test = 187 @@ -1108,6 +1143,55 @@ async def get_embedded_test_postgres_type(self, *, id_: int) -> GetEmbeddedTestP return None return GetEmbeddedTestPostgresTypeRow(id=row[0], serial_test=row[1], serial4_test=row[2], bigserial_test=row[3], smallserial_test=row[4], int_test=row[5], bigint_test=row[6], smallint_test=row[7], float_test=row[8], double_precision_test=row[9], real_test=row[10], numeric_test=row[11], money_test=row[12], bool_test=row[13], json_test=row[14], jsonb_test=row[15], bytea_test=memoryview(row[16]), date_test=row[17], time_test=row[18], timetz_test=row[19], timestamp_test=row[20], timestamptz_test=row[21], interval_test=row[22], text_test=row[23], varchar_test=row[24], bpchar_test=row[25], char_test=row[26], citext_test=row[27], uuid_test=row[28], inet_test=str(row[29]), cidr_test=str(row[30]), macaddr_test=row[31], macaddr8_test=row[32], ltree_test=row[33], lquery_test=row[34], ltxtquery_test=row[35], test_inner_postgres_type=models.TestInnerPostgresType(table_id=row[36], serial_test=row[37], serial4_test=row[38], bigserial_test=row[39], smallserial_test=row[40], int_test=row[41], bigint_test=row[42], smallint_test=row[43], float_test=row[44], double_precision_test=row[45], real_test=row[46], numeric_test=row[47], money_test=row[48], bool_test=row[49], json_test=row[50], jsonb_test=row[51], bytea_test=memoryview(row[52]) if row[52] is not None else None, date_test=row[53], time_test=row[54], timetz_test=row[55], timestamp_test=row[56], timestamptz_test=row[57], interval_test=row[58], text_test=row[59], varchar_test=row[60], bpchar_test=row[61], char_test=row[62], citext_test=row[63], uuid_test=row[64], inet_test=str(row[65]) if row[65] is not None else None, cidr_test=str(row[66]) if row[66] is not None else None, macaddr_test=row[67], macaddr8_test=row[68], ltree_test=row[69], lquery_test=row[70], ltxtquery_test=row[71])) + async def get_field_naming(self, *, id_: int) -> models.TestFieldNaming | None: + """Fetch one from the db using the SQL query with `name: GetFieldNaming :one`. + + ```sql + SELECT id, outputs, groups + FROM test_field_namings + WHERE id = $1 LIMIT 1 + ``` + + Parameters + ---------- + id_ : int + + Returns + ------- + models.TestFieldNaming + Result fetched from the db. Will be `None` if not found. + + """ + row = await self._conn.fetchrow(GET_FIELD_NAMING, id_) + if row is None: + return None + return models.TestFieldNaming(id=row[0], outputs=row[1], groups=row[2]) + + async def get_field_naming_duplicate_columns(self, *, id_: int) -> GetFieldNamingDuplicateColumnsRow | None: + """Fetch one from the db using the SQL query with `name: GetFieldNamingDuplicateColumns :one`. + + ```sql + SELECT a.outputs, b.outputs + FROM test_field_namings a + JOIN test_field_namings b ON a.id = b.id + WHERE a.id = $1 LIMIT 1 + ``` + + Parameters + ---------- + id_ : int + + Returns + ------- + GetFieldNamingDuplicateColumnsRow + Result fetched from the db. Will be `None` if not found. + + """ + row = await self._conn.fetchrow(GET_FIELD_NAMING_DUPLICATE_COLUMNS, id_) + if row is None: + return None + return GetFieldNamingDuplicateColumnsRow(outputs=row[0], outputs_2=row[1]) + def get_many_test_bytea_postgres_type(self, *, id_: int) -> QueryResults[memoryview]: """Fetch many from the db using the SQL query with `name: GetManyTestByteaPostgresType :many`. @@ -1416,6 +1500,24 @@ async def test_copy_from(self, *, params: collections.abc.Sequence[TestCopyFromP r = await self._conn.copy_records_to_table("test_copy_from", columns=["id", "float_test", "int_test"], records=records) return int(n) if (n := r.split()[-1]).isdigit() else 0 + async def update_field_naming_mixed_params(self, *, id_: int, outputs: str, outputs_2: str) -> None: + """Execute SQL query with `name: UpdateFieldNamingMixedParams :exec`. + + ```sql + UPDATE test_field_namings + SET outputs = $2 + WHERE id = $1 AND outputs <> $3::jsonb + ``` + + Parameters + ---------- + id_ : int + outputs : str + outputs_2 : str + + """ + await self._conn.execute(UPDATE_FIELD_NAMING_MIXED_PARAMS, id_, outputs, outputs_2) + async def update_result_test_postgres_type(self, *, id_: int) -> str: """Execute and return the result of SQL query with `name: UpdateResultTestPostgresType :execresult`. diff --git a/test/driver_asyncpg/attrs/functions/__init__.py b/test/driver_asyncpg/attrs/functions/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_asyncpg/attrs/functions/__init__.py +++ b/test/driver_asyncpg/attrs/functions/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_asyncpg/attrs/functions/models.py b/test/driver_asyncpg/attrs/functions/models.py index 3c99c99..84651e5 100644 --- a/test/driver_asyncpg/attrs/functions/models.py +++ b/test/driver_asyncpg/attrs/functions/models.py @@ -1,11 +1,12 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations __all__: collections.abc.Sequence[str] = ( + "TestFieldNaming", "TestInnerPostgresType", "TestPostgresType", "TestTypeOverride", @@ -22,6 +23,23 @@ import uuid +@attrs.define() +class TestFieldNaming: + """Model representing TestFieldNaming. + + Attributes + ---------- + id : int + outputs : str + groups : collections.abc.Sequence[str] + + """ + + id: int + outputs: str + groups: collections.abc.Sequence[str] + + @attrs.define() class TestInnerPostgresType: """Model representing TestInnerPostgresType. diff --git a/test/driver_asyncpg/attrs/functions/queries.py b/test/driver_asyncpg/attrs/functions/queries.py index 5c0c661..0967639 100644 --- a/test/driver_asyncpg/attrs/functions/queries.py +++ b/test/driver_asyncpg/attrs/functions/queries.py @@ -1,13 +1,14 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations __all__: collections.abc.Sequence[str] = ( "GetAllEmbeddedTestPostgresTypeRow", "GetEmbeddedTestPostgresTypeRow", + "GetFieldNamingDuplicateColumnsRow", "QueryResults", "TestCopyFromParams", "create_one_test_postgres_inner_type", @@ -22,6 +23,8 @@ "delete_type_override", "get_all_embedded_test_postgres_type", "get_embedded_test_postgres_type", + "get_field_naming", + "get_field_naming_duplicate_columns", "get_many_test_bytea_postgres_type", "get_many_test_iterator_postgres_type", "get_many_test_postgres_type", @@ -36,6 +39,7 @@ "get_one_type_override", "insert_type_override", "test_copy_from", + "update_field_naming_mixed_params", "update_result_test_postgres_type", "update_rows_test_postgres_type", ) @@ -53,7 +57,7 @@ import decimal import uuid - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | uuid.UUID | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | uuid.UUID | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None ConnectionLike: typing.TypeAlias = asyncpg.Connection[asyncpg.Record] | asyncpg.pool.PoolConnectionProxy[asyncpg.Record] @@ -160,6 +164,21 @@ class GetEmbeddedTestPostgresTypeRow: test_inner_postgres_type: models.TestInnerPostgresType +@attrs.define() +class GetFieldNamingDuplicateColumnsRow: + """Model representing GetFieldNamingDuplicateColumnsRow. + + Attributes + ---------- + outputs : str + outputs_2 : str + + """ + + outputs: str + outputs_2: str + + @attrs.define() class TestCopyFromParams: """Model representing TestCopyFromParams. @@ -405,6 +424,19 @@ class TestCopyFromParams: WHERE test_postgres_types.id = $1 """ +GET_FIELD_NAMING: typing.Final[str] = """-- name: GetFieldNaming :one +SELECT id, outputs, groups +FROM test_field_namings +WHERE id = $1 LIMIT 1 +""" + +GET_FIELD_NAMING_DUPLICATE_COLUMNS: typing.Final[str] = """-- name: GetFieldNamingDuplicateColumns :one +SELECT a.outputs, b.outputs +FROM test_field_namings a +JOIN test_field_namings b ON a.id = b.id +WHERE a.id = $1 LIMIT 1 +""" + GET_MANY_TEST_BYTEA_POSTGRES_TYPE: typing.Final[str] = """-- name: GetManyTestByteaPostgresType :many SELECT bytea_test FROM test_postgres_types @@ -481,6 +513,12 @@ class TestCopyFromParams: VALUES ($1, $2, $3) """ +UPDATE_FIELD_NAMING_MIXED_PARAMS: typing.Final[str] = """-- name: UpdateFieldNamingMixedParams :exec +UPDATE test_field_namings +SET outputs = $2 +WHERE id = $1 AND outputs <> $3::jsonb +""" + UPDATE_RESULT_TEST_POSTGRES_TYPE: typing.Final[str] = """-- name: UpdateResultTestPostgresType :execresult UPDATE test_postgres_types SET serial_test = 187 @@ -1147,6 +1185,61 @@ async def get_embedded_test_postgres_type(conn: ConnectionLike, *, id_: int) -> return GetEmbeddedTestPostgresTypeRow(id=row[0], serial_test=row[1], serial4_test=row[2], bigserial_test=row[3], smallserial_test=row[4], int_test=row[5], bigint_test=row[6], smallint_test=row[7], float_test=row[8], double_precision_test=row[9], real_test=row[10], numeric_test=row[11], money_test=row[12], bool_test=row[13], json_test=row[14], jsonb_test=row[15], bytea_test=memoryview(row[16]), date_test=row[17], time_test=row[18], timetz_test=row[19], timestamp_test=row[20], timestamptz_test=row[21], interval_test=row[22], text_test=row[23], varchar_test=row[24], bpchar_test=row[25], char_test=row[26], citext_test=row[27], uuid_test=row[28], inet_test=str(row[29]), cidr_test=str(row[30]), macaddr_test=row[31], macaddr8_test=row[32], ltree_test=row[33], lquery_test=row[34], ltxtquery_test=row[35], test_inner_postgres_type=models.TestInnerPostgresType(table_id=row[36], serial_test=row[37], serial4_test=row[38], bigserial_test=row[39], smallserial_test=row[40], int_test=row[41], bigint_test=row[42], smallint_test=row[43], float_test=row[44], double_precision_test=row[45], real_test=row[46], numeric_test=row[47], money_test=row[48], bool_test=row[49], json_test=row[50], jsonb_test=row[51], bytea_test=memoryview(row[52]) if row[52] is not None else None, date_test=row[53], time_test=row[54], timetz_test=row[55], timestamp_test=row[56], timestamptz_test=row[57], interval_test=row[58], text_test=row[59], varchar_test=row[60], bpchar_test=row[61], char_test=row[62], citext_test=row[63], uuid_test=row[64], inet_test=str(row[65]) if row[65] is not None else None, cidr_test=str(row[66]) if row[66] is not None else None, macaddr_test=row[67], macaddr8_test=row[68], ltree_test=row[69], lquery_test=row[70], ltxtquery_test=row[71])) +async def get_field_naming(conn: ConnectionLike, *, id_: int) -> models.TestFieldNaming | None: + """Fetch one from the db using the SQL query with `name: GetFieldNaming :one`. + + ```sql + SELECT id, outputs, groups + FROM test_field_namings + WHERE id = $1 LIMIT 1 + ``` + + Parameters + ---------- + conn : ConnectionLike + Connection object of type `ConnectionLike` used to execute the query. + id_ : int + + Returns + ------- + models.TestFieldNaming + Result fetched from the db. Will be `None` if not found. + + """ + row = await conn.fetchrow(GET_FIELD_NAMING, id_) + if row is None: + return None + return models.TestFieldNaming(id=row[0], outputs=row[1], groups=row[2]) + + +async def get_field_naming_duplicate_columns(conn: ConnectionLike, *, id_: int) -> GetFieldNamingDuplicateColumnsRow | None: + """Fetch one from the db using the SQL query with `name: GetFieldNamingDuplicateColumns :one`. + + ```sql + SELECT a.outputs, b.outputs + FROM test_field_namings a + JOIN test_field_namings b ON a.id = b.id + WHERE a.id = $1 LIMIT 1 + ``` + + Parameters + ---------- + conn : ConnectionLike + Connection object of type `ConnectionLike` used to execute the query. + id_ : int + + Returns + ------- + GetFieldNamingDuplicateColumnsRow + Result fetched from the db. Will be `None` if not found. + + """ + row = await conn.fetchrow(GET_FIELD_NAMING_DUPLICATE_COLUMNS, id_) + if row is None: + return None + return GetFieldNamingDuplicateColumnsRow(outputs=row[0], outputs_2=row[1]) + + def get_many_test_bytea_postgres_type(conn: ConnectionLike, *, id_: int) -> QueryResults[memoryview]: """Fetch many from the db using the SQL query with `name: GetManyTestByteaPostgresType :many`. @@ -1497,6 +1590,27 @@ async def test_copy_from(conn: ConnectionLike, *, params: collections.abc.Sequen return int(n) if (n := r.split()[-1]).isdigit() else 0 +async def update_field_naming_mixed_params(conn: ConnectionLike, *, id_: int, outputs: str, outputs_2: str) -> None: + """Execute SQL query with `name: UpdateFieldNamingMixedParams :exec`. + + ```sql + UPDATE test_field_namings + SET outputs = $2 + WHERE id = $1 AND outputs <> $3::jsonb + ``` + + Parameters + ---------- + conn : ConnectionLike + Connection object of type `ConnectionLike` used to execute the query. + id_ : int + outputs : str + outputs_2 : str + + """ + await conn.execute(UPDATE_FIELD_NAMING_MIXED_PARAMS, id_, outputs, outputs_2) + + async def update_result_test_postgres_type(conn: ConnectionLike, *, id_: int) -> str: """Execute and return the result of SQL query with `name: UpdateResultTestPostgresType :execresult`. diff --git a/test/driver_asyncpg/dataclass/classes/__init__.py b/test/driver_asyncpg/dataclass/classes/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_asyncpg/dataclass/classes/__init__.py +++ b/test/driver_asyncpg/dataclass/classes/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_asyncpg/dataclass/classes/models.py b/test/driver_asyncpg/dataclass/classes/models.py index 7cc9cf4..5455397 100644 --- a/test/driver_asyncpg/dataclass/classes/models.py +++ b/test/driver_asyncpg/dataclass/classes/models.py @@ -1,11 +1,12 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations __all__: collections.abc.Sequence[str] = ( + "TestFieldNaming", "TestInnerPostgresType", "TestPostgresType", "TestTypeOverride", @@ -22,6 +23,21 @@ import uuid +@dataclasses.dataclass() +class TestFieldNaming: + """Model representing TestFieldNaming. + + Attributes: + id: int + outputs: str + groups: collections.abc.Sequence[str] + """ + + id: int + outputs: str + groups: collections.abc.Sequence[str] + + @dataclasses.dataclass() class TestInnerPostgresType: """Model representing TestInnerPostgresType. diff --git a/test/driver_asyncpg/dataclass/classes/queries.py b/test/driver_asyncpg/dataclass/classes/queries.py index 2efd7cb..c0629c6 100644 --- a/test/driver_asyncpg/dataclass/classes/queries.py +++ b/test/driver_asyncpg/dataclass/classes/queries.py @@ -1,13 +1,14 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations __all__: collections.abc.Sequence[str] = ( "GetAllEmbeddedTestPostgresTypeRow", "GetEmbeddedTestPostgresTypeRow", + "GetFieldNamingDuplicateColumnsRow", "Queries", "QueryResults", "TestCopyFromParams", @@ -26,7 +27,7 @@ import decimal import uuid - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | uuid.UUID | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | uuid.UUID | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None ConnectionLike: typing.TypeAlias = asyncpg.Connection[asyncpg.Record] | asyncpg.pool.PoolConnectionProxy[asyncpg.Record] @@ -129,6 +130,19 @@ class GetEmbeddedTestPostgresTypeRow: test_inner_postgres_type: models.TestInnerPostgresType +@dataclasses.dataclass() +class GetFieldNamingDuplicateColumnsRow: + """Model representing GetFieldNamingDuplicateColumnsRow. + + Attributes: + outputs: str + outputs_2: str + """ + + outputs: str + outputs_2: str + + @dataclasses.dataclass() class TestCopyFromParams: """Model representing TestCopyFromParams. @@ -372,6 +386,19 @@ class TestCopyFromParams: WHERE test_postgres_types.id = $1 """ +GET_FIELD_NAMING: typing.Final[str] = """-- name: GetFieldNaming :one +SELECT id, outputs, groups +FROM test_field_namings +WHERE id = $1 LIMIT 1 +""" + +GET_FIELD_NAMING_DUPLICATE_COLUMNS: typing.Final[str] = """-- name: GetFieldNamingDuplicateColumns :one +SELECT a.outputs, b.outputs +FROM test_field_namings a +JOIN test_field_namings b ON a.id = b.id +WHERE a.id = $1 LIMIT 1 +""" + GET_MANY_TEST_BYTEA_POSTGRES_TYPE: typing.Final[str] = """-- name: GetManyTestByteaPostgresType :many SELECT bytea_test FROM test_postgres_types @@ -448,6 +475,12 @@ class TestCopyFromParams: VALUES ($1, $2, $3) """ +UPDATE_FIELD_NAMING_MIXED_PARAMS: typing.Final[str] = """-- name: UpdateFieldNamingMixedParams :exec +UPDATE test_field_namings +SET outputs = $2 +WHERE id = $1 AND outputs <> $3::jsonb +""" + UPDATE_RESULT_TEST_POSTGRES_TYPE: typing.Final[str] = """-- name: UpdateResultTestPostgresType :execresult UPDATE test_postgres_types SET serial_test = 187 @@ -1051,6 +1084,47 @@ async def get_embedded_test_postgres_type(self, *, id_: int) -> GetEmbeddedTestP return None return GetEmbeddedTestPostgresTypeRow(id=row[0], serial_test=row[1], serial4_test=row[2], bigserial_test=row[3], smallserial_test=row[4], int_test=row[5], bigint_test=row[6], smallint_test=row[7], float_test=row[8], double_precision_test=row[9], real_test=row[10], numeric_test=row[11], money_test=row[12], bool_test=row[13], json_test=row[14], jsonb_test=row[15], bytea_test=memoryview(row[16]), date_test=row[17], time_test=row[18], timetz_test=row[19], timestamp_test=row[20], timestamptz_test=row[21], interval_test=row[22], text_test=row[23], varchar_test=row[24], bpchar_test=row[25], char_test=row[26], citext_test=row[27], uuid_test=row[28], inet_test=str(row[29]), cidr_test=str(row[30]), macaddr_test=row[31], macaddr8_test=row[32], ltree_test=row[33], lquery_test=row[34], ltxtquery_test=row[35], test_inner_postgres_type=models.TestInnerPostgresType(table_id=row[36], serial_test=row[37], serial4_test=row[38], bigserial_test=row[39], smallserial_test=row[40], int_test=row[41], bigint_test=row[42], smallint_test=row[43], float_test=row[44], double_precision_test=row[45], real_test=row[46], numeric_test=row[47], money_test=row[48], bool_test=row[49], json_test=row[50], jsonb_test=row[51], bytea_test=memoryview(row[52]) if row[52] is not None else None, date_test=row[53], time_test=row[54], timetz_test=row[55], timestamp_test=row[56], timestamptz_test=row[57], interval_test=row[58], text_test=row[59], varchar_test=row[60], bpchar_test=row[61], char_test=row[62], citext_test=row[63], uuid_test=row[64], inet_test=str(row[65]) if row[65] is not None else None, cidr_test=str(row[66]) if row[66] is not None else None, macaddr_test=row[67], macaddr8_test=row[68], ltree_test=row[69], lquery_test=row[70], ltxtquery_test=row[71])) + async def get_field_naming(self, *, id_: int) -> models.TestFieldNaming | None: + """Fetch one from the db using the SQL query with `name: GetFieldNaming :one`. + + ```sql + SELECT id, outputs, groups + FROM test_field_namings + WHERE id = $1 LIMIT 1 + ``` + + Args: + id_: int. + + Returns: + Result of type `models.TestFieldNaming` fetched from the db. Will be `None` if not found. + """ + row = await self._conn.fetchrow(GET_FIELD_NAMING, id_) + if row is None: + return None + return models.TestFieldNaming(id=row[0], outputs=row[1], groups=row[2]) + + async def get_field_naming_duplicate_columns(self, *, id_: int) -> GetFieldNamingDuplicateColumnsRow | None: + """Fetch one from the db using the SQL query with `name: GetFieldNamingDuplicateColumns :one`. + + ```sql + SELECT a.outputs, b.outputs + FROM test_field_namings a + JOIN test_field_namings b ON a.id = b.id + WHERE a.id = $1 LIMIT 1 + ``` + + Args: + id_: int. + + Returns: + Result of type `GetFieldNamingDuplicateColumnsRow` fetched from the db. Will be `None` if not found. + """ + row = await self._conn.fetchrow(GET_FIELD_NAMING_DUPLICATE_COLUMNS, id_) + if row is None: + return None + return GetFieldNamingDuplicateColumnsRow(outputs=row[0], outputs_2=row[1]) + def get_many_test_bytea_postgres_type(self, *, id_: int) -> QueryResults[memoryview]: """Fetch many from the db using the SQL query with `name: GetManyTestByteaPostgresType :many`. @@ -1305,6 +1379,22 @@ async def test_copy_from(self, *, params: collections.abc.Sequence[TestCopyFromP r = await self._conn.copy_records_to_table("test_copy_from", columns=["id", "float_test", "int_test"], records=records) return int(n) if (p := r.split()) and (n := p[-1]).isdigit() else 0 + async def update_field_naming_mixed_params(self, *, id_: int, outputs: str, outputs_2: str) -> None: + """Execute SQL query with `name: UpdateFieldNamingMixedParams :exec`. + + ```sql + UPDATE test_field_namings + SET outputs = $2 + WHERE id = $1 AND outputs <> $3::jsonb + ``` + + Args: + id_: int. + outputs: str. + outputs_2: str. + """ + await self._conn.execute(UPDATE_FIELD_NAMING_MIXED_PARAMS, id_, outputs, outputs_2) + async def update_result_test_postgres_type(self, *, id_: int) -> str: """Execute and return the result of SQL query with `name: UpdateResultTestPostgresType :execresult`. diff --git a/test/driver_asyncpg/dataclass/functions/__init__.py b/test/driver_asyncpg/dataclass/functions/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_asyncpg/dataclass/functions/__init__.py +++ b/test/driver_asyncpg/dataclass/functions/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_asyncpg/dataclass/functions/models.py b/test/driver_asyncpg/dataclass/functions/models.py index 7cc9cf4..5455397 100644 --- a/test/driver_asyncpg/dataclass/functions/models.py +++ b/test/driver_asyncpg/dataclass/functions/models.py @@ -1,11 +1,12 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations __all__: collections.abc.Sequence[str] = ( + "TestFieldNaming", "TestInnerPostgresType", "TestPostgresType", "TestTypeOverride", @@ -22,6 +23,21 @@ import uuid +@dataclasses.dataclass() +class TestFieldNaming: + """Model representing TestFieldNaming. + + Attributes: + id: int + outputs: str + groups: collections.abc.Sequence[str] + """ + + id: int + outputs: str + groups: collections.abc.Sequence[str] + + @dataclasses.dataclass() class TestInnerPostgresType: """Model representing TestInnerPostgresType. diff --git a/test/driver_asyncpg/dataclass/functions/queries.py b/test/driver_asyncpg/dataclass/functions/queries.py index 8803166..ee0673d 100644 --- a/test/driver_asyncpg/dataclass/functions/queries.py +++ b/test/driver_asyncpg/dataclass/functions/queries.py @@ -1,13 +1,14 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations __all__: collections.abc.Sequence[str] = ( "GetAllEmbeddedTestPostgresTypeRow", "GetEmbeddedTestPostgresTypeRow", + "GetFieldNamingDuplicateColumnsRow", "QueryResults", "TestCopyFromParams", "create_one_test_postgres_inner_type", @@ -22,6 +23,8 @@ "delete_type_override", "get_all_embedded_test_postgres_type", "get_embedded_test_postgres_type", + "get_field_naming", + "get_field_naming_duplicate_columns", "get_many_test_bytea_postgres_type", "get_many_test_iterator_postgres_type", "get_many_test_postgres_type", @@ -36,6 +39,7 @@ "get_one_type_override", "insert_type_override", "test_copy_from", + "update_field_naming_mixed_params", "update_result_test_postgres_type", "update_rows_test_postgres_type", ) @@ -53,7 +57,7 @@ import decimal import uuid - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | uuid.UUID | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | uuid.UUID | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None ConnectionLike: typing.TypeAlias = asyncpg.Connection[asyncpg.Record] | asyncpg.pool.PoolConnectionProxy[asyncpg.Record] @@ -156,6 +160,19 @@ class GetEmbeddedTestPostgresTypeRow: test_inner_postgres_type: models.TestInnerPostgresType +@dataclasses.dataclass() +class GetFieldNamingDuplicateColumnsRow: + """Model representing GetFieldNamingDuplicateColumnsRow. + + Attributes: + outputs: str + outputs_2: str + """ + + outputs: str + outputs_2: str + + @dataclasses.dataclass() class TestCopyFromParams: """Model representing TestCopyFromParams. @@ -399,6 +416,19 @@ class TestCopyFromParams: WHERE test_postgres_types.id = $1 """ +GET_FIELD_NAMING: typing.Final[str] = """-- name: GetFieldNaming :one +SELECT id, outputs, groups +FROM test_field_namings +WHERE id = $1 LIMIT 1 +""" + +GET_FIELD_NAMING_DUPLICATE_COLUMNS: typing.Final[str] = """-- name: GetFieldNamingDuplicateColumns :one +SELECT a.outputs, b.outputs +FROM test_field_namings a +JOIN test_field_namings b ON a.id = b.id +WHERE a.id = $1 LIMIT 1 +""" + GET_MANY_TEST_BYTEA_POSTGRES_TYPE: typing.Final[str] = """-- name: GetManyTestByteaPostgresType :many SELECT bytea_test FROM test_postgres_types @@ -475,6 +505,12 @@ class TestCopyFromParams: VALUES ($1, $2, $3) """ +UPDATE_FIELD_NAMING_MIXED_PARAMS: typing.Final[str] = """-- name: UpdateFieldNamingMixedParams :exec +UPDATE test_field_namings +SET outputs = $2 +WHERE id = $1 AND outputs <> $3::jsonb +""" + UPDATE_RESULT_TEST_POSTGRES_TYPE: typing.Final[str] = """-- name: UpdateResultTestPostgresType :execresult UPDATE test_postgres_types SET serial_test = 187 @@ -1093,6 +1129,53 @@ async def get_embedded_test_postgres_type(conn: ConnectionLike, *, id_: int) -> return GetEmbeddedTestPostgresTypeRow(id=row[0], serial_test=row[1], serial4_test=row[2], bigserial_test=row[3], smallserial_test=row[4], int_test=row[5], bigint_test=row[6], smallint_test=row[7], float_test=row[8], double_precision_test=row[9], real_test=row[10], numeric_test=row[11], money_test=row[12], bool_test=row[13], json_test=row[14], jsonb_test=row[15], bytea_test=memoryview(row[16]), date_test=row[17], time_test=row[18], timetz_test=row[19], timestamp_test=row[20], timestamptz_test=row[21], interval_test=row[22], text_test=row[23], varchar_test=row[24], bpchar_test=row[25], char_test=row[26], citext_test=row[27], uuid_test=row[28], inet_test=str(row[29]), cidr_test=str(row[30]), macaddr_test=row[31], macaddr8_test=row[32], ltree_test=row[33], lquery_test=row[34], ltxtquery_test=row[35], test_inner_postgres_type=models.TestInnerPostgresType(table_id=row[36], serial_test=row[37], serial4_test=row[38], bigserial_test=row[39], smallserial_test=row[40], int_test=row[41], bigint_test=row[42], smallint_test=row[43], float_test=row[44], double_precision_test=row[45], real_test=row[46], numeric_test=row[47], money_test=row[48], bool_test=row[49], json_test=row[50], jsonb_test=row[51], bytea_test=memoryview(row[52]) if row[52] is not None else None, date_test=row[53], time_test=row[54], timetz_test=row[55], timestamp_test=row[56], timestamptz_test=row[57], interval_test=row[58], text_test=row[59], varchar_test=row[60], bpchar_test=row[61], char_test=row[62], citext_test=row[63], uuid_test=row[64], inet_test=str(row[65]) if row[65] is not None else None, cidr_test=str(row[66]) if row[66] is not None else None, macaddr_test=row[67], macaddr8_test=row[68], ltree_test=row[69], lquery_test=row[70], ltxtquery_test=row[71])) +async def get_field_naming(conn: ConnectionLike, *, id_: int) -> models.TestFieldNaming | None: + """Fetch one from the db using the SQL query with `name: GetFieldNaming :one`. + + ```sql + SELECT id, outputs, groups + FROM test_field_namings + WHERE id = $1 LIMIT 1 + ``` + + Args: + conn: + Connection object of type `ConnectionLike` used to execute the query. + id_: int. + + Returns: + Result of type `models.TestFieldNaming` fetched from the db. Will be `None` if not found. + """ + row = await conn.fetchrow(GET_FIELD_NAMING, id_) + if row is None: + return None + return models.TestFieldNaming(id=row[0], outputs=row[1], groups=row[2]) + + +async def get_field_naming_duplicate_columns(conn: ConnectionLike, *, id_: int) -> GetFieldNamingDuplicateColumnsRow | None: + """Fetch one from the db using the SQL query with `name: GetFieldNamingDuplicateColumns :one`. + + ```sql + SELECT a.outputs, b.outputs + FROM test_field_namings a + JOIN test_field_namings b ON a.id = b.id + WHERE a.id = $1 LIMIT 1 + ``` + + Args: + conn: + Connection object of type `ConnectionLike` used to execute the query. + id_: int. + + Returns: + Result of type `GetFieldNamingDuplicateColumnsRow` fetched from the db. Will be `None` if not found. + """ + row = await conn.fetchrow(GET_FIELD_NAMING_DUPLICATE_COLUMNS, id_) + if row is None: + return None + return GetFieldNamingDuplicateColumnsRow(outputs=row[0], outputs_2=row[1]) + + def get_many_test_bytea_postgres_type(conn: ConnectionLike, *, id_: int) -> QueryResults[memoryview]: """Fetch many from the db using the SQL query with `name: GetManyTestByteaPostgresType :many`. @@ -1389,6 +1472,25 @@ async def test_copy_from(conn: ConnectionLike, *, params: collections.abc.Sequen return int(n) if (p := r.split()) and (n := p[-1]).isdigit() else 0 +async def update_field_naming_mixed_params(conn: ConnectionLike, *, id_: int, outputs: str, outputs_2: str) -> None: + """Execute SQL query with `name: UpdateFieldNamingMixedParams :exec`. + + ```sql + UPDATE test_field_namings + SET outputs = $2 + WHERE id = $1 AND outputs <> $3::jsonb + ``` + + Args: + conn: + Connection object of type `ConnectionLike` used to execute the query. + id_: int. + outputs: str. + outputs_2: str. + """ + await conn.execute(UPDATE_FIELD_NAMING_MIXED_PARAMS, id_, outputs, outputs_2) + + async def update_result_test_postgres_type(conn: ConnectionLike, *, id_: int) -> str: """Execute and return the result of SQL query with `name: UpdateResultTestPostgresType :execresult`. diff --git a/test/driver_asyncpg/msgspec/classes/__init__.py b/test/driver_asyncpg/msgspec/classes/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_asyncpg/msgspec/classes/__init__.py +++ b/test/driver_asyncpg/msgspec/classes/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_asyncpg/msgspec/classes/models.py b/test/driver_asyncpg/msgspec/classes/models.py index ec0755b..fe20f27 100644 --- a/test/driver_asyncpg/msgspec/classes/models.py +++ b/test/driver_asyncpg/msgspec/classes/models.py @@ -1,11 +1,12 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations __all__: collections.abc.Sequence[str] = ( + "TestFieldNaming", "TestInnerPostgresType", "TestPostgresType", "TestTypeOverride", @@ -22,6 +23,20 @@ import uuid +class TestFieldNaming(msgspec.Struct): + """Model representing TestFieldNaming. + + Attributes: + id -- int + outputs -- str + groups -- collections.abc.Sequence[str] + """ + + id: int + outputs: str + groups: collections.abc.Sequence[str] + + class TestInnerPostgresType(msgspec.Struct): """Model representing TestInnerPostgresType. diff --git a/test/driver_asyncpg/msgspec/classes/queries.py b/test/driver_asyncpg/msgspec/classes/queries.py index 5e86502..8da72a8 100644 --- a/test/driver_asyncpg/msgspec/classes/queries.py +++ b/test/driver_asyncpg/msgspec/classes/queries.py @@ -1,13 +1,14 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations __all__: collections.abc.Sequence[str] = ( "GetAllEmbeddedTestPostgresTypeRow", "GetEmbeddedTestPostgresTypeRow", + "GetFieldNamingDuplicateColumnsRow", "Queries", "QueryResults", "TestCopyFromParams", @@ -26,7 +27,7 @@ import decimal import uuid - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | uuid.UUID | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | uuid.UUID | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None ConnectionLike: typing.TypeAlias = asyncpg.Connection[asyncpg.Record] | asyncpg.pool.PoolConnectionProxy[asyncpg.Record] @@ -127,6 +128,18 @@ class GetEmbeddedTestPostgresTypeRow(msgspec.Struct): test_inner_postgres_type: models.TestInnerPostgresType +class GetFieldNamingDuplicateColumnsRow(msgspec.Struct): + """Model representing GetFieldNamingDuplicateColumnsRow. + + Attributes: + outputs -- str + outputs_2 -- str + """ + + outputs: str + outputs_2: str + + class TestCopyFromParams(msgspec.Struct): """Model representing TestCopyFromParams. @@ -369,6 +382,19 @@ class TestCopyFromParams(msgspec.Struct): WHERE test_postgres_types.id = $1 """ +GET_FIELD_NAMING: typing.Final[str] = """-- name: GetFieldNaming :one +SELECT id, outputs, groups +FROM test_field_namings +WHERE id = $1 LIMIT 1 +""" + +GET_FIELD_NAMING_DUPLICATE_COLUMNS: typing.Final[str] = """-- name: GetFieldNamingDuplicateColumns :one +SELECT a.outputs, b.outputs +FROM test_field_namings a +JOIN test_field_namings b ON a.id = b.id +WHERE a.id = $1 LIMIT 1 +""" + GET_MANY_TEST_BYTEA_POSTGRES_TYPE: typing.Final[str] = """-- name: GetManyTestByteaPostgresType :many SELECT bytea_test FROM test_postgres_types @@ -445,6 +471,12 @@ class TestCopyFromParams(msgspec.Struct): VALUES ($1, $2, $3) """ +UPDATE_FIELD_NAMING_MIXED_PARAMS: typing.Final[str] = """-- name: UpdateFieldNamingMixedParams :exec +UPDATE test_field_namings +SET outputs = $2 +WHERE id = $1 AND outputs <> $3::jsonb +""" + UPDATE_RESULT_TEST_POSTGRES_TYPE: typing.Final[str] = """-- name: UpdateResultTestPostgresType :execresult UPDATE test_postgres_types SET serial_test = 187 @@ -1043,6 +1075,47 @@ async def get_embedded_test_postgres_type(self, *, id_: int) -> GetEmbeddedTestP return None return GetEmbeddedTestPostgresTypeRow(id=row[0], serial_test=row[1], serial4_test=row[2], bigserial_test=row[3], smallserial_test=row[4], int_test=row[5], bigint_test=row[6], smallint_test=row[7], float_test=row[8], double_precision_test=row[9], real_test=row[10], numeric_test=row[11], money_test=row[12], bool_test=row[13], json_test=row[14], jsonb_test=row[15], bytea_test=memoryview(row[16]), date_test=row[17], time_test=row[18], timetz_test=row[19], timestamp_test=row[20], timestamptz_test=row[21], interval_test=row[22], text_test=row[23], varchar_test=row[24], bpchar_test=row[25], char_test=row[26], citext_test=row[27], uuid_test=row[28], inet_test=str(row[29]), cidr_test=str(row[30]), macaddr_test=row[31], macaddr8_test=row[32], ltree_test=row[33], lquery_test=row[34], ltxtquery_test=row[35], test_inner_postgres_type=models.TestInnerPostgresType(table_id=row[36], serial_test=row[37], serial4_test=row[38], bigserial_test=row[39], smallserial_test=row[40], int_test=row[41], bigint_test=row[42], smallint_test=row[43], float_test=row[44], double_precision_test=row[45], real_test=row[46], numeric_test=row[47], money_test=row[48], bool_test=row[49], json_test=row[50], jsonb_test=row[51], bytea_test=memoryview(row[52]) if row[52] is not None else None, date_test=row[53], time_test=row[54], timetz_test=row[55], timestamp_test=row[56], timestamptz_test=row[57], interval_test=row[58], text_test=row[59], varchar_test=row[60], bpchar_test=row[61], char_test=row[62], citext_test=row[63], uuid_test=row[64], inet_test=str(row[65]) if row[65] is not None else None, cidr_test=str(row[66]) if row[66] is not None else None, macaddr_test=row[67], macaddr8_test=row[68], ltree_test=row[69], lquery_test=row[70], ltxtquery_test=row[71])) + async def get_field_naming(self, *, id_: int) -> models.TestFieldNaming | None: + """Fetch one from the db using the SQL query with `name: GetFieldNaming :one`. + + ```sql + SELECT id, outputs, groups + FROM test_field_namings + WHERE id = $1 LIMIT 1 + ``` + + Arguments: + id_ -- int. + + Returns: + models.TestFieldNaming -- Result fetched from the db. Will be `None` if not found. + """ + row = await self._conn.fetchrow(GET_FIELD_NAMING, id_) + if row is None: + return None + return models.TestFieldNaming(id=row[0], outputs=row[1], groups=row[2]) + + async def get_field_naming_duplicate_columns(self, *, id_: int) -> GetFieldNamingDuplicateColumnsRow | None: + """Fetch one from the db using the SQL query with `name: GetFieldNamingDuplicateColumns :one`. + + ```sql + SELECT a.outputs, b.outputs + FROM test_field_namings a + JOIN test_field_namings b ON a.id = b.id + WHERE a.id = $1 LIMIT 1 + ``` + + Arguments: + id_ -- int. + + Returns: + GetFieldNamingDuplicateColumnsRow -- Result fetched from the db. Will be `None` if not found. + """ + row = await self._conn.fetchrow(GET_FIELD_NAMING_DUPLICATE_COLUMNS, id_) + if row is None: + return None + return GetFieldNamingDuplicateColumnsRow(outputs=row[0], outputs_2=row[1]) + def get_many_test_bytea_postgres_type(self, *, id_: int) -> QueryResults[memoryview]: """Fetch many from the db using the SQL query with `name: GetManyTestByteaPostgresType :many`. @@ -1296,6 +1369,22 @@ async def test_copy_from(self, *, params: collections.abc.Sequence[TestCopyFromP r = await self._conn.copy_records_to_table("test_copy_from", columns=["id", "float_test", "int_test"], records=records) return int(n) if (p := r.split()) and (n := p[-1]).isdigit() else 0 + async def update_field_naming_mixed_params(self, *, id_: int, outputs: str, outputs_2: str) -> None: + """Execute SQL query with `name: UpdateFieldNamingMixedParams :exec`. + + ```sql + UPDATE test_field_namings + SET outputs = $2 + WHERE id = $1 AND outputs <> $3::jsonb + ``` + + Arguments: + id_ -- int. + outputs -- str. + outputs_2 -- str. + """ + await self._conn.execute(UPDATE_FIELD_NAMING_MIXED_PARAMS, id_, outputs, outputs_2) + async def update_result_test_postgres_type(self, *, id_: int) -> str: """Execute and return the result of SQL query with `name: UpdateResultTestPostgresType :execresult`. diff --git a/test/driver_asyncpg/msgspec/functions/__init__.py b/test/driver_asyncpg/msgspec/functions/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_asyncpg/msgspec/functions/__init__.py +++ b/test/driver_asyncpg/msgspec/functions/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_asyncpg/msgspec/functions/models.py b/test/driver_asyncpg/msgspec/functions/models.py index ec0755b..fe20f27 100644 --- a/test/driver_asyncpg/msgspec/functions/models.py +++ b/test/driver_asyncpg/msgspec/functions/models.py @@ -1,11 +1,12 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations __all__: collections.abc.Sequence[str] = ( + "TestFieldNaming", "TestInnerPostgresType", "TestPostgresType", "TestTypeOverride", @@ -22,6 +23,20 @@ import uuid +class TestFieldNaming(msgspec.Struct): + """Model representing TestFieldNaming. + + Attributes: + id -- int + outputs -- str + groups -- collections.abc.Sequence[str] + """ + + id: int + outputs: str + groups: collections.abc.Sequence[str] + + class TestInnerPostgresType(msgspec.Struct): """Model representing TestInnerPostgresType. diff --git a/test/driver_asyncpg/msgspec/functions/queries.py b/test/driver_asyncpg/msgspec/functions/queries.py index 57d85bd..f65999e 100644 --- a/test/driver_asyncpg/msgspec/functions/queries.py +++ b/test/driver_asyncpg/msgspec/functions/queries.py @@ -1,13 +1,14 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations __all__: collections.abc.Sequence[str] = ( "GetAllEmbeddedTestPostgresTypeRow", "GetEmbeddedTestPostgresTypeRow", + "GetFieldNamingDuplicateColumnsRow", "QueryResults", "TestCopyFromParams", "create_one_test_postgres_inner_type", @@ -22,6 +23,8 @@ "delete_type_override", "get_all_embedded_test_postgres_type", "get_embedded_test_postgres_type", + "get_field_naming", + "get_field_naming_duplicate_columns", "get_many_test_bytea_postgres_type", "get_many_test_iterator_postgres_type", "get_many_test_postgres_type", @@ -36,6 +39,7 @@ "get_one_type_override", "insert_type_override", "test_copy_from", + "update_field_naming_mixed_params", "update_result_test_postgres_type", "update_rows_test_postgres_type", ) @@ -53,7 +57,7 @@ import decimal import uuid - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | uuid.UUID | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | uuid.UUID | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None ConnectionLike: typing.TypeAlias = asyncpg.Connection[asyncpg.Record] | asyncpg.pool.PoolConnectionProxy[asyncpg.Record] @@ -154,6 +158,18 @@ class GetEmbeddedTestPostgresTypeRow(msgspec.Struct): test_inner_postgres_type: models.TestInnerPostgresType +class GetFieldNamingDuplicateColumnsRow(msgspec.Struct): + """Model representing GetFieldNamingDuplicateColumnsRow. + + Attributes: + outputs -- str + outputs_2 -- str + """ + + outputs: str + outputs_2: str + + class TestCopyFromParams(msgspec.Struct): """Model representing TestCopyFromParams. @@ -396,6 +412,19 @@ class TestCopyFromParams(msgspec.Struct): WHERE test_postgres_types.id = $1 """ +GET_FIELD_NAMING: typing.Final[str] = """-- name: GetFieldNaming :one +SELECT id, outputs, groups +FROM test_field_namings +WHERE id = $1 LIMIT 1 +""" + +GET_FIELD_NAMING_DUPLICATE_COLUMNS: typing.Final[str] = """-- name: GetFieldNamingDuplicateColumns :one +SELECT a.outputs, b.outputs +FROM test_field_namings a +JOIN test_field_namings b ON a.id = b.id +WHERE a.id = $1 LIMIT 1 +""" + GET_MANY_TEST_BYTEA_POSTGRES_TYPE: typing.Final[str] = """-- name: GetManyTestByteaPostgresType :many SELECT bytea_test FROM test_postgres_types @@ -472,6 +501,12 @@ class TestCopyFromParams(msgspec.Struct): VALUES ($1, $2, $3) """ +UPDATE_FIELD_NAMING_MIXED_PARAMS: typing.Final[str] = """-- name: UpdateFieldNamingMixedParams :exec +UPDATE test_field_namings +SET outputs = $2 +WHERE id = $1 AND outputs <> $3::jsonb +""" + UPDATE_RESULT_TEST_POSTGRES_TYPE: typing.Final[str] = """-- name: UpdateResultTestPostgresType :execresult UPDATE test_postgres_types SET serial_test = 187 @@ -1074,6 +1109,51 @@ async def get_embedded_test_postgres_type(conn: ConnectionLike, *, id_: int) -> return GetEmbeddedTestPostgresTypeRow(id=row[0], serial_test=row[1], serial4_test=row[2], bigserial_test=row[3], smallserial_test=row[4], int_test=row[5], bigint_test=row[6], smallint_test=row[7], float_test=row[8], double_precision_test=row[9], real_test=row[10], numeric_test=row[11], money_test=row[12], bool_test=row[13], json_test=row[14], jsonb_test=row[15], bytea_test=memoryview(row[16]), date_test=row[17], time_test=row[18], timetz_test=row[19], timestamp_test=row[20], timestamptz_test=row[21], interval_test=row[22], text_test=row[23], varchar_test=row[24], bpchar_test=row[25], char_test=row[26], citext_test=row[27], uuid_test=row[28], inet_test=str(row[29]), cidr_test=str(row[30]), macaddr_test=row[31], macaddr8_test=row[32], ltree_test=row[33], lquery_test=row[34], ltxtquery_test=row[35], test_inner_postgres_type=models.TestInnerPostgresType(table_id=row[36], serial_test=row[37], serial4_test=row[38], bigserial_test=row[39], smallserial_test=row[40], int_test=row[41], bigint_test=row[42], smallint_test=row[43], float_test=row[44], double_precision_test=row[45], real_test=row[46], numeric_test=row[47], money_test=row[48], bool_test=row[49], json_test=row[50], jsonb_test=row[51], bytea_test=memoryview(row[52]) if row[52] is not None else None, date_test=row[53], time_test=row[54], timetz_test=row[55], timestamp_test=row[56], timestamptz_test=row[57], interval_test=row[58], text_test=row[59], varchar_test=row[60], bpchar_test=row[61], char_test=row[62], citext_test=row[63], uuid_test=row[64], inet_test=str(row[65]) if row[65] is not None else None, cidr_test=str(row[66]) if row[66] is not None else None, macaddr_test=row[67], macaddr8_test=row[68], ltree_test=row[69], lquery_test=row[70], ltxtquery_test=row[71])) +async def get_field_naming(conn: ConnectionLike, *, id_: int) -> models.TestFieldNaming | None: + """Fetch one from the db using the SQL query with `name: GetFieldNaming :one`. + + ```sql + SELECT id, outputs, groups + FROM test_field_namings + WHERE id = $1 LIMIT 1 + ``` + + Arguments: + conn -- Connection object of type `ConnectionLike` used to execute the query. + id_ -- int. + + Returns: + models.TestFieldNaming -- Result fetched from the db. Will be `None` if not found. + """ + row = await conn.fetchrow(GET_FIELD_NAMING, id_) + if row is None: + return None + return models.TestFieldNaming(id=row[0], outputs=row[1], groups=row[2]) + + +async def get_field_naming_duplicate_columns(conn: ConnectionLike, *, id_: int) -> GetFieldNamingDuplicateColumnsRow | None: + """Fetch one from the db using the SQL query with `name: GetFieldNamingDuplicateColumns :one`. + + ```sql + SELECT a.outputs, b.outputs + FROM test_field_namings a + JOIN test_field_namings b ON a.id = b.id + WHERE a.id = $1 LIMIT 1 + ``` + + Arguments: + conn -- Connection object of type `ConnectionLike` used to execute the query. + id_ -- int. + + Returns: + GetFieldNamingDuplicateColumnsRow -- Result fetched from the db. Will be `None` if not found. + """ + row = await conn.fetchrow(GET_FIELD_NAMING_DUPLICATE_COLUMNS, id_) + if row is None: + return None + return GetFieldNamingDuplicateColumnsRow(outputs=row[0], outputs_2=row[1]) + + def get_many_test_bytea_postgres_type(conn: ConnectionLike, *, id_: int) -> QueryResults[memoryview]: """Fetch many from the db using the SQL query with `name: GetManyTestByteaPostgresType :many`. @@ -1355,6 +1435,24 @@ async def test_copy_from(conn: ConnectionLike, *, params: collections.abc.Sequen return int(n) if (p := r.split()) and (n := p[-1]).isdigit() else 0 +async def update_field_naming_mixed_params(conn: ConnectionLike, *, id_: int, outputs: str, outputs_2: str) -> None: + """Execute SQL query with `name: UpdateFieldNamingMixedParams :exec`. + + ```sql + UPDATE test_field_namings + SET outputs = $2 + WHERE id = $1 AND outputs <> $3::jsonb + ``` + + Arguments: + conn -- Connection object of type `ConnectionLike` used to execute the query. + id_ -- int. + outputs -- str. + outputs_2 -- str. + """ + await conn.execute(UPDATE_FIELD_NAMING_MIXED_PARAMS, id_, outputs, outputs_2) + + async def update_result_test_postgres_type(conn: ConnectionLike, *, id_: int) -> str: """Execute and return the result of SQL query with `name: UpdateResultTestPostgresType :execresult`. diff --git a/test/driver_asyncpg/queries.sql b/test/driver_asyncpg/queries.sql index c90a8da..5c353c0 100644 --- a/test/driver_asyncpg/queries.sql +++ b/test/driver_asyncpg/queries.sql @@ -288,3 +288,19 @@ SELECT text_test FROM test_type_override WHERE test_type_override.id = $1; DELETE FROM test_type_override WHERE test_type_override.id = $1; + +-- name: GetFieldNaming :one +SELECT * +FROM test_field_namings +WHERE id = $1 LIMIT 1; + +-- name: GetFieldNamingDuplicateColumns :one +SELECT a.outputs, b.outputs +FROM test_field_namings a +JOIN test_field_namings b ON a.id = b.id +WHERE a.id = $1 LIMIT 1; + +-- name: UpdateFieldNamingMixedParams :exec +UPDATE test_field_namings +SET outputs = $2 +WHERE id = $1 AND outputs <> sqlc.arg(outputs)::jsonb; diff --git a/test/driver_asyncpg/schema.sql b/test/driver_asyncpg/schema.sql index a25d999..e303750 100644 --- a/test/driver_asyncpg/schema.sql +++ b/test/driver_asyncpg/schema.sql @@ -136,4 +136,11 @@ CREATE TABLE IF NOT EXISTS test_type_override ( id integer PRIMARY KEY NOT NULL, text_test text -); \ No newline at end of file +); +-- Plural column names: generated fields must not be singularized. +CREATE TABLE IF NOT EXISTS test_field_namings +( + id int PRIMARY KEY NOT NULL, + outputs jsonb NOT NULL, + groups text[] NOT NULL +); diff --git a/test/driver_asyncpg/sqlc-gen-better-python.wasm b/test/driver_asyncpg/sqlc-gen-better-python.wasm index 56caaa4..1088cd1 100644 Binary files a/test/driver_asyncpg/sqlc-gen-better-python.wasm and b/test/driver_asyncpg/sqlc-gen-better-python.wasm differ diff --git a/test/driver_asyncpg/sqlc.yaml b/test/driver_asyncpg/sqlc.yaml index 90e1aee..1ecd8fe 100644 --- a/test/driver_asyncpg/sqlc.yaml +++ b/test/driver_asyncpg/sqlc.yaml @@ -3,7 +3,7 @@ plugins: - name: python wasm: url: file://sqlc-gen-better-python.wasm - sha256: ee7bd0c07b784b80ea8c5853d9a6a04c51a7abbfd2663f470e9a5d2f623b967e + sha256: 53c4de16a585391d2ff2a545b12d04bce82b6e194873042706d471d343f2bbc2 sql: - schema: schema.sql queries: queries.sql diff --git a/test/driver_sqlite3/attrs/classes/__init__.py b/test/driver_sqlite3/attrs/classes/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_sqlite3/attrs/classes/__init__.py +++ b/test/driver_sqlite3/attrs/classes/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_sqlite3/attrs/classes/models.py b/test/driver_sqlite3/attrs/classes/models.py index 36327a6..0a7057f 100644 --- a/test/driver_sqlite3/attrs/classes/models.py +++ b/test/driver_sqlite3/attrs/classes/models.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations diff --git a/test/driver_sqlite3/attrs/classes/queries.py b/test/driver_sqlite3/attrs/classes/queries.py index d2f624c..f72822c 100644 --- a/test/driver_sqlite3/attrs/classes/queries.py +++ b/test/driver_sqlite3/attrs/classes/queries.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations @@ -21,7 +21,7 @@ if typing.TYPE_CHECKING: import collections.abc - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None from test.driver_sqlite3.attrs.classes import models diff --git a/test/driver_sqlite3/attrs/functions/__init__.py b/test/driver_sqlite3/attrs/functions/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_sqlite3/attrs/functions/__init__.py +++ b/test/driver_sqlite3/attrs/functions/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_sqlite3/attrs/functions/models.py b/test/driver_sqlite3/attrs/functions/models.py index 36327a6..0a7057f 100644 --- a/test/driver_sqlite3/attrs/functions/models.py +++ b/test/driver_sqlite3/attrs/functions/models.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations diff --git a/test/driver_sqlite3/attrs/functions/queries.py b/test/driver_sqlite3/attrs/functions/queries.py index 658aa92..29c538e 100644 --- a/test/driver_sqlite3/attrs/functions/queries.py +++ b/test/driver_sqlite3/attrs/functions/queries.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations @@ -58,7 +58,7 @@ if typing.TYPE_CHECKING: import collections.abc - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None from test.driver_sqlite3.attrs.functions import models diff --git a/test/driver_sqlite3/dataclass/classes/__init__.py b/test/driver_sqlite3/dataclass/classes/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_sqlite3/dataclass/classes/__init__.py +++ b/test/driver_sqlite3/dataclass/classes/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_sqlite3/dataclass/classes/models.py b/test/driver_sqlite3/dataclass/classes/models.py index 086490f..46bbf22 100644 --- a/test/driver_sqlite3/dataclass/classes/models.py +++ b/test/driver_sqlite3/dataclass/classes/models.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations diff --git a/test/driver_sqlite3/dataclass/classes/queries.py b/test/driver_sqlite3/dataclass/classes/queries.py index fe53d24..a500c27 100644 --- a/test/driver_sqlite3/dataclass/classes/queries.py +++ b/test/driver_sqlite3/dataclass/classes/queries.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations @@ -20,7 +20,7 @@ if typing.TYPE_CHECKING: import collections.abc - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None from test.driver_sqlite3.dataclass.classes import models diff --git a/test/driver_sqlite3/dataclass/functions/__init__.py b/test/driver_sqlite3/dataclass/functions/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_sqlite3/dataclass/functions/__init__.py +++ b/test/driver_sqlite3/dataclass/functions/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_sqlite3/dataclass/functions/models.py b/test/driver_sqlite3/dataclass/functions/models.py index 086490f..46bbf22 100644 --- a/test/driver_sqlite3/dataclass/functions/models.py +++ b/test/driver_sqlite3/dataclass/functions/models.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations diff --git a/test/driver_sqlite3/dataclass/functions/queries.py b/test/driver_sqlite3/dataclass/functions/queries.py index 2b63420..669149f 100644 --- a/test/driver_sqlite3/dataclass/functions/queries.py +++ b/test/driver_sqlite3/dataclass/functions/queries.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations @@ -58,7 +58,7 @@ if typing.TYPE_CHECKING: import collections.abc - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None from test.driver_sqlite3.dataclass.functions import models diff --git a/test/driver_sqlite3/msgspec/classes/__init__.py b/test/driver_sqlite3/msgspec/classes/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_sqlite3/msgspec/classes/__init__.py +++ b/test/driver_sqlite3/msgspec/classes/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_sqlite3/msgspec/classes/models.py b/test/driver_sqlite3/msgspec/classes/models.py index 0819a9c..36e4a60 100644 --- a/test/driver_sqlite3/msgspec/classes/models.py +++ b/test/driver_sqlite3/msgspec/classes/models.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations diff --git a/test/driver_sqlite3/msgspec/classes/queries.py b/test/driver_sqlite3/msgspec/classes/queries.py index c1099fe..3697b4b 100644 --- a/test/driver_sqlite3/msgspec/classes/queries.py +++ b/test/driver_sqlite3/msgspec/classes/queries.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations @@ -20,7 +20,7 @@ if typing.TYPE_CHECKING: import collections.abc - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None from test.driver_sqlite3.msgspec.classes import models diff --git a/test/driver_sqlite3/msgspec/functions/__init__.py b/test/driver_sqlite3/msgspec/functions/__init__.py index ea6558f..e52a894 100644 --- a/test/driver_sqlite3/msgspec/functions/__init__.py +++ b/test/driver_sqlite3/msgspec/functions/__init__.py @@ -1,5 +1,5 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Package containing queries and models automatically generated using sqlc-gen-better-python.""" diff --git a/test/driver_sqlite3/msgspec/functions/models.py b/test/driver_sqlite3/msgspec/functions/models.py index 0819a9c..36e4a60 100644 --- a/test/driver_sqlite3/msgspec/functions/models.py +++ b/test/driver_sqlite3/msgspec/functions/models.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing models.""" from __future__ import annotations diff --git a/test/driver_sqlite3/msgspec/functions/queries.py b/test/driver_sqlite3/msgspec/functions/queries.py index 4d846e1..5799f1e 100644 --- a/test/driver_sqlite3/msgspec/functions/queries.py +++ b/test/driver_sqlite3/msgspec/functions/queries.py @@ -1,7 +1,7 @@ # Code generated by sqlc. DO NOT EDIT. # versions: -# sqlc v1.30.0 -# sqlc-gen-better-python v0.4.4 +# sqlc v1.31.1 +# sqlc-gen-better-python v0.4.5 """Module containing queries from file queries.sql.""" from __future__ import annotations @@ -58,7 +58,7 @@ if typing.TYPE_CHECKING: import collections.abc - QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | None + QueryResultsArgsType: typing.TypeAlias = int | float | str | memoryview | decimal.Decimal | datetime.date | datetime.time | datetime.datetime | datetime.timedelta | collections.abc.Sequence[typing.Any] | None from test.driver_sqlite3.msgspec.functions import models diff --git a/test/driver_sqlite3/sqlc-gen-better-python.wasm b/test/driver_sqlite3/sqlc-gen-better-python.wasm index 56caaa4..1088cd1 100644 Binary files a/test/driver_sqlite3/sqlc-gen-better-python.wasm and b/test/driver_sqlite3/sqlc-gen-better-python.wasm differ diff --git a/test/driver_sqlite3/sqlc.yaml b/test/driver_sqlite3/sqlc.yaml index 25560b7..1d06096 100644 --- a/test/driver_sqlite3/sqlc.yaml +++ b/test/driver_sqlite3/sqlc.yaml @@ -3,7 +3,7 @@ plugins: - name: python wasm: url: file://sqlc-gen-better-python.wasm - sha256: ee7bd0c07b784b80ea8c5853d9a6a04c51a7abbfd2663f470e9a5d2f623b967e + sha256: 53c4de16a585391d2ff2a545b12d04bce82b6e194873042706d471d343f2bbc2 sql: - schema: schema.sql queries: queries.sql