Skip to content

v0.1.2-beta - Expression API

Pre-release
Pre-release

Choose a tag to compare

@kolkov kolkov released this 24 Oct 09:47
· 252 commits to main since this release

πŸŽ‰ Expression API Release

Comprehensive Expression API for building fluent, type-safe WHERE clauses in Relica.

✨ Key Features

Expression Types

  • HashExp - Map-based conditions with automatic IN/NULL handling
  • Comparison - Eq, NotEq, GreaterThan, LessThan, GreaterOrEqual, LessOrEqual
  • IN/BETWEEN - In, NotIn, Between, NotBetween with single-value optimization
  • LIKE - Pattern matching with automatic escaping and wildcards
  • Logical - And, Or, Not combinators with proper precedence
  • RawExp - Custom SQL fragments for edge cases

Example

  // Before - string-based WHERE
  db.Builder().
      Select().
      From("users").
      Where("status = ? AND age > ?", 1, 18).
      All(&users)
  // After - Type-safe Expression API
  db.Builder().
      Select().
      From("users").
      Where(relica.And(
          relica.Eq("status", 1),
          relica.GreaterThan("age", 18),
      )).
      All(&users)
  // Mix both styles (backward compatible)
  db.Builder().
      Select().
      From("users").
      Where("status = ?", 1).
      Where(relica.GreaterThan("age", 18)).
      All(&users)

πŸ“Š Quality Metrics

  • βœ… 87.0% test coverage (169 unit tests + 27 integration tests)
  • βœ… golangci-lint: 0 issues
  • βœ… Backward compatible - existing string-based WHERE still works
  • βœ… Zero production dependencies

πŸ”„ Migration

No breaking changes! All existing v0.1.0-beta code works without modifications.

Expression API is optional:

  • Continue using string-based WHERE clauses
  • Mix both styles in the same codebase
  • Gradually migrate for improved type safety and readability

πŸš€ Installation

go get github.com/coregx/relica@v0.1.2-beta

πŸ“š Documentation

πŸ”§ Technical Details

Performance:

  • Zero allocations in hot paths
  • Deterministic SQL generation
  • Same performance as string-based WHERE

Multi-Dialect Support:

  • PostgreSQL: $1, $2 placeholders, "column" quoting
  • MySQL: ?, ? placeholders, column quoting
  • SQLite: ?, ? placeholders, "column" quoting

Requirements:

  • Go 1.25+
  • Databases: PostgreSQL, MySQL, SQLite

Go Version: 1.25+, Status: Beta