diff options
-rw-r--r-- | lib/arel/collectors/bind.rb | 4 | ||||
-rw-r--r-- | lib/arel/collectors/sql_string.rb | 4 | ||||
-rw-r--r-- | test/collectors/test_bind_collector.rb | 8 |
3 files changed, 16 insertions, 0 deletions
diff --git a/lib/arel/collectors/bind.rb b/lib/arel/collectors/bind.rb index 4309de75c9..05cd966509 100644 --- a/lib/arel/collectors/bind.rb +++ b/lib/arel/collectors/bind.rb @@ -27,6 +27,10 @@ module Arel end end end + + def compile bvs + substitute_binds(bvs).join + end end end end diff --git a/lib/arel/collectors/sql_string.rb b/lib/arel/collectors/sql_string.rb index 526de66416..45001bb507 100644 --- a/lib/arel/collectors/sql_string.rb +++ b/lib/arel/collectors/sql_string.rb @@ -20,6 +20,10 @@ module Arel self << bind.to_s self end + + def compile bvs + value + end end end end diff --git a/test/collectors/test_bind_collector.rb b/test/collectors/test_bind_collector.rb index c7748d7d10..036d8f05fe 100644 --- a/test/collectors/test_bind_collector.rb +++ b/test/collectors/test_bind_collector.rb @@ -57,6 +57,14 @@ module Arel assert_equal 'SELECT FROM "users" WHERE "users"."age" = hello AND "users"."name" = world', list.join end + + def test_compile + bv = Nodes::BindParam.new('?') + collector = collect ast_with_binds bv + + sql = collector.compile ["hello", "world"] + assert_equal 'SELECT FROM "users" WHERE "users"."age" = hello AND "users"."name" = world', sql + end end end end |