diff options
author | claudiob <claudiob@gmail.com> | 2014-10-23 17:22:17 -0700 |
---|---|---|
committer | claudiob <claudiob@gmail.com> | 2014-10-23 17:23:30 -0700 |
commit | 08e64913d17f774420698c3dd917c285ebc42e55 (patch) | |
tree | 3801383ec1eaa782aba10e5c2f30a300c5c4816e /lib/arel | |
parent | 7c34f82dc7b42c528acb2b509d8f220c1600acd5 (diff) | |
download | rails-08e64913d17f774420698c3dd917c285ebc42e55.tar.gz rails-08e64913d17f774420698c3dd917c285ebc42e55.tar.bz2 rails-08e64913d17f774420698c3dd917c285ebc42e55.zip |
Reuse `maybe_visit` method
This commit simply removes duplicated code by reusing the
existing `maybe_visit` method.
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/visitors/mysql.rb | 7 | ||||
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 15 |
2 files changed, 4 insertions, 18 deletions
diff --git a/lib/arel/visitors/mysql.rb b/lib/arel/visitors/mysql.rb index 70a37582c2..f989b8ddef 100644 --- a/lib/arel/visitors/mysql.rb +++ b/lib/arel/visitors/mysql.rb @@ -69,12 +69,7 @@ module Arel collector = inject_join o.orders, collector, ', ' end - if o.limit - collector << " " - visit(o.limit, collector) - else - collector - end + maybe_visit o.limit, collector end end diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 7fa3322148..bccf1d4061 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -229,15 +229,9 @@ module Arel def visit_Arel_Nodes_SelectCore o, collector collector << "SELECT" - if o.top - collector << " " - collector = visit o.top, collector - end + maybe_visit o.top, collector - if o.set_quantifier - collector << " " - collector = visit o.set_quantifier, collector - end + maybe_visit o.set_quantifier, collector unless o.projections.empty? collector << SPACE @@ -271,10 +265,7 @@ module Arel end end - if o.having - collector << " " - collector = visit(o.having, collector) - end + maybe_visit o.having, collector unless o.windows.empty? collector << WINDOW |