Skip to content

Commit

Permalink
closes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
vintikzzz committed Feb 20, 2017
1 parent 8368429 commit abcba09
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 0 additions & 2 deletions lib/cassandra_ecto/adapter/cql.ex
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ defmodule Cassandra.Ecto.Adapter.CQL do

defp handle_call(fun, _arity), do: {:fun, Atom.to_string(fun)}

defp op_to_binary({op, _, [_, _]} = expr, query) when op in @binary_ops, do:
paren_expr(expr, query)
defp op_to_binary(expr, query), do: expr(expr, query)

defp expr({{:., _, [{:&, _, [_idx]}, field]}, _, []}, _query) when is_atom(field), do:
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule CassandraEcto.Mixfile do
use Mix.Project

@version "0.5.0"
@version "0.5.1"

def project do
[app: :cassandra_ecto,
Expand Down
8 changes: 4 additions & 4 deletions spec/cassandra_ecto/adapter/cql_spec.ex
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ defmodule CassandraEctoAdapterCQLSpec do
it "generates cql with binary clauses" do
query = (from p in "posts", where: p.id >= 1 and p.title == "abra") |> normalize
expect(to_cql(:all, query))
|> to(eq "SELECT * FROM \"posts\" WHERE (\"id\" >= 1) AND (\"title\" = 'abra')")
|> to(eq "SELECT * FROM \"posts\" WHERE \"id\" >= 1 AND \"title\" = 'abra'")
end
it "generates cql with nested binary clauses" do
query = (from p in "posts", where: (p.id >= 1 and p.title == "abra") or p.id == 1) |> normalize
it "supports multiple binary clauses" do
query = (from p in "posts", where: "abra" in p.tags and p.title == "test" and p.text == "test") |> normalize
expect(to_cql(:all, query))
|> to(eq "SELECT * FROM \"posts\" WHERE ((\"id\" >= 1) AND (\"title\" = 'abra')) OR (\"id\" = 1)")
|> to(eq "SELECT * FROM \"posts\" WHERE \"tags\" CONTAINS 'abra' AND \"title\" = 'test' AND \"text\" = 'test'")
end
it "generates cql with in clauses" do
query = (from p in "posts", where: p.id in [1, 2]) |> normalize
Expand Down
4 changes: 4 additions & 0 deletions spec/cassandra_ecto/adapter_spec.exs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ defmodule CassandraEctoAdapterSpec do
expect(TestRepo.all((from p in Post, where: "abra" in p.tags), allow_filtering: true) |> List.first |> Map.get(:id))
|> to(eq id)
end
it "fetches record with multiple where clauses" do
expect(TestRepo.all((from p in Post, where: "abra" in p.tags and p.text == "test" and p.title == "test"), allow_filtering: true) |> List.first |> Map.get(:id))
|> to(eq id)
end
it "writes log to io in :cyan when logging enabled" do
message = capture_log(fn ->
TestRepo.all((from p in Post), log: true)
Expand Down

0 comments on commit abcba09

Please sign in to comment.