Skip to content

Commit

Permalink
Keep decoded nil as nil
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jun 21, 2023
1 parent 1678de5 commit 22be184
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/ecto/adapters/tds.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -271,7 +270,6 @@ defmodule Ecto.Adapters.Tds do
end
end


@impl true
def supports_ddl_transaction? do
true
Expand All @@ -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)

Expand Down

0 comments on commit 22be184

Please sign in to comment.