Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions lib/clickhouse_ecto/query_string.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule ClickhouseEcto.QueryString do
alias Ecto.Query
alias Ecto.Query.{BooleanExpr, JoinExpr, QueryExpr}
alias Ecto.Query.{BooleanExpr, JoinExpr, QueryExpr, LimitExpr}
alias ClickhouseEcto.Connection
alias ClickhouseEcto.Helpers

Expand Down Expand Up @@ -93,6 +93,7 @@ defmodule ClickhouseEcto.QueryString do
def on_join_expr({:==, _, [{{_, _, [_, column]}, _, _}, _]}) when is_atom(column) do
" USING " <> Atom.to_string(column)
end

def on_join_expr(true), do: ""

def join_qual(:inner), do: " INNER JOIN "
Expand Down Expand Up @@ -144,7 +145,7 @@ defmodule ClickhouseEcto.QueryString do

def limit(%Query{limit: nil}, _sources), do: []

def limit(%Query{limit: %QueryExpr{expr: expr}} = query, sources) do
def limit(%Query{limit: %LimitExpr{expr: expr}} = query, sources) do
[" LIMIT ", expr(expr, sources, query)]
end

Expand All @@ -155,15 +156,19 @@ defmodule ClickhouseEcto.QueryString do
end

defp hints([_ | _] = hints) do
hint_list = Enum.map(hints, &hint/1)
|> Enum.intersperse(", ")
hint_list =
Enum.map(hints, &hint/1)
|> Enum.intersperse(", ")

[" ", hint_list]
end

defp hints([]), do: []

defp hint(hint_str) when is_binary(hint_str), do: hint_str
defp hint({key, val}) when is_atom(key) and is_integer(val), do: [Atom.to_string(key), " ", Integer.to_string(val)]

defp hint({key, val}) when is_atom(key) and is_integer(val),
do: [Atom.to_string(key), " ", Integer.to_string(val)]

def boolean(_name, [], _sources, _query), do: []

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule ClickhouseEcto.Mixfile do
def project do
[
app: :clickhouse_ecto,
version: "0.2.8",
version: "0.2.9",
elixir: "~> 1.5",
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand Down