Skip to content

Commit

Permalink
Testing null / non null queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
mindreader committed Apr 19, 2023
1 parent 1a2c5f4 commit 2ceb96f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/simpleramix/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,12 @@ defmodule Simpleramix.Query do
{_, nil} ->
# Compare a dimension to a value
dimension_a = {:%{}, [], dimension_a |> Enum.to_list()}

b = case b do
{:null, _, nil} -> nil
_ -> b
end

quote do
%{
type: :selector,
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 Simpleramix.MixProject do
def project do
[
app: :simpleramix,
version: "1.4.1",
version: "1.5.0",
elixir: "~> 1.12",
start_permanent: Mix.env() == :prod,
description: "Client library for sending requests to Druid.",
Expand Down
6 changes: 5 additions & 1 deletion test/query/query_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,12 @@ defmodule QueryTest do
|> Simpleramix.add_filter(dimensions.foo in some_ids)
|> Simpleramix.add_filter(dimensions.foo not in some_ids)
|> Simpleramix.add_filter(mindate <= dimensions.__time < maxdate)
|> Simpleramix.add_filter(dimensions.nullfield != nil)
|> Simpleramix.add_filter(dimensions.nullfield == nil)
|> Simpleramix.add_filter(dimensions.nullfield != null)
|> Simpleramix.add_filter(dimensions.sometimesnullfield == null)

assert query.filter.type == :and
assert query.filter.fields |> Enum.count() == 6
assert query.filter.fields |> Enum.count() == 10
end
end

0 comments on commit 2ceb96f

Please sign in to comment.