From f17fa8ef6f2abffeea5398cc450172c0975cad27 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Mon, 2 Jun 2014 08:58:12 +0200 Subject: pg, inline casting methods into `OID::Type` objects. This inlines casting for the most obvious types. The rest will follow eventually. I need to put some tests in place, to make sure that the inlining is not causing regressions. /cc @sgrif --- .../lib/active_record/connection_adapters/postgresql/oid/bit.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/oid/bit.rb') 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 9b2d887d07..dc077993c5 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/bit.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/bit.rb @@ -5,7 +5,12 @@ module ActiveRecord class Bit < Type::String def type_cast(value) if ::String === value - ConnectionAdapters::PostgreSQLColumn.string_to_bit value + case value + when /^0x/i + value[2..-1].hex.to_s(2) # Hexadecimal notation + else + value # Bit-string notation + end else value end -- cgit v1.2.3