Permalink
Browse files

Fix test asserting the sanitized SQL hash differently to some adapters

  • Loading branch information...
rafaelfranca committed May 7, 2013
1 parent 9073400 commit 0f97ac66471270b917103869a56bc409aa3ccf0b
Showing with 7 additions and 1 deletion.
  1. +7 −1 activerecord/test/cases/sanitize_test.rb
@@ -6,7 +6,13 @@ def setup
end
def test_sanitize_sql_hash_handles_associations
- assert_equal "`adorable_animals`.`name` = 'Bambi'", Binary.send(:sanitize_sql_hash, {adorable_animals: {name: 'Bambi'}})
+ if current_adapter?(:MysqlAdapter, :Mysql2Adapter)
+ expected_value = "`adorable_animals`.`name` = 'Bambi'"
+ else
+ expected_value = "\"adorable_animals\".\"name\" = 'Bambi'"
+ end
+
+ assert_equal expected_value, Binary.send(:sanitize_sql_hash, {adorable_animals: {name: 'Bambi'}})
end
def test_sanitize_sql_array_handles_string_interpolation

7 comments on commit 0f97ac6

@yahonda

This comment has been minimized.

Show comment Hide comment
@yahonda

yahonda May 7, 2013

Contributor

Let me confirm if you mind to add one more current_adapter? line for this tests. As I'm testing this commit with Oracle enhanced adapter but because of the implementation difference, it needs to modify following statements. But there are discussions to avoid current_adapter? within ActiveRecord unit tests.

+    elsif current_adapter?(:OracleAdapter)
+      expected_value = "\"ADORABLE_ANIMALS\".\"NAME\" = 'Bambi'"
Contributor

yahonda replied May 7, 2013

Let me confirm if you mind to add one more current_adapter? line for this tests. As I'm testing this commit with Oracle enhanced adapter but because of the implementation difference, it needs to modify following statements. But there are discussions to avoid current_adapter? within ActiveRecord unit tests.

+    elsif current_adapter?(:OracleAdapter)
+      expected_value = "\"ADORABLE_ANIMALS\".\"NAME\" = 'Bambi'"
@carlosantoniodasilva

This comment has been minimized.

Show comment Hide comment
@carlosantoniodasilva

carlosantoniodasilva May 7, 2013

Owner

Is it possible to do like the following test?

 quoted_bambi = ActiveRecord::Base.connection.quote("Bambi")

Is it possible to do like the following test?

 quoted_bambi = ActiveRecord::Base.connection.quote("Bambi")
@yahonda

This comment has been minimized.

Show comment Hide comment
@yahonda

yahonda May 7, 2013

Contributor

Thanks for providing useful information. I'm taking a look at this.

Contributor

yahonda replied May 7, 2013

Thanks for providing useful information. I'm taking a look at this.

@yahonda

This comment has been minimized.

Show comment Hide comment
@yahonda

yahonda May 7, 2013

Contributor

@carlosantoniodasilva What do you think about this?
yahonda/rails@798cf2b

Contributor

yahonda replied May 7, 2013

@carlosantoniodasilva What do you think about this?
yahonda/rails@798cf2b

@yahonda

This comment has been minimized.

Show comment Hide comment
@yahonda

yahonda May 8, 2013

Contributor

Opened a #10521

Contributor

yahonda replied May 8, 2013

Opened a #10521

@carlosantoniodasilva

This comment has been minimized.

Show comment Hide comment
@carlosantoniodasilva

carlosantoniodasilva May 8, 2013

Owner

Sorry I didn't see your previous message. Looks like it was already merged, thanks @yahonda :)

Sorry I didn't see your previous message. Looks like it was already merged, thanks @yahonda :)

@yahonda

This comment has been minimized.

Show comment Hide comment
@yahonda

yahonda May 8, 2013

Contributor

@carlosantoniodasilva No problem at all. Your review and comments are always helpful. Thanks.

Contributor

yahonda replied May 8, 2013

@carlosantoniodasilva No problem at all. Your review and comments are always helpful. Thanks.

Please sign in to comment.