From 22be18491fcae9651331a38f6b524722adfb0649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 21 Jun 2023 11:15:12 +0200 Subject: [PATCH] Keep decoded nil as nil --- lib/ecto/adapters/tds.ex | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/ecto/adapters/tds.ex b/lib/ecto/adapters/tds.ex index acbc88a3..c11e0a12 100644 --- a/lib/ecto/adapters/tds.ex +++ b/lib/ecto/adapters/tds.ex @@ -163,8 +163,7 @@ defmodule Ecto.Adapters.Tds do defp bool_decode(<<1>>), do: {:ok, true} defp bool_decode(0), do: {:ok, false} defp bool_decode(1), do: {:ok, true} - defp bool_decode(x) when is_boolean(x), do: {:ok, x} - defp bool_decode(nil), do: {:ok, false} + defp bool_decode(x), do: {:ok, x} defp json_decode(x) when is_binary(x), do: {:ok, Tds.json_library().decode!(x)} defp json_decode(x), do: {:ok, x} @@ -271,7 +270,6 @@ defmodule Ecto.Adapters.Tds do end end - @impl true def supports_ddl_transaction? do true @@ -285,12 +283,14 @@ defmodule Ecto.Adapters.Tds do Ecto.Adapters.SQL.raise_migration_pool_size_error() end - opts = Keyword.merge(opts, [timeout: :infinity, telemetry_options: [schema_migration: true]]) + opts = Keyword.merge(opts, timeout: :infinity, telemetry_options: [schema_migration: true]) {:ok, result} = transaction(meta, opts, fn -> - lock_name = "'ecto_#{inspect(repo)}'" - Ecto.Adapters.SQL.query!(meta, "sp_getapplock @Resource = #{lock_name}, @LockMode = 'Exclusive', @LockOwner = 'Transaction', @LockTimeout = -1", [], opts) + query = + "sp_getapplock @Resource = 'ecto_#{inspect(repo)}', @LockMode = 'Exclusive', @LockOwner = 'Transaction', @LockTimeout = -1" + + Ecto.Adapters.SQL.query!(meta, query, [], opts) fun.() end)