Skip to content

Commit

Permalink
Merge pull request #612 from greg-rychlewski/undo_mistaken_commit
Browse files Browse the repository at this point in the history
Revert "more tests"
  • Loading branch information
greg-rychlewski authored Jun 25, 2022
2 parents 5318aae + ee9fbeb commit 6c19765
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 56 deletions.
49 changes: 0 additions & 49 deletions test/query_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -684,55 +684,6 @@ defmodule QueryTest do
assert [[json]] == query("SELECT $1::jsonb", [json])
end

@tag max_pg_version: "14.0"
test "infinite values returns postgres error on select", context do
pos_inf = Decimal.new("Infinity")
neg_inf = Decimal.new("Infinity")

:ok = query("CREATE TABLE test (num numeric)", [])

assert %Postgrex.Error{postgres: %{code: :invalid_binary_representation}} =
query("SELECT $1::numeric", [pos_inf])

assert %Postgrex.Error{postgres: %{code: :invalid_binary_representation}} =
query("SELECT $1::numeric", [neg_inf])

assert %Postgrex.Error{postgres: %{code: :invalid_binary_representation}} =
query("SELECT * FROM test where num < $1", [pos_inf])

assert %Postgrex.Error{postgres: %{code: :invalid_binary_representation}} =
query("SELECT * FROM test where num > $1", [neg_inf])
end

@tag max_pg_version: "14.0"
test "infinite values returns postgres error on insert", context do
pos_inf = Decimal.new("Infinity")
neg_inf = Decimal.new("Infinity")

:ok = query("CREATE TABLE test (num numeric)", [])

assert %Postgrex.Error{postgres: %{code: :invalid_binary_representation}} =
query("INSERT INTO test VALUES ($1)", [pos_inf], [])

assert %Postgrex.Error{postgres: %{code: :invalid_binary_representation}} =
query("INSERT INTO test VALUES ($1)", [neg_inf], [])
end

@tag max_pg_version: "14.0"
test "infinite values returns postgres error on update", context do
pos_inf = Decimal.new("Infinity")
neg_inf = Decimal.new("Infinity")

:ok = query("CREATE TABLE test (num numeric)", [])
:ok = query("INSERT INTO test VALUES ($1)", [1], [])

assert %Postgrex.Error{postgres: %{code: :invalid_binary_representation}} =
query("UPDATE test SET num = $1 WHERE num = $2", [pos_inf, 1], [])

assert %Postgrex.Error{postgres: %{code: :invalid_binary_representation}} =
query("UPDATE test SET num = $1 WHERE num = $2", [neg_inf, 1], [])
end

test "encode custom numerics", context do
assert [[%Decimal{sign: 1, coef: 1500, exp: 0}]] ==
query("SELECT $1::numeric", [Decimal.from_float(1500.0)])
Expand Down
9 changes: 2 additions & 7 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,12 @@ replication_exclude =
[logical_replication: true]
end

min_version_exclude =
version_exclude =
[{8, 4}, {9, 0}, {9, 1}, {9, 2}, {9, 3}, {9, 4}, {9, 5}, {10, 0}, {13, 0}, {14, 0}]
|> Enum.filter(fn x -> x > pg_version end)
|> Enum.map(fn {major, minor} -> {:min_pg_version, "#{major}.#{minor}"} end)

max_version_exclude =
[{8, 4}, {9, 0}, {9, 1}, {9, 2}, {9, 3}, {9, 4}, {9, 5}, {10, 0}, {13, 0}, {14, 0}]
|> Enum.filter(fn x -> x < pg_version end)
|> Enum.map(fn {major, minor} -> {:max_pg_version, "#{major}.#{minor}"} end)

excludes = min_version_exclude ++ max_version_exclude ++ replication_exclude ++ notify_exclude ++ unix_exclude ++ ssl_exclude
excludes = version_exclude ++ replication_exclude ++ notify_exclude ++ unix_exclude ++ ssl_exclude
ExUnit.start(exclude: excludes, assert_receive_timeout: 1000)

sql_test = """
Expand Down

0 comments on commit 6c19765

Please sign in to comment.