Skip to content

Commit edef95f

Browse files
author
Étienne Lévesque
authored
docs: Add documentation on the binary_id_type and uuid_type options (#73)
1 parent 09889dd commit edef95f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/ecto/adapters/sqlite3.ex

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ defmodule Ecto.Adapters.SQLite3 do
4444
* `:busy_timeout` - Sets the busy timeout in milliseconds for a connection.
4545
Default is `2000`.
4646
* `:pool_size` - the size of the connection pool. Defaults to `5`.
47+
* `:binary_id_type` - Defaults to `:string`. Determines how binary IDs are stored in the database and the type of
48+
`:binary_id` columns. See the [section on binary ID types](#module-binary-id-types) for more details.
49+
* `:uuid_type` - Defaults to `:string`. Determines the type of `:uuid` columns. Possible values and
50+
column types are the same as for [binary IDs](#module-binary-id-types).
4751
4852
For more information about the options above, see [sqlite documentation][1]
4953
@@ -72,6 +76,19 @@ defmodule Ecto.Adapters.SQLite3 do
7276
[1]: https://www.sqlite.org/pragma.html
7377
[2]: https://sqlite.org/wal.html
7478
79+
### Binary ID types
80+
81+
The `:binary_id_type` configuration option allows configuring how `:binary_id` fields are stored in the database as
82+
well as the type of the column in which these IDs will be stored. The possible values are:
83+
* `:string` (default): IDs are stored as strings, and the type of the column is `TEXT_UUID`.
84+
* `:binary`: IDs are stored in their raw binary form, and the type of the column is `UUID`.
85+
86+
The main differences between the two formats are as follows:
87+
* When stored as binary, UUIDs require much less space in the database. IDs stored as strings require 36 bytes each,
88+
while IDs stored as binary only require 16 bytes.
89+
* Because SQLite does not have a dedicated UUID type, most clients cannot represent UUIDs stored as binary in a human
90+
readable format. Therefore, IDs stored as strings may be easier to work with if manual manipulation is required.
91+
7592
## Limitations and caveats
7693
7794
There are some limitations when using Ecto with SQLite that one needs

0 commit comments

Comments
 (0)