Skip to content

v0.9.0

Latest

Choose a tag to compare

@github-actions github-actions released this 16 Aug 16:00
· 69 commits to main since this release
1921a0d

Note

Releases before v1.0.0 are beta releases: options and generated output may still change between minor versions. Everything that ships is tested against real databases and already used in production.

v0.9.0 - 2026-08-16

Added

  • #248 MySQL support: the new sql_driver values asyncmy and pymysql generate code for asyncmy (asyncio) and PyMySQL (synchronous), using engine: "mysql" and the same ? placeholders as the SQLite drivers - the plugin rewrites them to the drivers' pyformat %s at generation time. Inline ENUM (and SET) columns generate enums.py classes, tinyint(1) maps to bool, time to datetime.timedelta, and returned json columns stay str like on every other driver. :execlastid returns cursor.lastrowid (None when nothing was inserted); :copyfrom stays PostgreSQL-only. Reused parameters (sqlc.arg or sqlc.slice used at several sites) merge into one function argument even though MySQL binds every occurrence separately. (Rayakame)

Fixed

  • #248 With omit_unused_models: true, an enum referenced only through an overridden column no longer breaks generation in either direction: an overridden enum parameter kept its enums.X(...) conversion while the class was filtered away (a NameError at import), and an enum used only by overridden return columns was retained as a dead enums.py nothing imports. (Rayakame)
  • #248 Query modules whose only queries return whole model rows (no :many) no longer import the row's column-type modules (datetime, decimal, ...) into their TYPE_CHECKING block: nothing in such a module spells those types, and ruff flagged the imports as unused on generated output. (Rayakame)
  • #257 Arguments of a reused sqlc.slice are no longer misordered when the query also contains a backtick- or bracket-quoted identifier holding a ? (SQLite family), and a slice whose name contains % now expands correctly on the MySQL drivers - its marker was doubled in the SQL constant but not in the replacement the generated code performs, so the expansion silently matched nothing. (Rayakame)
  • #260 SQLite-family queries that combine a sqlc.slice with a named argument (sqlc.arg, @name, :name) now bind their arguments to the right columns. sqlc numbers every placeholder of such a query (?1, ?2, ...) and assumes the slice marker occupies one slot, but the marker expands to one slot per element, so every index after it named the wrong slot: the query returned wrong rows, or the driver rejected it. The generated SQL constant now carries bare ? placeholders and the arguments are passed in text order, which is correct for any slice length including an empty one. (Rayakame)
  • #262 A backslash in a query now survives into the generated SQL constant. The SQL was written into a plain Python string literal, so Python read every escape it recognised: LIKE 'a\tb' reached the server with a tab, 'C:\name' with a newline, and an escape Python does not know (REGEXP '\d+') raised a SyntaxWarning that is slated to become a SyntaxError. Query text holding a backslash - and the docstring that repeats it - is now emitted as a raw literal. Affects every driver. (Rayakame)
  • #263 A query containing """ no longer produces a module that does not parse. The SQL went into a """ literal, so three consecutive double quotes in the query - from a string literal, or from a quoted identifier ending in a quote - closed the constant early and left the rest of the file as stray syntax. The constant and the docstring now pick a delimiter the query does not contain. A query holding both """ and ''' has no block spelling left: the constant falls back to an escaped one-liner, and the docstring, which cannot be escaped without tripping ruff D301, leaves the SQL out. (Rayakame)
plugins:
  - name: python
    wasm:
      url: https://github.com/rayakame/sqlc-gen-better-python/releases/download/v0.9.0/sqlc-gen-better-python.wasm
      sha256: d1787aa32e61f2e73c81a4f93b3e5a9beeec918952cff3183fb96313057f58a8