Repository navigation
v0.1.2-beta - Expression API
Pre-release
Pre-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
- https://github.com/coregx/relica#expression-api-v012 - Quick start and examples
- https://github.com/coregx/relica/blob/main/CHANGELOG.md#012-beta---2025-10-24 - Complete release notes
π§ 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,
columnquoting - SQLite: ?, ? placeholders, "column" quoting
Requirements:
- Go 1.25+
- Databases: PostgreSQL, MySQL, SQLite
Go Version: 1.25+, Status: Beta