Skip to content

Commit f35a728

Browse files
authored
Merge pull request #36 from ocean/coderabbitai/docstrings/a20c7db
2 parents a20c7db + 132e10e commit f35a728

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

lib/ecto/adapters/libsql/connection.ex

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ defmodule Ecto.Adapters.LibSql.Connection do
6666
end
6767

6868
@impl true
69+
@doc """
70+
Parse a SQLite error message and map it to a list of Ecto constraint tuples.
71+
72+
Accepts an exception-like map containing a SQLite error `:message` and returns recognised constraint information such as unique, foreign_key or check constraints; returns an empty list when no known constraint pattern is found.
73+
74+
## Parameters
75+
76+
- error: Map containing a `:message` string produced by SQLite.
77+
- _opts: Options (unused).
78+
79+
## Returns
80+
81+
- A keyword list of constraint tuples, for example `[unique: "table_column_index"]`, `[foreign_key: :unknown]`, `[check: "constraint_name"]`, or `[]` when no constraint is recognised.
82+
"""
83+
@spec to_constraints(%{message: String.t()}, Keyword.t()) :: Keyword.t()
6984
def to_constraints(%{message: message}, _opts) do
7085
cond do
7186
String.contains?(message, "UNIQUE constraint failed") ->

0 commit comments

Comments
 (0)