Skip to content

Releases: Grandbusta/jone

🎉 Jone v0.4.0

Choose a tag to compare

@Grandbusta Grandbusta released this 18 Jul 10:02
f453ec1

The query builder is complete! This release rounds out SELECT with joins, aggregations, grouping, CTEs, unions, derived tables, and row locking — plus a cleaner UPDATE, raw queries, TRUNCATE, and schema-qualified tables.

✨ What's New

Joins

  • Join (INNER), LeftJoin / LeftOuterJoin, RightJoin / RightOuterJoin, FullOuterJoin (PostgreSQL-only, capability-checked), and CrossJoin
  • Two ON forms — Join(table, left, right) for equality, Join(table, left, op, right) for anything else — plus JoinRaw for compound conditions with ?-bound args
  • Qualified identifiers everywhere: users.id now quotes as "users"."id" in every clause, and users.* works in column lists
  • Table aliasing with "orders as o" in joins and From() — self-joins included:
db.Select("users.name", "o.total").From("users").
    Join("orders as o", "users.id", "o.user_id").
    Where("o.total", ">", 100).
    Exec()
// SELECT "users"."name", "o"."total" FROM "users"
//   INNER JOIN "orders" AS "o" ON "users"."id" = "o"."user_id" WHERE "o"."total" > $1

Aggregations & Grouping

  • Count(), Sum(), Avg(), Min(), Max() — single-value queries honoring your WHERE conditions
  • GroupBy / GroupByRaw and the full HAVING family: Having, HavingRaw, HavingIn / HavingNotIn, HavingNull / HavingNotNull, HavingBetween / HavingNotBetween, HavingExists / HavingNotExists
  • Distinct() and PostgreSQL's DistinctOn() (capability-checked — a clear error on MySQL, not broken SQL)
  • All() — every matching row as []map[string]any, no *sql.Rows boilerplate

Subqueries: Derived Tables, CTEs, Unions

  • Name any builder with As("t") and select from it: From(sub) compiles FROM (SELECT ...) AS "t"
  • With(name, subquery) / WithRecursive(...) for common table expressions — builder or raw SQL bodies
  • Union / UnionAll with other builders or raw queries; OrderBy/Limit apply to the combined result
  • Placeholder numbering stays correct through any nesting — CTEs, FROM subqueries, joins, WHERE, HAVING, unions all continue the same sequence
totals := jone.Select("user_id").From("orders").GroupBy("user_id")
db.Select("*").From("totals").With("totals", totals).Exec()
// WITH "totals" AS (SELECT "user_id" FROM "orders" GROUP BY "user_id") SELECT * FROM "totals"

Row Locking

  • ForUpdate() / ForShare() with SkipLocked() / NoWait() — the classic job-queue claim is now one chain:
tx.Select("*").From("jobs").Where("status", "queued").
    OrderBy("created_at").ForUpdate().SkipLocked().First()

More WHERE Conditions

On Select, Update, and Delete — and inside condition groups — each with Or variants:

  • WhereNot for negated conditions and groups (NOT "col" = $1, NOT (...))
  • WhereBetween / WhereNotBetween
  • WhereExists / WhereNotExists with builder or raw subqueries
  • WhereLike / WhereILike — case sensitivity handled per dialect (PG LIKE/ILIKE, MySQL LIKE BINARY/LIKE)
  • Or variants completed for the existing family: OrWhereIn, OrWhereNotIn, OrWhereNull, OrWhereNotNull, OrWhereRaw

UPDATE

Set() is gone — pass the data straight to Update:

db.Update("users", map[string]any{"name": "Alice", "updated_at": jone.Fn.Now()}).Where("id", 1).Exec()
db.Update("users", user).Where("id", 1).Exec()          // struct with `db` tags
db.Update("books", "title", "New Title").Where("id", 42).Exec()  // single pair
db.Update("counters").Increment("views").Exec()          // new: Increment / Decrement

Raw Queries, Truncate, WithSchema

  • db.RawQuery("SELECT * FROM users WHERE age > ?", 21).All() — raw SQL with rows back as maps; ? rebinds to $n on PostgreSQL. (s.Raw() in migrations is unchanged.)
  • db.Truncate("sessions").Exec()
  • WithSchema("analytics") on every builder for schema-qualified tables — on SELECT it covers joined tables too

⚠️ Breaking Changes

  • Set() is removed — pass data directly: Update(table, map), Update(table, struct), or Update(table, column, value)
  • Custom dialects: SelectSQL now takes a single SubSelect struct, and the Dialect interface gained AggregateSQL, RawSQL, TruncateSQL, SupportsDistinctOn, and SupportsFullOuterJoin
  • QuoteIdentifier treats dots as qualification — users.id quotes as two identifiers now

📦 Installation

go install github.com/Grandbusta/jone/cmd/jone@v0.4.0

v0.3.0 — Query Builder

Choose a tag to compare

@Grandbusta Grandbusta released this 13 Jul 12:01
c4343dc

🎉 Jone v0.3.0

The query builder is here! Jone now goes beyond migrations with a fluent, fully parameterized query builder for INSERT, SELECT, UPDATE, and DELETE — plus transactions and PostgreSQL RETURNING support.

✨ What's New

Query Builder

  • jone init now generates a ready-to-use DB instance in your jonefile.go — the connection is lazy and opens automatically on your first query
  • INSERT accepts a map[string]any, []map[string]any, a struct, or a slice of structs (using db tags with snake_case fallback)
  • Multi-row inserts generate a single INSERT INTO ... VALUES (...), (...) statement
  • Conflict handling with OnConflict().Ignore() — no target, column targets, or partial-index expressions (ON CONFLICT DO NOTHING on PostgreSQL, INSERT IGNORE on MySQL)
  • SELECT with column selection, ordering, pagination, and First() for fetching a single row as a map[string]any
  • UPDATE and DELETE with parameterized SET values and WHERE conditions
  • ToSQL() on every builder to inspect the generated SQL and args without executing

Parameterized WHERE Clauses

  • Conditions with bound values — never string interpolation: Where("age", ">", 18), Where("email", v)
  • Full family: OrWhere, WhereIn / WhereNotIn, WhereNull / WhereNotNull, and WhereRaw as the raw-SQL escape hatch (? placeholders are rebound to $n on PostgreSQL automatically)
  • Condition groups: pass a func to Where/OrWhere for parenthesized groups, nestable to any depth:
db.Select("*").From("users").
    Where("active", true).
    Where(func(g *jone.WhereGroup) {
        g.Where("role", "admin").OrWhere("age", ">", 65)
    }).
    Exec()
// WHERE "active" = $1 AND ("role" = $2 OR "age" > $3)
  • Injection-safe OrderBy("created_at", "desc") — columns are quoted and directions validated; OrderByRaw for expressions

RETURNING Support (PostgreSQL)

  • ExecReturning("id", ...) on Insert, Update, and Delete returns the affected rows as []map[string]any
  • Solves LastInsertId() being unsupported by the PostgreSQL driver — get your generated IDs back directly
  • On MySQL, keep using Exec() with result.LastInsertId()

Transactions

  • db.Transaction(func(tx *jone.Schema) error { ... }) — automatically commits on nil return, rolls back on error
  • db.Begin() returns a TxSchema for manual Commit() / Rollback() control
  • All query methods work inside transactions

Raw Expressions

  • jone.Raw("gen_random_uuid()") inlines any SQL expression where a value is expected
  • jone.Fn.Now() shorthand for CURRENT_TIMESTAMP

⚠️ Breaking Changes

  • jone.NewSchema() is renamed to jone.New() — update your jonefile.go (or re-run jone init in a fresh project to see the new template)

📦 Installation

go install github.com/Grandbusta/jone/cmd/jone@v0.3.0

v0.2.0 - MySQL Support & Improved Error Handling

Choose a tag to compare

@Grandbusta Grandbusta released this 31 Jan 18:10

🎉 Jone v0.2.0

Full MySQL support is here! This release adds complete MySQL dialect implementation alongside improved error handling and connection pooling for a better developer experience.

✨ What's New

MySQL Support

  • Full MySQL dialect implementation with all schema operations
  • MySQL-specific data type mappings (TINYINT(1) for boolean, CHAR(36) for UUID, etc.)
  • Index method support (BTREE, HASH, FULLTEXT, SPATIAL)
  • Proper ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 for all table creation
  • MySQL-compatible MODIFY COLUMN for nullability changes

Connection Pooling

  • Configure MaxOpenConns, MaxIdleConns, ConnMaxLifetime, and ConnMaxIdleTime
  • Leverages Go's built-in database/sql connection pool
  • All settings are optional with sensible defaults

Improved Error Handling

  • Schema operations now log and exit on error instead of failing silently
  • Clear, actionable error messages for database failures
  • Errors display immediately when migrations fail

Documentation

  • Updated README with MySQL configuration examples
  • Added connection pooling documentation
  • Added emojis to section headers for better readability
  • Updated database support table

📦 Installation

go install github.com/Grandbusta/jone/cmd/jone@v0.2.0

🚀 v0.1.0 - Initial Release

Choose a tag to compare

@Grandbusta Grandbusta released this 24 Jan 13:41

The first public release of Jone, a Knex-inspired database migration tool for Go.

Features

  • Schema Builder — Fluent API for creating and modifying tables

    • Column types: String, Int, BigInt, Boolean, UUID, Timestamp, JSON, Decimal, and more
    • Modifiers: NotNullable(), Unique(), Default(), Primary()
    • Indexes and foreign keys
  • CLI Commands

    • jone init — Initialize project
    • jone migrate:make — Create new migration
    • jone migrate:latest — Run all pending migrations
    • jone migrate:up/down — Run/rollback single migration
    • jone migrate:rollback — Rollback last batch
    • jone migrate:list — View migration status
    • jone version — Display version (-v flag)
  • Additional Features

    • --dry-run flag to preview SQL without executing
    • s.Raw() for custom SQL statements
    • Colored CLI output
    • Transaction-wrapped migrations with batch tracking

Supported Databases

  • ✅ PostgreSQL

Installation

go install github.com/Grandbusta/jone/cmd/jone@v0.1.0
go get github.com/Grandbusta/jone