Skip to content

Commit

Permalink
Add basic bitwise operators support
Browse files Browse the repository at this point in the history
  • Loading branch information
Gigitsu committed Nov 25, 2023
1 parent d5153e3 commit d2ef848
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/ecto/adapters/postgres/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ if Code.ensure_loaded?(Postgrex) do
-: " - ",
*: " * ",
/: " / ",
&&&: " & ",
|||: " | ",
<<<: " << ",
>>>: " >> ",
and: " AND ",
or: " OR ",
ilike: " ILIKE ",
Expand Down
12 changes: 12 additions & 0 deletions test/ecto/adapters/postgres_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,18 @@ defmodule Ecto.Adapters.PostgresTest do

query = Schema |> select([r], r.x + 2) |> plan()
assert all(query) == ~s{SELECT s0."x" + 2 FROM "schema" AS s0}

query = Schema |> select([r], r.x &&& 2) |> plan()
assert all(query) == ~s{SELECT s0."x" & 2 FROM "schema" AS s0}

query = Schema |> select([r], r.x ||| 2) |> plan()
assert all(query) == ~s{SELECT s0."x" | 2 FROM "schema" AS s0}

query = Schema |> select([r], r.x <<< 2) |> plan()
assert all(query) == ~s{SELECT s0."x" << 2 FROM "schema" AS s0}

query = Schema |> select([r], r.x >>> 2) |> plan()
assert all(query) == ~s{SELECT s0."x" >> 2 FROM "schema" AS s0}
end

test "is_nil" do
Expand Down

0 comments on commit d2ef848

Please sign in to comment.