Skip to main content
Version: Next

Marten 0.8.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​

Minor features​

Models and databases​

  • Query sets now provide a #each_batch method, 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 #lock method, 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_routers setting. 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 #using selection is used.
  • Models can now persist raw binary data with the binary field. Values are exposed as Bytes.

Handlers and HTTP​

  • Handlers now support the QUERY HTTP method through #query. QUERY is safe and idempotent, and its request body is available through the request's #data and #body methods. CSRF protection treats QUERY as a safe method. The test client also provides #query to issue these requests.

Schemas​

Templates​

  • A querystring template tag was introduced to build URL-encoded query strings from the current request while adding, replacing, or removing parameters.

Development​

  • The serve management command now displays how long project compilation took after each successful build.
  • The new command now writes an AGENTS.md file 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 --edge link 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 new command prints its usage and exits with status 1 when type or name is 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_slash setting 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 set config.trailing_slash = :do_nothing.
  • #query is now the handler method for the QUERY HTTP method, and QUERY is allowed by default. A handler that already defines #query for another purpose will have that method invoked for incoming QUERY requests. Rename that method if it is not meant to handle the HTTP verb. CSRF protection also treats QUERY as a safe method.