Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/ecto/adapters/sqlite3/codec.ex
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ defmodule Ecto.Adapters.SQLite3.Codec do
def bool_encode(false), do: {:ok, 0}
def bool_encode(true), do: {:ok, 1}

def decimal_encode(nil), do: {:ok, nil}

def decimal_encode(%Decimal{} = x) do
{:ok, Decimal.to_string(x, :normal)}
end

# def decimal_encode(x), do: {:ok, x}

def time_encode(value) do
{:ok, value}
end
Expand Down
11 changes: 11 additions & 0 deletions test/ecto/adapters/sqlite3/codec_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ defmodule Ecto.Adapters.SQLite3.CodecTest do
end
end

describe ".decimal_encode/1" do
test "nil" do
{:ok, nil} = Codec.decimal_encode(nil)
end

test "decimal" do
decimal = Decimal.new("2.5")
{:ok, "2.5"} = Codec.decimal_encode(decimal)
end
end

describe ".time_decode/1" do
test "nil" do
{:ok, nil} = Codec.time_decode(nil)
Expand Down