Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit 2878c09

Browse files
authored
Merge pull request #66 from mmmries/fix_dialyzer_errors
Fix dialyzer errors
2 parents f14ad12 + 08ba326 commit 2878c09

File tree

5 files changed

+38
-27
lines changed

5 files changed

+38
-27
lines changed

.travis.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
language: elixir
22
otp_release:
3-
- 20.1
4-
- 20.2
53
- 20.3
64
elixir:
7-
- 1.4.5
8-
- 1.5.3
9-
- 1.6.4
5+
- 1.4
6+
- 1.5
7+
- 1.6
8+
cache:
9+
directories:
10+
- /home/travis/.mix
11+
- /home/travis/build/mmmries/sqlitex/deps
12+
- /home/travis/build/mmmries/sqlitex/_build
13+
before_script:
14+
- mix dialyzer --plt
15+
script:
16+
- mix test
17+
- mix dialyzer --halt-exit-status --no-check
1018
after_script:
1119
- MIX_ENV=dev mix deps.get
1220
- MIX_ENV=dev mix inch.report

lib/sqlitex/row.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ defmodule Sqlitex.Row do
5555
defp translate_value({float, "decimal(" <> rest}) do
5656
[precision, scale] = rest |> string_rstrip(?)) |> String.split(",") |> Enum.map(&String.to_integer/1)
5757
Decimal.with_context %Decimal.Context{precision: precision, rounding: :down}, fn ->
58-
float |> Float.round(scale) |> Decimal.new |> Decimal.plus
58+
float |> Float.round(scale) |> Float.to_string |> Decimal.new |> Decimal.plus
5959
end
6060
end
6161

lib/sqlitex/server/statement_cache.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ defmodule Sqlitex.Server.StatementCache do
3434
end
3535
end
3636

37-
defp prepare_new_statement(%__MODULE__{db: db} = cache, sql, opts \\ []) do
37+
defp prepare_new_statement(%__MODULE__{db: db} = cache, sql, opts) do
3838
case Sqlitex.Statement.prepare(db, sql, opts) do
3939
{:ok, prepared} ->
4040
cache = cache

mix.exs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@ defmodule Sqlitex.Mixfile do
22
use Mix.Project
33

44
def project do
5-
[app: :sqlitex,
6-
version: "1.4.0",
7-
elixir: "~> 1.2",
8-
deps: deps(),
9-
package: package(),
10-
test_coverage: [tool: ExCoveralls],
11-
preferred_cli_env: [
12-
"coveralls": :test,
13-
"coveralls.detail": :test,
14-
"coveralls.post": :test,
15-
"coveralls.html": :test],
16-
description: """
17-
A thin Elixir wrapper around esqlite
18-
"""]
5+
[
6+
app: :sqlitex,
7+
version: "1.4.0",
8+
elixir: "~> 1.2",
9+
deps: deps(),
10+
package: package(),
11+
test_coverage: [tool: ExCoveralls],
12+
preferred_cli_env: [
13+
"coveralls": :test,
14+
"coveralls.detail": :test,
15+
"coveralls.post": :test,
16+
"coveralls.html": :test],
17+
description: """
18+
A thin Elixir wrapper around esqlite
19+
""",
20+
dialyzer: [plt_add_deps: :transitive],
21+
]
1922
end
2023

2124
# Configuration for the OTP application
@@ -26,7 +29,7 @@ defmodule Sqlitex.Mixfile do
2629
# Type `mix help deps` for more examples and options
2730
defp deps do
2831
[
29-
{:esqlite, "~> 0.2.3"},
32+
{:esqlite, "~> 0.2.4"},
3033
{:decimal, "~> 1.1"},
3134

3235
{:credo, "~> 0.4", only: :dev},

test/sqlitex_test.exs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ defmodule SqlitexTest do
193193
test "decimal types" do
194194
{:ok, db} = Sqlitex.open(":memory:")
195195
:ok = Sqlitex.exec(db, "CREATE TABLE t (f DECIMAL)")
196-
d = Decimal.new(1.123)
196+
d = Decimal.new("1.123")
197197
{:ok, []} = Sqlitex.query(db, "INSERT INTO t VALUES (?)", bind: [d])
198198
{:ok, [row]} = Sqlitex.query(db, "SELECT f FROM t")
199199
assert row[:f] == d
@@ -202,14 +202,14 @@ defmodule SqlitexTest do
202202
test "decimal types with scale and precision" do
203203
{:ok, db} = Sqlitex.open(":memory:")
204204
:ok = Sqlitex.exec(db, "CREATE TABLE t (id INTEGER, f DECIMAL(3,2))")
205-
{:ok, []} = Sqlitex.query(db, "INSERT INTO t VALUES (?,?)", bind: [1, Decimal.new(1.123)])
206-
{:ok, []} = Sqlitex.query(db, "INSERT INTO t VALUES (?,?)", bind: [2, Decimal.new(244.37)])
207-
{:ok, []} = Sqlitex.query(db, "INSERT INTO t VALUES (?,?)", bind: [3, Decimal.new(1997)])
205+
{:ok, []} = Sqlitex.query(db, "INSERT INTO t VALUES (?,?)", bind: [1, Decimal.new("1.123")])
206+
{:ok, []} = Sqlitex.query(db, "INSERT INTO t VALUES (?,?)", bind: [2, Decimal.new("244.37")])
207+
{:ok, []} = Sqlitex.query(db, "INSERT INTO t VALUES (?,?)", bind: [3, Decimal.new("1997")])
208208

209209
# results should be truncated to the appropriate precision and scale:
210210
Sqlitex.query!(db, "SELECT f FROM t ORDER BY id")
211211
|> Enum.map(fn row -> row[:f] end)
212-
|> Enum.zip([Decimal.new(1.12), Decimal.new(244), Decimal.new(1990)])
212+
|> Enum.zip([Decimal.new("1.12"), Decimal.new(244), Decimal.new(1990)])
213213
|> Enum.each(fn {res, ans} -> assert Decimal.equal?(res, ans) end)
214214
end
215215

0 commit comments

Comments
 (0)