Skip to content

v0.9.0: NullStringMap, Composite PK, Functional Expressions

Choose a tag to compare

@kolkov kolkov released this 16 Dec 16:24
· 183 commits to main since this release
a83dfb2

What's New in v0.9.0

🆕 New Features

TASK-016: NullStringMap for Dynamic Scanning

var result relica.NullStringMap
db.Select("*").From("users").Where("id = ?", 1).One(&result)
name := result.String("name")    // empty string if NULL
if !result.IsNull("email") { ... }

TASK-017: Query.Prepare() / Query.Close()

q := db.NewQuery("SELECT * FROM users WHERE status = ?").Prepare()
defer q.Close()
for _, status := range statuses {
    q.Bind(status).All(&users)
}

Composite Primary Key Support

type OrderItem struct {
    OrderID   int `db:"order_id,pk"`
    ProductID int `db:"product_id,pk"`
    Quantity  int `db:"quantity"`
}
db.Model(&item).Insert()  // Works with composite PK
db.Model(&item).Update()  // WHERE order_id=? AND product_id=?

TASK-100: Functional Expressions

relica.Case("status").When("active", 1).Else(0).As("code")
relica.Coalesce("nickname", "first_name", "'Anonymous'")
relica.NullIf("email", "''")
relica.Greatest("price", "sale_price")
relica.Least("price", "discount_price")
relica.Concat("first_name", "' '", "last_name")

📊 Quality Metrics

  • 650+ tests passing
  • 86% coverage
  • 0 linter issues
  • 100% backward compatible

📦 Installation

go get github.com/coregx/relica@v0.9.0

Full Changelog: v0.8.0...v0.9.0