File tree Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ defimpl DBConnection.Query, for: Sqlite.DbConnection.Query do
7575 { result , _ } = int |> Integer . to_string |> Float . parse
7676 translate_value ( { result , type } )
7777 end
78- defp translate_value ( { float , "decimal" } ) , do: Decimal . new ( float )
78+ defp translate_value ( { float , "decimal" } ) , do: Decimal . from_float ( float )
7979 defp translate_value ( { float , "decimal(" <> rest } ) do
8080 [ precision , scale ] =
8181 rest
@@ -85,7 +85,7 @@ defimpl DBConnection.Query, for: Sqlite.DbConnection.Query do
8585
8686 Decimal . with_context ( % Decimal.Context { precision: precision , rounding: :down } ,
8787 fn ->
88- float |> Float . round ( scale ) |> Decimal . new |> Decimal . plus
88+ float |> Float . round ( scale ) |> Decimal . from_float |> Decimal . plus
8989 end )
9090 end
9191
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ defmodule Sqlite.Ecto2.RepoTest do
2424
2525 test "preserves decimal without precision" do
2626 TestRepo . insert! ( % MiscTypes { name: "hello" , start_time: ~T( 09:33:51.130422) , cost: 3.1415 } )
27- pi_ish = Decimal . new ( 3.1415 )
27+ pi_ish = Decimal . from_float ( 3.1415 )
2828 assert [ % MiscTypes { name: "hello" , cost: ^ pi_ish } ] =
2929 TestRepo . all from mt in MiscTypes
3030 end
You can’t perform that action at this time.
0 commit comments