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

Commit a6ed594

Browse files
committed
Merge branch 'master' into server+prepared-stmt-cache
2 parents 0d0fae6 + f3e03e5 commit a6ed594

File tree

7 files changed

+22
-13
lines changed

7 files changed

+22
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/_build
2+
/cover
23
/deps
34
erl_crash.dump
45
*.ez

lib/sqlitex/row.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule Sqlitex.Row do
66
end
77

88
defp build_row(_types, _columns, row, :raw_list) do
9-
row |> Tuple.to_list
9+
Tuple.to_list(row)
1010
end
1111
defp build_row(types, columns, row, into) do
1212
types = Enum.map(types, fn type ->

lib/sqlitex/sql_builder.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule Sqlitex.SqlBuilder do
2323
defp table_opt(:temp), do: {:temp, "TEMP"}
2424
defp table_opt({:primary_key, cols}) when is_list(cols) do
2525
{
26-
:primary_key, ",PRIMARY KEY ("
26+
:primary_key, ",PRIMARY KEY ("
2727
# Also quote the columns in a PRIMARY KEY list
2828
<> (cols |> Enum.map(&(~s("#{&1}"))) |> Enum.join(","))
2929
<> ")"

mix.exs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ defmodule Sqlitex.Mixfile do
77
elixir: "~> 1.2",
88
deps: deps(),
99
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],
1016
description: """
1117
A thin Elixir wrapper around esqlite
1218
"""]
@@ -26,6 +32,7 @@ defmodule Sqlitex.Mixfile do
2632
{:credo, "~> 0.4", only: :dev},
2733
{:dialyze, "~> 0.2.0", only: :dev},
2834
{:earmark, "~> 0.2.1", only: :dev},
35+
{:excoveralls, "~> 0.6", only: :test},
2936
{:ex_doc, "~> 0.11", only: :dev},
3037
{:inch_ex, "~> 0.5", only: :dev},
3138

test/sql_builder_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ defmodule SqlBuilderTest do
1616
sql = Sql.create_table(:dinosaurs, [primary_key: :id], id: :integer, name: :text)
1717
assert sql == "CREATE TABLE \"dinosaurs\" (\"id\" integer, \"name\" text ,PRIMARY KEY (\"id\"))"
1818
end
19-
19+
2020
test "creating a table with multiple primary keys" do
2121
sql = Sql.create_table(:dinosaurs, [primary_key: [:id, :type]], id: :integer, type: :integer, name: :text)
2222
assert sql == "CREATE TABLE \"dinosaurs\" (\"id\" integer, \"type\" integer, \"name\" text ,PRIMARY KEY (\"id\",\"type\"))"

test/sqlitex_test.exs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ defmodule SqlitexTest do
3232
end
3333

3434
test "a basic query returns a list of keyword lists", context do
35-
{:ok, [row]} = context[:golf_db] |> Sqlitex.query("SELECT * FROM players ORDER BY id LIMIT 1")
35+
{:ok, [row]} = Sqlitex.query(context[:golf_db], "SELECT * FROM players ORDER BY id LIMIT 1")
3636
assert row == [id: 1, name: "Mikey", created_at: {{2012,10,14},{05,46,28,318_107}}, updated_at: {{2013,09,06},{22,29,36,610_911}}, type: nil]
3737
end
3838

3939
test "a basic query returns a list of maps when into: %{} is given", context do
40-
{:ok, [row]} = context[:golf_db] |> Sqlitex.query("SELECT * FROM players ORDER BY id LIMIT 1", into: %{})
40+
{:ok, [row]} = Sqlitex.query(context[:golf_db], "SELECT * FROM players ORDER BY id LIMIT 1", into: %{})
4141
assert row == %{id: 1, name: "Mikey", created_at: {{2012,10,14},{05,46,28,318_107}}, updated_at: {{2013,09,06},{22,29,36,610_911}}, type: nil}
4242
end
4343

@@ -62,12 +62,12 @@ defmodule SqlitexTest do
6262
end
6363

6464
test "a parameterized query", context do
65-
{:ok, [row]} = context[:golf_db] |> Sqlitex.query("SELECT id, name FROM players WHERE name LIKE ?1 AND type == ?2", bind: ["s%", "Team"])
65+
{:ok, [row]} = Sqlitex.query(context[:golf_db], "SELECT id, name FROM players WHERE name LIKE ?1 AND type == ?2", bind: ["s%", "Team"])
6666
assert row == [id: 25, name: "Slothstronauts"]
6767
end
6868

6969
test "a parameterized query into %{}", context do
70-
{:ok, [row]} = context[:golf_db] |> Sqlitex.query("SELECT id, name FROM players WHERE name LIKE ?1 AND type == ?2", bind: ["s%", "Team"], into: %{})
70+
{:ok, [row]} = Sqlitex.query(context[:golf_db], "SELECT id, name FROM players WHERE name LIKE ?1 AND type == ?2", bind: ["s%", "Team"], into: %{})
7171
assert row == %{id: 25, name: "Slothstronauts"}
7272
end
7373

@@ -155,20 +155,20 @@ defmodule SqlitexTest do
155155
end
156156

157157
test "query_rows returns {:ok, data}", context do
158-
{:ok, result} = context[:golf_db] |> Sqlitex.query_rows("SELECT id, name FROM players WHERE name LIKE ?1 AND type == ?2", bind: ["s%", "Team"])
158+
{:ok, result} = Sqlitex.query_rows(context[:golf_db], "SELECT id, name FROM players WHERE name LIKE ?1 AND type == ?2", bind: ["s%", "Team"])
159159
%{rows: rows, columns: columns, types: types} = result
160160
assert rows == [[25, "Slothstronauts"]]
161161
assert columns == [:id, :name]
162162
assert types == [:INTEGER, :"varchar(255)"]
163163
end
164164

165165
test "query_rows return {:error, reason}", context do
166-
{:error, reason} = context[:golf_db] |> Sqlitex.query_rows("SELECT wat FROM players")
166+
{:error, reason} = Sqlitex.query_rows(context[:golf_db], "SELECT wat FROM players")
167167
assert reason == {:sqlite_error, 'no such column: wat'}
168168
end
169169

170170
test "query_rows! returns data", context do
171-
result = context[:golf_db] |> Sqlitex.query_rows!("SELECT id, name FROM players WHERE name LIKE ?1 AND type == ?2", bind: ["s%", "Team"])
171+
result = Sqlitex.query_rows!(context[:golf_db], "SELECT id, name FROM players WHERE name LIKE ?1 AND type == ?2", bind: ["s%", "Team"])
172172
%{rows: rows, columns: columns, types: types} = result
173173
assert rows == [[25, "Slothstronauts"]]
174174
assert columns == [:id, :name]
@@ -177,7 +177,7 @@ defmodule SqlitexTest do
177177

178178
test "query_rows! raises on error", context do
179179
assert_raise Sqlitex.QueryError, "Query failed: {:sqlite_error, 'no such column: wat'}", fn ->
180-
[_res] = context[:golf_db] |> Sqlitex.query_rows!("SELECT wat FROM players")
180+
[_res] = Sqlitex.query_rows!(context[:golf_db], "SELECT wat FROM players")
181181
end
182182
end
183183

test/statement_test.exs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ defmodule StatementTest do
55
test "fetch_all! works" do
66
{:ok, db} = Sqlitex.open(":memory:")
77

8-
result = Sqlitex.Statement.prepare!(db, "PRAGMA user_version;")
9-
|> Sqlitex.Statement.fetch_all!
8+
result = db
9+
|> Sqlitex.Statement.prepare!("PRAGMA user_version;")
10+
|> Sqlitex.Statement.fetch_all!
1011

1112
assert result == [[user_version: 0]]
1213
end

0 commit comments

Comments
 (0)