diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2016-08-20 06:40:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-20 06:40:15 -0400 |
commit | 02c9a78489dae495f15f4bc967359308ca4203f6 (patch) | |
tree | ea366d2975d6509956401511c1a73e693f96c70b /activerecord | |
parent | bf35e2f33a0744c8cf4df9f957e5409d8c8003b1 (diff) | |
parent | f1d9fc5d346a6a1bc6728bad544196c62fc50cac (diff) | |
download | rails-02c9a78489dae495f15f4bc967359308ca4203f6.tar.gz rails-02c9a78489dae495f15f4bc967359308ca4203f6.tar.bz2 rails-02c9a78489dae495f15f4bc967359308ca4203f6.zip |
Merge pull request #26232 from kamipo/fix_oid_bit_cast_value
Fix `OID::Bit#cast_value`
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/oid/bit.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/bit_string_test.rb | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid/bit.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid/bit.rb index a6b5a89ec0..74bff229ea 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/bit.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/bit.rb @@ -7,7 +7,7 @@ module ActiveRecord :bit end - def cast(value) + def cast_value(value) if ::String === value case value when /^0x/i @@ -16,7 +16,7 @@ module ActiveRecord value # Bit-string notation end else - value + value.to_s end end diff --git a/activerecord/test/cases/adapters/postgresql/bit_string_test.rb b/activerecord/test/cases/adapters/postgresql/bit_string_test.rb index f646e59848..7712e809a2 100644 --- a/activerecord/test/cases/adapters/postgresql/bit_string_test.rb +++ b/activerecord/test/cases/adapters/postgresql/bit_string_test.rb @@ -65,10 +65,11 @@ class PostgresqlBitStringTest < ActiveRecord::PostgreSQLTestCase end def test_roundtrip - PostgresqlBitString.create! a_bit: "00001010", a_bit_varying: "0101" - record = PostgresqlBitString.first + record = PostgresqlBitString.create!(a_bit: "00001010", a_bit_varying: "0101") assert_equal "00001010", record.a_bit assert_equal "0101", record.a_bit_varying + assert_nil record.another_bit + assert_nil record.another_bit_varying record.a_bit = "11111111" record.a_bit_varying = "0xF" |