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

Commit 334c136

Browse files
authored
Merge pull request #48 from mmmries/elixir_1_4
Elixir 1.4
2 parents c2b67da + 1412c5a commit 334c136

6 files changed

Lines changed: 16 additions & 15 deletions

File tree

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
language: elixir
22
otp_release:
33
- 18.3
4-
- 19.1
4+
- 19.2
55
elixir:
66
- 1.2.6
7-
- 1.3.2
7+
- 1.3.4
8+
- 1.4.0
89
after_script:
910
- MIX_ENV=dev mix deps.get
1011
- MIX_ENV=dev mix inch.report

lib/sqlitex/query.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ defmodule Sqlitex.Query do
2525
@spec query(Sqlitex.connection, String.t | char_list, [bind: [], into: Enum.t]) :: [Enum.t] | Sqlitex.sqlite_error
2626
def query(db, sql, opts \\ []) do
2727
with {:ok, stmt} <- Statement.prepare(db, sql),
28-
{:ok, stmt} <- Statement.bind_values(stmt, Dict.get(opts, :bind, [])),
29-
{:ok, res} <- Statement.fetch_all(stmt, Dict.get(opts, :into, [])),
28+
{:ok, stmt} <- Statement.bind_values(stmt, Keyword.get(opts, :bind, [])),
29+
{:ok, res} <- Statement.fetch_all(stmt, Keyword.get(opts, :into, [])),
3030
do: {:ok, res}
3131
end
3232

@@ -68,7 +68,7 @@ defmodule Sqlitex.Query do
6868
@spec query_rows(Sqlitex.connection, String.t | char_list, [bind: []]) :: {:ok, %{}} | Sqlitex.sqlite_error
6969
def query_rows(db, sql, opts \\ []) do
7070
with {:ok, stmt} <- Statement.prepare(db, sql),
71-
{:ok, stmt} <- Statement.bind_values(stmt, Dict.get(opts, :bind, [])),
71+
{:ok, stmt} <- Statement.bind_values(stmt, Keyword.get(opts, :bind, [])),
7272
{:ok, rows} <- Statement.fetch_all(stmt, :raw_list),
7373
do: {:ok, %{rows: rows, columns: stmt.column_names, types: stmt.column_types}}
7474
end

lib/sqlitex/sql_builder.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ defmodule Sqlitex.SqlBuilder do
1212
# column_name: :column_type, of
1313
# column_name: {:column_type, [column_constraints]}
1414
def create_table(name, table_opts, cols) do
15-
tbl_options = get_opts_dict(table_opts, &table_opt/1)
16-
get_opt = &(Dict.get(tbl_options, &1, nil))
15+
tbl_options = get_opts_map(table_opts, &table_opt/1)
16+
get_opt = &(Map.get(tbl_options, &1, nil))
1717

1818
"CREATE #{get_opt.(:temp)} TABLE \"#{name}\" (#{get_columns_block(cols)} #{get_opt.(:primary_key)})"
1919
end
@@ -38,9 +38,9 @@ defmodule Sqlitex.SqlBuilder do
3838
defp column_opt(:not_null), do: {:not_null, "NOT NULL"}
3939
defp column_opt(:autoincrement), do: {:autoincrement, "AUTOINCREMENT"}
4040

41-
# Helper function that creates a dictionary of option names
41+
# Helper function that creates a map of option names
4242
# and their string representations
43-
defp get_opts_dict(opts, opt) do
43+
defp get_opts_map(opts, opt) do
4444
Enum.into(opts, %{}, &(opt.(&1)))
4545
end
4646

@@ -51,8 +51,8 @@ defmodule Sqlitex.SqlBuilder do
5151
case col do
5252
# Column with name, type and constraint
5353
{name, {type, constraints}} ->
54-
col_options = get_opts_dict(constraints, &column_opt/1)
55-
get_opt = &(Dict.get(col_options, &1, nil))
54+
col_options = get_opts_map(constraints, &column_opt/1)
55+
get_opt = &(Map.get(col_options, &1, nil))
5656

5757
[~s("#{name}"), type, get_opt.(:primary_key), get_opt.(:not_null), get_opt.(:autoincrement)]
5858
|> Enum.filter(&(&1))

mix.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ defmodule Sqlitex.Mixfile do
55
[app: :sqlitex,
66
version: "1.1.0",
77
elixir: "~> 1.2",
8-
deps: deps,
9-
package: package,
8+
deps: deps(),
9+
package: package(),
1010
description: """
1111
A thin Elixir wrapper around esqlite
1212
"""]

test/order_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule Sqlitex.OrderTest do
33
use ExCheck
44

55
property :ordering_query_results do
6-
for_all {x, y} in {int, int} do
6+
for_all {x, y} in {int(), int()} do
77
{:ok, db} = Sqlitex.open(":memory:")
88
:ok = Sqlitex.exec(db, "CREATE TABLE t (a INTEGER)")
99
:ok = Sqlitex.exec(db, "INSERT INTO t (a) VALUES #{(x..y) |> Enum.map(&( "(#{&1})" )) |> Enum.join(",")}")

test/sum_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule Sqlitex.SumTest do
33
use ExCheck
44

55
property :sum_integers do
6-
for_all nums in such_that(ns in list(int) when length(ns) > 0) do
6+
for_all nums in such_that(ns in list(int()) when length(ns) > 0) do
77
{:ok, db} = Sqlitex.open(":memory:")
88
:ok = Sqlitex.exec(db, "CREATE TABLE t (a INTEGER)")
99
Enum.each(nums, fn(num) ->

0 commit comments

Comments
 (0)