aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-05-09 13:53:46 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-05-09 13:53:57 -0700
commit73ff6797ef3e6fd0a3ee4b860061cf6869fe835d (patch)
tree85b21ccac375a0a031cab3ccbb2121ed2819bcca /activerecord/test/cases/adapters
parentc56f4b272d54bcca1978067a1fa8c78bdb3ab516 (diff)
downloadrails-73ff6797ef3e6fd0a3ee4b860061cf6869fe835d.tar.gz
rails-73ff6797ef3e6fd0a3ee4b860061cf6869fe835d.tar.bz2
rails-73ff6797ef3e6fd0a3ee4b860061cf6869fe835d.zip
use a null byte as a bind parameter substitute as it is not allowed in normal SQL. fixes #411, #417
Diffstat (limited to 'activerecord/test/cases/adapters')
-rw-r--r--activerecord/test/cases/adapters/mysql2/bind_parameter_test.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/mysql2/bind_parameter_test.rb b/activerecord/test/cases/adapters/mysql2/bind_parameter_test.rb
new file mode 100644
index 0000000000..cd9c1041dc
--- /dev/null
+++ b/activerecord/test/cases/adapters/mysql2/bind_parameter_test.rb
@@ -0,0 +1,50 @@
+require "cases/helper"
+require 'models/topic'
+
+module ActiveRecord
+ module ConnectionAdapters
+ class Mysql2Adapter
+ class BindParameterTest < ActiveRecord::TestCase
+ fixtures :topics
+
+ def test_update_question_marks
+ str = "foo?bar"
+ x = Topic.find :first
+ x.title = str
+ x.content = str
+ x.save!
+ x.reload
+ assert_equal str, x.title
+ assert_equal str, x.content
+ end
+
+ def test_create_question_marks
+ str = "foo?bar"
+ x = Topic.create!(:title => str, :content => str)
+ x.reload
+ assert_equal str, x.title
+ assert_equal str, x.content
+ end
+
+ def test_update_null_bytes
+ str = "foo\0bar"
+ x = Topic.find :first
+ x.title = str
+ x.content = str
+ x.save!
+ x.reload
+ assert_equal str, x.title
+ assert_equal str, x.content
+ end
+
+ def test_create_null_bytes
+ str = "foo\0bar"
+ x = Topic.create!(:title => str, :content => str)
+ x.reload
+ assert_equal str, x.title
+ assert_equal str, x.content
+ end
+ end
+ end
+ end
+end