Marten 1.0.0 release notes
Under development.
Requirements and compatibility
- Crystal: 1.20, 1.21, and 1.22.
- Databases:
- MariaDB 10.11 and higher.
- MySQL 8.4 and higher.
- PostgreSQL 15 and higher.
- SQLite 3.37.0 and higher.
New features
Schemas
Marten::Core::Validation::ErrorandMarten::Core::Validation::ErrorSetcan now be serialized to JSON. An error set becomes a list of objects withfield,type, andmessage, andfieldisnullfor global errors. Schema and model validation errors can therefore be returned from a JSON response through the#jsonhandler helper. See Serializing errors as JSON.
Models and databases
- Query sets now provide a
#each_batchmethod, allowing to iterate over large query sets in batches without loading all the matching records into memory at once. Records are fetched in batches using a primary key cursor and are always processed in ascending primary key order. - Models and query sets now support pessimistic row locking via
SELECT ... FOR UPDATE. Query sets provide a#lockmethod, while model records provide#lock!and#with_lock. See Pessimistic locking for more details. - Multi-database projects can now define pluggable database routers via the
database_routerssetting. Routers resolve which database to use for reads and writes, gate cross-database relations, and control which migrations apply to a given database. Model instances also remember the database they were loaded from or saved to when an explicit#usingselection is used.
Development
- The
servemanagement command now displays how long project compilation took after each successful build. - The
newcommand now writes anAGENTS.mdfile when creating a project. The file records the Marten version, links to the matching guides and API, and describes the project layout, generators, requires, migrations, CSRF, and specs, so coding agents can work in the generated project. Projects created with--edgelink to the in-development guides. - The in-development guides are published as a single file at
/docs/llms-full.txt, next to the guide index at/docs/llms.txt. - The
newcommand prints its usage and exits with status 1 whentypeornameis omitted and stdin is not a terminal, instead of waiting for prompts. Passing both arguments still runs without prompts.
Backward incompatible changes
Handlers and HTTP
- The default value of the
trailing_slashsetting is now:remove, so unresolved URLs ending with a trailing slash are permanently redirected to their slashless version by default. Applications that want to keep the previous behavior should explicitly setconfig.trailing_slash = :do_nothing.