aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-05-06 11:55:21 -0500
committerSean Griffin <sean@seantheprogrammer.com>2016-05-06 11:58:01 -0500
commit96f3f3d8267167d5d4c5697f2299756cfa7e37d4 (patch)
tree4159b2de70d916cb85d420906d4a2acf6b414950 /activerecord/lib/active_record/connection_adapters
parentc763c00b5e7cdfc7e5523502f7be77314cbfff7b (diff)
downloadrails-96f3f3d8267167d5d4c5697f2299756cfa7e37d4.tar.gz
rails-96f3f3d8267167d5d4c5697f2299756cfa7e37d4.tar.bz2
rails-96f3f3d8267167d5d4c5697f2299756cfa7e37d4.zip
Allow the connection adapters to determine the order of bind params
In 5.0 we use bind parameters for limit and offset, while in 4.2 we used the values directly. The code as it was written assumed that limit and offset worked as `LIMIT ? OFFSET ?`. Both Oracle and SQL Server have a different syntax, where the offset is stated before the limit. We delegate this behavior to the connection adapter so that these adapters are able to determine how the bind parameters are flattened based on what order their specification has the various clauses appear. Fixes #24775
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_adapter.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
index 51ed2bf8f2..d4b9e301bc 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -454,6 +454,24 @@ module ActiveRecord
visitor.accept(node, collector).value
end
+ def combine_bind_parameters(
+ from_clause: [],
+ join_clause: [],
+ where_clause: [],
+ having_clause: [],
+ limit: nil,
+ offset: nil
+ ) # :nodoc:
+ result = from_clause + join_clause + where_clause + having_clause
+ if limit
+ result << limit
+ end
+ if offset
+ result << offset
+ end
+ result
+ end
+
protected
def initialize_type_map(m) # :nodoc: