diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-05-24 08:23:32 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-05-26 06:19:44 -0700 |
commit | b5c4ef2c785ef634a81d7bb554e9b20f164be95b (patch) | |
tree | 19336e52e362bfeb4a09ea41de94a04e194ce6b7 /activerecord/lib/active_record/connection_adapters/abstract | |
parent | ec88d6861a81e5d7402660fb141f75f0aab86a4a (diff) | |
download | rails-b5c4ef2c785ef634a81d7bb554e9b20f164be95b.tar.gz rails-b5c4ef2c785ef634a81d7bb554e9b20f164be95b.tar.bz2 rails-b5c4ef2c785ef634a81d7bb554e9b20f164be95b.zip |
Add an interface for type objects to control Ruby => SQL
Adds the ability to save custom types, which type cast to non-primitive
ruby objects.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/quoting.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb index 75501852ed..0bd53a7eb0 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb @@ -47,6 +47,15 @@ module ActiveRecord return value.id end + # FIXME: The only case we get an object other than nil or a real column + # is `SchemaStatements#add_column` with a PG array that has a non-empty default + # value. Is this really the only case? Are we missing tests for other types? + # We should have a real column object passed (or nil) here, and check for that + # instead + if column.respond_to?(:type_cast_for_database) + value = column.type_cast_for_database(value) + end + case value when String, ActiveSupport::Multibyte::Chars value = value.to_s |