aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorkennyj <kennyj@gmail.com>2012-11-14 01:43:34 +0900
committerkennyj <kennyj@gmail.com>2013-04-17 00:57:53 +0900
commit01a2ac12b90691315dec7792f98f895819c53e06 (patch)
tree1d747920e72c8b4128d4bb91ec008262f934cbf4 /activerecord/lib
parentb8e26642504fb8722f88b68a211eeaf5d40e2749 (diff)
downloadrails-01a2ac12b90691315dec7792f98f895819c53e06.tar.gz
rails-01a2ac12b90691315dec7792f98f895819c53e06.tar.bz2
rails-01a2ac12b90691315dec7792f98f895819c53e06.zip
Fix #7619. 0x prefix must be added when assigning hexadecimal string into bit column in Postgresql, because solving ambiguity.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/cast.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb b/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb
index 5789a2ae5f..a9ef11aa83 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb
@@ -28,8 +28,10 @@ module ActiveRecord
def string_to_bit(value)
case value
- when /^[01]*$/ then value # Bit-string notation
- when /^[0-9A-F]*$/i then value.hex.to_s(2) # Hexadecimal notation
+ when /^0x/i
+ value[2..-1].hex.to_s(2) # Hexadecimal notation
+ else
+ value # Bit-string notation
end
end