aboutsummaryrefslogtreecommitdiffstats
path: root/test/visitors
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2017-12-28 10:35:15 -0800
committerGitHub <noreply@github.com>2017-12-28 10:35:15 -0800
commitdf2b74b53664cc3ce3a49156c555b84c134bb75a (patch)
tree89d2a363ead699b4e8916c9ddb7ffccd8d429f1d /test/visitors
parent6cf061ed6f3f9c8128385765c07eaa4f8a43bd34 (diff)
parentd8f463a3b87ff9f69eef2a3ed5718b198c2072a1 (diff)
downloadrails-df2b74b53664cc3ce3a49156c555b84c134bb75a.tar.gz
rails-df2b74b53664cc3ce3a49156c555b84c134bb75a.tar.bz2
rails-df2b74b53664cc3ce3a49156c555b84c134bb75a.zip
Merge pull request #481 from lautis/lateral
Lateral expressions for PostgreSQL
Diffstat (limited to 'test/visitors')
-rw-r--r--test/visitors/test_postgres.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/visitors/test_postgres.rb b/test/visitors/test_postgres.rb
index beae117ef5..b28c0f3c18 100644
--- a/test/visitors/test_postgres.rb
+++ b/test/visitors/test_postgres.rb
@@ -51,6 +51,20 @@ module Arel
assert_equal 'SELECT DISTINCT', compile(core)
end
+ it 'encloses LATERAL queries in parens' do
+ subquery = @table.project(:id).where(@table[:name].matches('foo%'))
+ compile(subquery.lateral).must_be_like %{
+ LATERAL (SELECT id FROM "users" WHERE "users"."name" ILIKE 'foo%')
+ }
+ end
+
+ it 'produces LATERAL queries with alias' do
+ subquery = @table.project(:id).where(@table[:name].matches('foo%'))
+ compile(subquery.lateral('bar')).must_be_like %{
+ LATERAL (SELECT id FROM "users" WHERE "users"."name" ILIKE 'foo%') bar
+ }
+ end
+
describe "Nodes::Matches" do
it "should know how to visit" do
node = @table[:name].matches('foo%')