Your first query
Write a migration and three annotated queries, generate, and call the result.
53 concepts and 214 runnable examples across 8 engines. Each one is a small program in the Seagull repository: the SQL you write, the Go sgl generates, and the code that calls it.
Start from the SQLite starter that sgl init writes, pick any dialect, and watch the Go appear as you type.
Write a migration and three annotated queries, generate, and call the result.
Each command kind gives a different Go signature; pick the one that matches what the caller needs back.
Seagull names parameters from what they are compared with, and groups two or more into a Params struct.
A column that can be NULL becomes a pointer, and Seagull works that out through joins, COALESCE and aggregates.
How each engine's column types arrive in Go, from integers and decimals to times and UUIDs.
JSON columns and JSON operators, read into the generated JSON type.
Each enum becomes a named Go type with a constant per value; a go_type override maps it to your own Go type instead.
Array and list columns arrive as typed Go slices.
Override a column's Go type in a query, in a migration, or for a whole SQL type in sgl.yaml.
Pass a Go slice where the SQL expects a list.
A filter the caller may leave out, with an optional parameter and the IS NULL idiom.
Let callers choose the sort column and direction from an allow-list, never from raw text.
LIMIT and OFFSET parameters with a default and a maximum, combined into a full search endpoint.
Build WHERE, ORDER BY, LIMIT and COUNT at run time from an allow-list, with every value bound.
Return a joined table as a nested struct, and as a pointer when the join is outer.
Collapse repeated parent rows into one parent with a slice of children using group_by.
Stream rows one at a time with a range-over-func iterator, and stop early.
Make a one query report a missing row with a bool instead of sql.ErrNoRows.
Column types and nullability follow CTEs, recursive CTEs, window functions and views.
Use RETURNING to get the written row back in one round trip.
Insert a row or update the one that is already there, in each engine's own syntax.
Write many rows in one call, chunked under each engine's bind-variable limit.
Run several queries atomically with RunInTx, or bind the queries to a transaction with WithTx.
Send read-only queries to a replica and writes to the primary, decided by Seagull's read-only detection.
Prepare every query once with go.prepared and the generated Prepare.
Name every query in traces and logs with go.query_names and a wrapping DBTX.
Embed the migration files in the binary and apply them when the program starts.
Migrate up to a version, roll back, check status and validate checksums, with locking.
Seed data, keep several migration histories in one database, and run code around each migration.
Define SQL functions in migrations; whether they change data decides whether queries that call them are read-only.
LATERAL joins, DISTINCT ON, full-text search and data-modifying CTEs, all typed.
Create a hypertable and query it with time_bucket, first, last and gap filling.
Define a continuous aggregate, refresh it, and query it with hyperfunctions.
ReplacingMergeTree, SummingMergeTree and AggregatingMergeTree, read with FINAL and PREWHERE.
ARRAY JOIN, Map, Tuple, LowCardinality and IPv4 columns, typed in Go.
Declare ALTER TABLE UPDATE and DELETE as asyncexec so callers know the server queues them.
STRUCT, MAP, LIST and UNION columns as Go types.
QUALIFY, FILTER, PIVOT, macros and read_parquet, with typed results.
INSERT IGNORE, REPLACE INTO, SET columns, GROUP_CONCAT and unsigned integers.
FTS5 and R*Tree virtual tables, json_each and generated columns.
Check queries without generating, read a diagnostic, and look a code up with sgl explain.
Fail the build when generated code is stale, and report diagnostics as GitHub annotations or SARIF.
Print a query's Go signature, dump the schema, and diff it against a live database.
Normalise directives with sgl fmt, require the canonical prefix, and adopt queries written with another tool's prefix.
Create, apply, roll back and inspect migrations and seeds with sgl.
Run Seagull as a library from your own generator, with a --check mode for CI.
Read the analysed queries and the schema catalogue to build your own checks.
Declare a Go function registered with the driver so Seagull can type queries that call it.
Generate with your own directive prefix, header and helper names.
Generate against a database's real schema instead of migration files.
Trace each stage of generation and migration with an observer and slog.
Wrap the database/sql emitter to add a generated file of your own.
Build an sgl with your dialect options and emitter using cli.Main.
No example matches.