Skip to content

feat: typed queries and results - #5

Merged
hpopp merged 3 commits into
mainfrom
feat/typed-returns
Aug 29, 2026
Merged

feat: typed queries and results#5
hpopp merged 3 commits into
mainfrom
feat/typed-returns

Conversation

@hpopp

@hpopp hpopp commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Added

  • execute caches prepared statements per connection, keyed by SQL text and parameter types. The cache holds Config.statement_cache_size statements (default 256) with least-recently-used eviction. Set 0 to turn the cache off. Repeated statements skip the server parse and plan step.
  • A cached statement that a schema change invalidated (SQLSTATE 0A000), or that the server dropped (SQLSTATE 26000), is prepared again and retried once instead of surfacing the error.
  • Value gains opt_bool, opt_int, opt_float, and opt_string constructors that map Option values to SQL NULL, plus as_* and *_or accessors for reading result columns.
  • The params argument of Connection.execute defaults to no parameters, so statements without placeholders need no empty list.

Changed

  • Breaking change Result rows are now typed. QueryResult.rows is List<List<Postgres.Value>> instead of List<List<Option<String>>>. Rows decode from the column type OIDs the server reports. Types without a first-class variant (numeric, timestamps, uuid, json) pass through as Value.String, and SQL NULL decodes to Value.Null.
  • Breaking change Connection.execute takes List<Postgres.Value> parameters instead of List<Option<String>>. The driver declares parameter types in the Parse message (Value.Int as int8, Value.Bool as bool, Value.Float as float8), so most $1::type casts in SQL are no longer needed. Bind SQL NULL with Value.Null.

@hpopp
hpopp merged commit e04e89a into main Aug 29, 2026
3 checks passed
@hpopp
hpopp deleted the feat/typed-returns branch August 29, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant