Skip to content

v0.3.0

Choose a tag to compare

@jirikuncar jirikuncar released this 30 Oct 22:42
· 94 commits to main since this release
Immutable release. Only release title and notes can be modified.
e0ab4cd

sqlty 0.3.0 adds a language server and a VS Code extension, types the parameters of a query, checks queries built in branches, and reads row types without running your code.

pip install -U sqlty   # or: uv add sqlty@latest

Upgrading

  • The type-modules setting is removed. check reads row types from source and never imports a module, not even the standard library or Pydantic, so checking an untrusted pull request is safe. Delete the key; a field whose type cannot be read from source is unknown and never reported (#797)
  • unknown-column is fixable: when one column of the tables in scope is the likely spelling, the message suggests it and sqlty check --fix writes it (#816)
  • sqlty check --output-format json adds the start and end of what a diagnostic underlines and its fix edits (#806)
  • The new rule params-type-mismatch is an error by default. It reports only a P of SQL[R, P] that you wrote, so existing code is unchanged (#794)

Editors

  • sqlty server is a language server for Python files, with the fixes of sqlty check --fix as quick fixes and source.fixAll.sqlty for fix on save (#806, #807, #808)
  • The VS Code extension runs the sqlty your project pins, so the editor reports what CI reports. It is published to the Visual Studio Marketplace and Open VSX with each release (#809, #812, #813)
  • sqlty.breaking.against shows sqlty breaking findings in the editor, forward as you edit and backward when the schema changes (#810)
  • An unknown name is underlined inside the query string (#811)

Typed parameters

  • SQL[R, P] types the parameters of a query next to its rows, and bind(params) checks them on every type checker (#791)
  • param-types = true makes sqlty rewrite and check --fix write P: a tuple, or a generated TypedDict for named parameters. It is off by default because type checkers then reject calls the driver runs (#792)
  • params-type-mismatch reports a P that does not fit its query (#794)

Query variants (preview)

With preview = true, a query built from static values bound in branches is checked along every path instead of being skipped as dynamic-query. max-query-variants (default 64) caps the paths; a query with more is reported and never checked in part (#785)

Row types from source

  • Aliases, string annotations and from __future__ import annotations of row types resolve from source (#789), as do the aliases and NewTypes of helper modules (#793)
  • Standard-library classes resolve from typeshed's class graph (#795), and the public types of pydantic.types and pydantic.networks (EmailStr, AnyUrl, conint(...), Json[T]) from a table checked against Pydantic (#796)

Type inference

  • MySQL's XOR, ^, << and >> group by MySQL 8.4's operator precedence instead of PostgreSQL's (#805)

Full changelog: v0.2.2...v0.3.0