Skip to content

v0.1.0

Choose a tag to compare

@maxryl maxryl released this 06 Mar 08:53
· 2 commits to master since this release
a844456

Breaking Changes

  • Named parameter maps: All clause methods (Where, OrderBy, Having, InnerJoin, LeftJoin, etc.) now accept ...Params (named map[string]any) instead of positional ...any values. This gives callers explicit control over parameter names and eliminates the implicit positional-to-name mapping.
  • Build() return type: Returns Params (a named map[string]any type) instead of a raw map[string]any.
  • Removed ErrParamMismatch: Replaced by ErrMissingParam (placeholder with no map key) and ErrExtraParam (map key with no placeholder), providing more precise error reporting.

New Features

  • @ parameter prefix support: Named placeholders can now use either :param or @param syntax (but not both in the same query). Mixed prefixes produce ErrMixedPrefix.
  • PostgreSQL :: and @@ escaping: Double-prefix sequences (value::integer, @@session_var) are correctly skipped and not treated as parameters.
  • Multiple param maps per clause: Methods accept variadic Params maps that are merged, e.g. Where("a = :x AND b = :y", Params{"x": 1}, Params{"y": 2}).
  • Params named type: New Params type (map[string]any) used throughout the public API for clarity and type safety.

Bug Fixes

  • Nested/sibling subquery prefix detection: Build() now correctly detects mixed : and @ prefixes across arbitrarily nested subqueries and sibling subqueries, even when intermediate builders have no direct parameters. Previously, mixed prefixes could silently produce malformed SQL.
  • toSnakeCase digit boundaries: Field names containing digits followed by uppercase letters (e.g. Field1Name, V2API, S3Bucket) now correctly produce field1_name, v2_api, s3_bucket instead of field1name, v2api, s3bucket.
  • Embedded struct tag handling: collectColumns now respects tags on embedded (anonymous) struct fields. An embedded struct tagged with db:"-" is skipped, and one tagged with db:"name" is treated as a single column rather than being recursed into.

Internal

  • Defensive copying of caller-provided Params maps to prevent external mutation
  • Bidirectional validation between SQL placeholders and map keys
  • detectPrefix / reconcilePrefix functions for robust prefix tracking during Build()
  • fieldTagName helper extracted for reuse in struct column collection