Repository navigation
Releases: Grandbusta/jone
Release list
🎉 Jone v0.4.0
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), andCrossJoin- Two ON forms —
Join(table, left, right)for equality,Join(table, left, op, right)for anything else — plusJoinRawfor compound conditions with?-bound args - Qualified identifiers everywhere:
users.idnow quotes as"users"."id"in every clause, andusers.*works in column lists - Table aliasing with
"orders as o"in joins andFrom()— 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" > $1Aggregations & Grouping
Count(),Sum(),Avg(),Min(),Max()— single-value queries honoring your WHERE conditionsGroupBy/GroupByRawand the full HAVING family:Having,HavingRaw,HavingIn/HavingNotIn,HavingNull/HavingNotNull,HavingBetween/HavingNotBetween,HavingExists/HavingNotExistsDistinct()and PostgreSQL'sDistinctOn()(capability-checked — a clear error on MySQL, not broken SQL)All()— every matching row as[]map[string]any, no*sql.Rowsboilerplate
Subqueries: Derived Tables, CTEs, Unions
- Name any builder with
As("t")and select from it:From(sub)compilesFROM (SELECT ...) AS "t" With(name, subquery)/WithRecursive(...)for common table expressions — builder or raw SQL bodiesUnion/UnionAllwith other builders or raw queries;OrderBy/Limitapply 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()withSkipLocked()/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:
WhereNotfor negated conditions and groups (NOT "col" = $1,NOT (...))WhereBetween/WhereNotBetweenWhereExists/WhereNotExistswith builder or raw subqueriesWhereLike/WhereILike— case sensitivity handled per dialect (PGLIKE/ILIKE, MySQLLIKE BINARY/LIKE)Orvariants 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 / DecrementRaw Queries, Truncate, WithSchema
db.RawQuery("SELECT * FROM users WHERE age > ?", 21).All()— raw SQL with rows back as maps;?rebinds to$non 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), orUpdate(table, column, value)- Custom dialects:
SelectSQLnow takes a singleSubSelectstruct, and theDialectinterface gainedAggregateSQL,RawSQL,TruncateSQL,SupportsDistinctOn, andSupportsFullOuterJoin QuoteIdentifiertreats dots as qualification —users.idquotes as two identifiers now
📦 Installation
go install github.com/Grandbusta/jone/cmd/jone@v0.4.0v0.3.0 — Query Builder
🎉 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 initnow generates a ready-to-useDBinstance in yourjonefile.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 (usingdbtags 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 NOTHINGon PostgreSQL,INSERT IGNOREon MySQL) - SELECT with column selection, ordering, pagination, and
First()for fetching a single row as amap[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, andWhereRawas the raw-SQL escape hatch (?placeholders are rebound to$non PostgreSQL automatically) - Condition groups: pass a func to
Where/OrWherefor 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;OrderByRawfor 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()withresult.LastInsertId()
Transactions
db.Transaction(func(tx *jone.Schema) error { ... })— automatically commits on nil return, rolls back on errordb.Begin()returns aTxSchemafor manualCommit()/Rollback()control- All query methods work inside transactions
Raw Expressions
jone.Raw("gen_random_uuid()")inlines any SQL expression where a value is expectedjone.Fn.Now()shorthand forCURRENT_TIMESTAMP
⚠️ Breaking Changes
jone.NewSchema()is renamed tojone.New()— update yourjonefile.go(or re-runjone initin a fresh project to see the new template)
📦 Installation
go install github.com/Grandbusta/jone/cmd/jone@v0.3.0v0.2.0 - MySQL Support & Improved Error Handling
🎉 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=utf8mb4for all table creation - MySQL-compatible
MODIFY COLUMNfor nullability changes
Connection Pooling
- Configure
MaxOpenConns,MaxIdleConns,ConnMaxLifetime, andConnMaxIdleTime - Leverages Go's built-in
database/sqlconnection 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
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
- Column types:
-
CLI Commands
jone init— Initialize projectjone migrate:make— Create new migrationjone migrate:latest— Run all pending migrationsjone migrate:up/down— Run/rollback single migrationjone migrate:rollback— Rollback last batchjone migrate:list— View migration statusjone version— Display version (-vflag)
-
Additional Features
--dry-runflag to preview SQL without executings.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