Skip to content

Commit

Permalink
Prepare 0.4.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
ellmetha committed Jan 13, 2024
1 parent 893349e commit 452762c
Show file tree
Hide file tree
Showing 120 changed files with 5,934 additions and 763 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ docs: docs_api docs_site
.PHONY: docs_api
docs_api:
crystal docs --output=docs/static/api/dev
cp -R docs/static/api/dev/ docs/static/api/0.1
cp -R docs/static/api/dev/ docs/static/api/0.2
cp -R docs/static/api/dev/ docs/static/api/0.3
cp -R docs/static/api/dev/ docs/static/api/0.4

.PHONY: docs_site
docs_site:
Expand Down
20 changes: 10 additions & 10 deletions docs/docs/the-marten-project/release-notes/0.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ You can read more about this new kind of model inheritance in [Multi table inher

### Schema handler callbacks

Handlers that inherit from the base schema handler - [`Marten::Handlers::Schema`](pathname:///api/dev/Marten/Handlers/Schema.html) - or one of its subclasses (such as [`Marten::Handlers::RecordCreate`](pathname:///api/dev/Marten/Handlers/RecordCreate.html) or [`Marten::Handlers::RecordUpdate`](pathname:///api/dev/Marten/Handlers/RecordUpdate.html)) can now define new kinds of callbacks that allow to easily manipulate the considered [schema](../../schemas/introduction.md) instance and to define logic to execute before the schema is validated or after (eg. when the schema validation is successful or failed):
Handlers that inherit from the base schema handler - [`Marten::Handlers::Schema`](pathname:///api/0.4/Marten/Handlers/Schema.html) - or one of its subclasses (such as [`Marten::Handlers::RecordCreate`](pathname:///api/0.4/Marten/Handlers/RecordCreate.html) or [`Marten::Handlers::RecordUpdate`](pathname:///api/0.4/Marten/Handlers/RecordUpdate.html)) can now define new kinds of callbacks that allow to easily manipulate the considered [schema](../../schemas/introduction.md) instance and to define logic to execute before the schema is validated or after (eg. when the schema validation is successful or failed):

* [`before_schema_validation`](../../handlers-and-http/callbacks.md#before_schema_validation)
* [`after_schema_validation`](../../handlers-and-http/callbacks.md#after_schema_validation)
Expand Down Expand Up @@ -116,25 +116,25 @@ end

#### Models and databases

* Support for removing records from many-to-many fields was added and many-to-many field query sets now provide a [`#remove`](pathname:///api/dev/Marten/DB/Query/ManyToManySet.html#remove(*objs%3AM)%3ANil-instance-method) helper method allowing to easily remove specific records from a specific relation. You can learn more about this capability in [Many-to-many relationships](../../models-and-databases/relationships.md#many-to-many-relationships).
* Support for clearing all the references to records targeted by many-to-many fields was added. Indeed, many-to-many field query sets now provide a [`#clear`](pathname:///api/dev/Marten/DB/Query/ManyToManySet.html#clear%3ANil-instance-method) method allowing to easily clear a specific relation. You can learn more about this capability in [Many-to-many relationships](../../models-and-databases/relationships.md#many-to-many-relationships).
* It is now possible to specify arrays of records to add or remove from a many-to-many relationship query set, through the use of the [`#add`](pathname:///api/dev/Marten/DB/Query/ManyToManySet.html#add(*objs%3AM)-instance-method) and [`#remove`](pathname:///api/dev/Marten/DB/Query/ManyToManySet.html#remove(*objs%3AM)%3ANil-instance-method) methods. See the [related documentation](../../models-and-databases/relationships.md#interacting-with-related-records-2) to learn more about interacting with records targeted by many-to-many relationships.
* Support for removing records from many-to-many fields was added and many-to-many field query sets now provide a [`#remove`](pathname:///api/0.4/Marten/DB/Query/ManyToManySet.html#remove(*objs%3AM)%3ANil-instance-method) helper method allowing to easily remove specific records from a specific relation. You can learn more about this capability in [Many-to-many relationships](../../models-and-databases/relationships.md#many-to-many-relationships).
* Support for clearing all the references to records targeted by many-to-many fields was added. Indeed, many-to-many field query sets now provide a [`#clear`](pathname:///api/0.4/Marten/DB/Query/ManyToManySet.html#clear%3ANil-instance-method) method allowing to easily clear a specific relation. You can learn more about this capability in [Many-to-many relationships](../../models-and-databases/relationships.md#many-to-many-relationships).
* It is now possible to specify arrays of records to add or remove from a many-to-many relationship query set, through the use of the [`#add`](pathname:///api/0.4/Marten/DB/Query/ManyToManySet.html#add(*objs%3AM)-instance-method) and [`#remove`](pathname:///api/0.4/Marten/DB/Query/ManyToManySet.html#remove(*objs%3AM)%3ANil-instance-method) methods. See the [related documentation](../../models-and-databases/relationships.md#interacting-with-related-records-2) to learn more about interacting with records targeted by many-to-many relationships.
* Records targeted by reverse relations that are contributed to models by [`one_to_one`](../../models-and-databases/reference/fields.md#one_to_one) (ie. when using the [`related`](../../models-and-databases/reference/fields.md#related-2) option) are now memoized when the corresponding methods are called on related model instances.
* Relation fields that contribute methods that return query sets to models (such as [`many_to_one`](../../models-and-databases/reference/fields.md#many_to_one) or [`many_to_many`](../../models-and-databases/reference/fields.md#many_to_many) fields) now make sure that those query set objects are memoized at the record level. The corresponding instance variables are also reset when the considered records are reloaded. This allows to limit the number of queries involved when iterating multiple times over the records targeted by a [`many_to_many`](../../models-and-databases/reference/fields.md#many_to_many) field for example.
* The [`#order`](../../models-and-databases/reference/query-set.md#order) query set method can now be called directly on model classes to allow retrieving all the records of the considered model in a specific order.
* A [`#pk?`](pathname:///api/dev/Marten/DB/Model/Table.html#pk%3F%3ABool-instance-method) model method can now be leveraged to determine if a primary key value is set on a given model record.
* A [`#pk?`](pathname:///api/0.4/Marten/DB/Model/Table.html#pk%3F%3ABool-instance-method) model method can now be leveraged to determine if a primary key value is set on a given model record.
* The [`#join`](../../models-and-databases/reference/query-set.md#join) query set method now makes it possible to pre-select one-to-one reverse relations. This essentially allows to traverse a [`one_to_one`](../../models-and-databases/reference/fields.md#one_to_one) field back to the model record on which the field is specified.
* The [`#count`](../../models-and-databases/reference/query-set.md#count) query set method can now take an optional field name to count the number of records that have a non-null value for the corresponding column in the database.

#### Handlers and HTTP

* It is now optional to define a name for included route maps (but defining a name for individual routes that are associated with [handlers](../../handlers-and-http/introduction.md) is still mandatory). You can read more about this in [Defining included routes](../../handlers-and-http/routing.md#defining-included-routes).
* The [`Marten::Handlers::Schema`](pathname:///api/dev/Marten/Handlers/Schema.html) generic handler now allows modifying the schema object context name through the use of the [`#schema_context_name`](pathname:///api/dev/Marten/Handlers/Schema.html#schema_context_name(name%3AString|Symbol)-class-method) method.
* The [`Marten::Handlers::Schema`](pathname:///api/0.4/Marten/Handlers/Schema.html) generic handler now allows modifying the schema object context name through the use of the [`#schema_context_name`](pathname:///api/0.4/Marten/Handlers/Schema.html#schema_context_name(name%3AString|Symbol)-class-method) method.
* It is now possible to specify symbol status codes when making use of the [`#respond`](../../handlers-and-http/introduction.md#respond), [`#render`](../../handlers-and-http/introduction.md#render), [`#head`](../../handlers-and-http/introduction.md#head), and [`#json`](../../handlers-and-http/introduction.md#json) response helper methods. Such symbols must comply with the values of the [`HTTP::Status`](https://crystal-lang.org/api/HTTP/Status.html) enum.
* The hash of matched routing parameters that is available from handlers through the use of the `#params` method can accept symbols and strings when performing key lookups.
* The [GZip middleware](../../handlers-and-http/reference/middlewares.md#gzip-middleware) now incorporates a mitigation strategy against the BREACH attack. This strategy (described in the [Heal The Breach paper](https://ieeexplore.ieee.org/document/9754554)) involves introducing up to 100 random bytes into GZip responses to enhance the security against such attacks.
* A new [`before_render`](../../handlers-and-http/callbacks.md#before_render) callback type is now available to handlers. Such callbacks are executed before rendering a [template](../../templates/introduction.md) in order to produce a response. As such they are well suited for adding new variables to the global template context so that they are available to the template runtime.
* All handlers now have access to a [global template context](../../handlers-and-http/introduction.md#global-template-context) through the use of the [`#context`](pathname:///api/dev/Marten/Handlers/Base.html#context-instance-method) method. This template context object is available for the lifetime of the considered handler and can be mutated to define which variables are made available to the template runtime when rendering templates (either through the use of the [`#render`](#render) helper method or when rendering templates as part of subclasses of the [`Marten::Handlers::Template`](../../handlers-and-http/generic-handlers.md#rendering-a-template) generic handler). This feature can be combined with the [`before_render`](../../handlers-and-http/callbacks.md#before_render) callback to effortlessly introduce new variables to the context used for rendering a template and generating a handler response.
* All handlers now have access to a [global template context](../../handlers-and-http/introduction.md#global-template-context) through the use of the [`#context`](pathname:///api/0.4/Marten/Handlers/Base.html#context-instance-method) method. This template context object is available for the lifetime of the considered handler and can be mutated to define which variables are made available to the template runtime when rendering templates (either through the use of the [`#render`](#render) helper method or when rendering templates as part of subclasses of the [`Marten::Handlers::Template`](../../handlers-and-http/generic-handlers.md#rendering-a-template) generic handler). This feature can be combined with the [`before_render`](../../handlers-and-http/callbacks.md#before_render) callback to effortlessly introduce new variables to the context used for rendering a template and generating a handler response.

#### Templates

Expand All @@ -147,8 +147,8 @@ end

* The [`new`](../../development/reference/management-commands.md#new) management command now accepts an optional `--database` option that can be used to preconfigure the application database (eg. `--database=postgresql`).
* A [`clearsessions`](../../development/reference/management-commands.md#clearsessions) management command was introduced in order to ease the process of clearing expired session entries.
* Custom management commands can now define how they want to handle unknown or undefined arguments through the use of the [`#on_unknown_argument`](pathname:///api/dev/Marten/CLI/Manage/Command/Base.html#on_unknown_argument(%26block%3AString->)-instance-method) method. This can be leveraged to implement management commands which can accept a variable number of positional arguments.
* Custom management commands can now define how they want to handle invalid options through the use of the [`#on_invalid_option`](pathname:///api/dev/Marten/CLI/Manage/Command/Base.html#on_invalid_option(%26block%3AString->)-instance-method) method.
* Custom management commands can now define how they want to handle unknown or undefined arguments through the use of the [`#on_unknown_argument`](pathname:///api/0.4/Marten/CLI/Manage/Command/Base.html#on_unknown_argument(%26block%3AString->)-instance-method) method. This can be leveraged to implement management commands which can accept a variable number of positional arguments.
* Custom management commands can now define how they want to handle invalid options through the use of the [`#on_invalid_option`](pathname:///api/0.4/Marten/CLI/Manage/Command/Base.html#on_invalid_option(%26block%3AString->)-instance-method) method.

#### Emailing

Expand All @@ -162,7 +162,7 @@ end

### Handlers and HTTP

* Custom [session stores](../../handlers-and-http/sessions.md#session-stores) must now implement a [`#clear_expired_entries`](pathname:///api/dev/Marten/HTTP/Session/Store/Base.html#clear_expired_entries%3ANil-instance-method) method (allowing to clear expired session entries if this is applicable for the considered store).
* Custom [session stores](../../handlers-and-http/sessions.md#session-stores) must now implement a [`#clear_expired_entries`](pathname:///api/0.4/Marten/HTTP/Session/Store/Base.html#clear_expired_entries%3ANil-instance-method) method (allowing to clear expired session entries if this is applicable for the considered store).
* The introduction of the [global template context](../../handlers-and-http/introduction.md#global-template-context) involves that generic handlers that used to override the `#context` method (in order to insert record or schema objects into the template context for example) now leverage [`before_render`](../../handlers-and-http/callbacks.md#before_render) callbacks in order to mutate the global context and define the same variables. Generic handler subclasses that were overriding this `#context` method and calling `super` in it will likely need to be updated in order to leverage the [`before_render`](../../handlers-and-http/callbacks.md#before_render) callback to add custom variables to the [global template context](../../handlers-and-http/introduction.md#global-template-context).

### Templates
Expand Down
94 changes: 0 additions & 94 deletions docs/versioned_docs/version-0.1/development/testing.md

This file was deleted.

Loading

0 comments on commit 452762c

Please sign in to comment.