Skip to content

Commit 366089a

Browse files
committed
Match on both quotes
1 parent 4e0764b commit 366089a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/ecto/adapters/myxql/connection.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ if Code.ensure_loaded?(MyXQL) do
4444
MyXQL.stream(conn, sql, params, opts)
4545
end
4646

47+
@quotes ~w(" ')
48+
4749
@impl true
4850
def to_constraints(%MyXQL.Error{mysql: %{name: :ER_DUP_ENTRY}, message: message}, opts) do
4951
with [_, quoted] <- :binary.split(message, " for key "),
50-
[_, index | _] <- :binary.split(quoted, "'", [:global]) do
52+
[_, index | _] <- :binary.split(quoted, @quotes, [:global]) do
5153
[unique: strip_source(index, opts[:source])]
5254
else
5355
_ -> []
@@ -57,7 +59,7 @@ if Code.ensure_loaded?(MyXQL) do
5759
def to_constraints(%MyXQL.Error{mysql: %{name: name}, message: message}, _opts)
5860
when name in [:ER_ROW_IS_REFERENCED_2, :ER_NO_REFERENCED_ROW_2] do
5961
with [_, quoted] <- :binary.split(message, [" CONSTRAINT ", " FOREIGN KEY "]),
60-
[_, index | _] <- :binary.split(quoted, "'", [:global]) do
62+
[_, index | _] <- :binary.split(quoted, @quotes, [:global]) do
6163
[foreign_key: index]
6264
else
6365
_ -> []

0 commit comments

Comments
 (0)