Permalink
Browse files

Merge [5597] from trunk.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5598 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent af43e87 commit ef6c3c4289eba6ac5bef5fafcba1c5b067bb4833 @jeremy jeremy committed Nov 20, 2006
View
@@ -1,5 +1,7 @@
*1.15.0 RC1* (November 19th, 2006)
+* Quote ActiveSupport::Multibyte::Chars. #6653 [Julian Tarkhanov]
+
* validates_numericality_of uses \A \Z to ensure the entire string matches rather than ^ $ which may match one valid line of a multiline string. #5716 [Andreas Schwarz]
* Oracle: automatically detect the primary key. #6594 [vesaria, Michael Schoen]
@@ -8,7 +8,8 @@ def quote(value, column = nil)
return value.quoted_id if value.respond_to?(:quoted_id)
case value
- when String
+ when String, ActiveSupport::Multibyte::Chars
+ value = value.to_s
if column && column.type == :binary && column.class.respond_to?(:string_to_binary)
"'#{quote_string(column.class.string_to_binary(value))}'" # ' (for ruby-mode)
elsif column && [:integer, :float].include?(column.type)
@@ -1075,6 +1075,18 @@ def test_quote
assert_equal author_name, Topic.find(topic.id).author_name
end
+ def test_quote_chars
+ str = 'The Narrator'
+ topic = Topic.create(:author_name => str)
+ assert_equal str, topic.author_name
+
+ assert_kind_of ActiveSupport::Multibyte::Chars, str.chars
+ topic = Topic.find_by_author_name(str.chars)
+
+ assert_kind_of Topic, topic
+ assert_equal str, topic.author_name, "The right topic should have been found by name even with name passed as Chars"
+ end
+
def test_class_level_destroy
should_be_destroyed_reply = Reply.create("title" => "hello", "content" => "world")
Topic.find(1).replies << should_be_destroyed_reply

0 comments on commit ef6c3c4

Please sign in to comment.