aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/column.rb15
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/oid/hstore.rb8
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/oid/json.rb8
-rw-r--r--activerecord/lib/active_record/errors.rb7
4 files changed, 22 insertions, 16 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/column.rb b/activerecord/lib/active_record/connection_adapters/column.rb
index 86232f9d3f..a62617ab47 100644
--- a/activerecord/lib/active_record/connection_adapters/column.rb
+++ b/activerecord/lib/active_record/connection_adapters/column.rb
@@ -14,12 +14,9 @@ module ActiveRecord
end
attr_reader :name, :default, :cast_type, :null, :sql_type, :default_function
- attr_accessor :coder
-
- alias :encoded? :coder
delegate :type, :precision, :scale, :limit, :klass, :text?, :number?, :binary?,
- :type_cast_for_write, :type_cast_for_database, to: :cast_type
+ :type_cast, :type_cast_for_write, :type_cast_for_database, to: :cast_type
# Instantiates a new column in the table.
#
@@ -37,22 +34,12 @@ module ActiveRecord
@null = null
@default = extract_default(default)
@default_function = nil
- @coder = nil
end
def has_default?
!default.nil?
end
- # Casts value to an appropriate instance.
- def type_cast(value)
- if encoded?
- coder.load(value)
- else
- cast_type.type_cast(value)
- end
- end
-
# Returns the human name of the column name.
#
# ===== Examples
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid/hstore.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid/hstore.rb
index 98f369a7f8..bf680b6624 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/hstore.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/hstore.rb
@@ -8,7 +8,13 @@ module ActiveRecord
end
def type_cast_for_write(value)
- ConnectionAdapters::PostgreSQLColumn.hstore_to_string value
+ # roundtrip to ensure uniform uniform types
+ # TODO: This is not an efficient solution.
+ cast_value(type_cast_for_database(value))
+ end
+
+ def type_cast_for_database(value)
+ ConnectionAdapters::PostgreSQLColumn.hstore_to_string(value)
end
def cast_value(value)
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid/json.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid/json.rb
index 42bf5656f4..42a5110ffd 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/json.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/json.rb
@@ -8,7 +8,13 @@ module ActiveRecord
end
def type_cast_for_write(value)
- ConnectionAdapters::PostgreSQLColumn.json_to_string value
+ # roundtrip to ensure uniform uniform types
+ # TODO: This is not an efficient solution.
+ cast_value(type_cast_for_database(value))
+ end
+
+ def type_cast_for_database(value)
+ ConnectionAdapters::PostgreSQLColumn.json_to_string(value)
end
def cast_value(value)
diff --git a/activerecord/lib/active_record/errors.rb b/activerecord/lib/active_record/errors.rb
index 71efbb8f93..2ccb1b0702 100644
--- a/activerecord/lib/active_record/errors.rb
+++ b/activerecord/lib/active_record/errors.rb
@@ -217,6 +217,13 @@ module ActiveRecord
class ImmutableRelation < ActiveRecordError
end
+ # TransactionIsolationError will be raised under the following conditions:
+ #
+ # * The adapter does not support setting the isolation level
+ # * You are joining an existing open transaction
+ # * You are creating a nested (savepoint) transaction
+ #
+ # The mysql, mysql2 and postgresql adapters support setting the transaction isolation level.
class TransactionIsolationError < ActiveRecordError
end
end