Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make map/array encoding configurable #163

Merged
merged 3 commits into from
Mar 19, 2025

Conversation

a-nassim
Copy link
Contributor

Closes #162

This PR adds:

  1. :map_type config option to determine how :map columns are stored (:string or :binary)
  2. :array_type config option for :array columns (also :string or :binary)
    • I thought this would make sense since :array columns are also serialized using JSON

Both default to :string, the :binary option enables SQLite's JSONB storage format.

I tried to be consistent with other configurable types in this project like :uuid that is why it is not implemented the exact same way as in the Postgres adapter.

@warmwaffles
Copy link
Member

Yea this looks great!

storage format.
* `:array_type` - Defaults to `:string`. Determines the type of `:array` columns.
Arrays are serialized using JSON. Set to `:binary` to use the
[JSONB](https://sqlite.org/draft/jsonb.html) storage format.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[JSONB](https://sqlite.org/draft/jsonb.html) storage format.
[JSONB](https://sqlite.org/jsonb.html) storage format.

@@ -51,6 +51,12 @@ defmodule Ecto.Adapters.SQLite3 do
* `:uuid_type` - Defaults to `:string`. Determines the type of `:uuid` columns.
Possible values and column types are the same as for
[binary IDs](#module-binary-id-types).
* `:map_type` - Defaults to `:string`. Determines the type of `:map` columns.
Set to `:binary` to use the [JSONB](https://sqlite.org/draft/jsonb.html)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's point at the official docs and not the draft.

Suggested change
Set to `:binary` to use the [JSONB](https://sqlite.org/draft/jsonb.html)
Set to `:binary` to use the [JSONB](https://sqlite.org/jsonb.html)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops I missed that, fixed!

@a-nassim a-nassim force-pushed the configurable-map-encoding branch from d21f7f4 to ffeaeff Compare March 19, 2025 02:19
@warmwaffles warmwaffles merged commit 952f38b into elixir-sqlite:main Mar 19, 2025
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make map encoding configurable
2 participants