Skip to content

Commit

Permalink
Removed unneeded code [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Oct 25, 2023
1 parent e355c15 commit e9d3079
Showing 1 changed file with 6 additions and 34 deletions.
40 changes: 6 additions & 34 deletions test/adapters/postgresql_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ def test_run
end

def test_audit
if no_binds?
assert_audit "SELECT 'world' AS hello", "SELECT {var} AS hello", var: "world"
else
assert_audit "SELECT $1 AS hello\n\n[\"world\"]", "SELECT {var} AS hello", var: "world"
end
assert_audit "SELECT $1 AS hello\n\n[\"world\"]", "SELECT {var} AS hello", var: "world"
end

def test_string
Expand Down Expand Up @@ -56,43 +52,19 @@ def test_multiple_variables
end

def test_bad_position
if no_binds?
assert_error "syntax error at or near \"'hello'\"\nLINE 1: SELECT 'world' AS 'hello'", "SELECT 'world' AS {var}", var: "hello"
else
assert_bad_position "SELECT 'world' AS {var}", var: "hello"
end
assert_bad_position "SELECT 'world' AS {var}", var: "hello"
end

def test_bad_position_before
if no_binds?
assert_result [{"?column?" => "world"}], "SELECT{var}", var: "world"
else
assert_error "syntax error at or near \"SELECT$1\"", "SELECT{var}", var: "world"
end
assert_error "syntax error at or near \"SELECT$1\"", "SELECT{var}", var: "world"
end

def test_bad_position_after
if no_binds?
assert_error "syntax error at or near \"456\"\nLINE 1: SELECT 'world'456", "SELECT {var}456", var: "world"
assert_equal "SELECT 'world'456", Blazer::Audit.last.statement
else
assert_error "syntax error at or near \"456\"\nLINE 1: SELECT $1 456", "SELECT {var}456", var: "world"
assert_equal "SELECT $1 456\n\n[\"world\"]", Blazer::Audit.last.statement
end
assert_error "syntax error at or near \"456\"\nLINE 1: SELECT $1 456", "SELECT {var}456", var: "world"
assert_equal "SELECT $1 456\n\n[\"world\"]", Blazer::Audit.last.statement
end

def test_quoted
if no_binds?
assert_error "syntax error at or near \"''\"\nLINE 1: SELECT ''world'' AS hello", "SELECT '{var}' AS hello", var: "world"
else
assert_error "could not determine data type of parameter $1", "SELECT '{var}' AS hello", var: "world"
end
end

private

def no_binds?
ActiveRecord::VERSION::STRING.to_f < 6.1 &&
Blazer.data_sources[data_source].settings["url"].include?("prepared_statements=false")
assert_error "could not determine data type of parameter $1", "SELECT '{var}' AS hello", var: "world"
end
end

0 comments on commit e9d3079

Please sign in to comment.