diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-08-02 05:41:58 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-08-02 05:41:58 -0700 |
commit | e73f07568998e220d4e5501456b9f4dc6ac417f1 (patch) | |
tree | 0c794749dab5dda8712328ccc02ef22287ea4182 /activerecord | |
parent | db7e912138cd13e8727c22d24df077627b8612e4 (diff) | |
parent | 4371c5c4ec8af2534aadcdeefa90b983c55884a6 (diff) | |
download | rails-e73f07568998e220d4e5501456b9f4dc6ac417f1.tar.gz rails-e73f07568998e220d4e5501456b9f4dc6ac417f1.tar.bz2 rails-e73f07568998e220d4e5501456b9f4dc6ac417f1.zip |
Merge pull request #11714 from jetthoughts/11706_remove_bad_override_of_xml
Removed redundant xml override from pg adapter
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG.md | 5 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 10 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/xml_test.rb | 39 |
3 files changed, 47 insertions, 7 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 5e7a0c3811..449d94e0eb 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,8 @@ +* Removed redundant override of `xml` column definition for PG, + in order to use `xml` column type instead of `text` + + *Paul Nikitochkin*, *Michael Nikitochkin* + * Revert `ActiveRecord::Relation#order` change that make new order prepend the old one. diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 98126249df..342d1b1433 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -373,15 +373,11 @@ module ActiveRecord self end - def xml(options = {}) - column(args[0], :text, options) - end - private - def create_column_definition(name, type) - ColumnDefinition.new name, type - end + def create_column_definition(name, type) + ColumnDefinition.new name, type + end end class Table < ActiveRecord::ConnectionAdapters::Table diff --git a/activerecord/test/cases/adapters/postgresql/xml_test.rb b/activerecord/test/cases/adapters/postgresql/xml_test.rb new file mode 100644 index 0000000000..974fbabd58 --- /dev/null +++ b/activerecord/test/cases/adapters/postgresql/xml_test.rb @@ -0,0 +1,39 @@ +# encoding: utf-8 + +require 'cases/helper' +require 'active_record/base' +require 'active_record/connection_adapters/postgresql_adapter' + +class PostgresqlXMLTest < ActiveRecord::TestCase + class XmlDataType < ActiveRecord::Base + self.table_name = 'xml_data_type' + end + + def setup + @connection = ActiveRecord::Base.connection + begin + @connection.transaction do + @connection.create_table('xml_data_type') do |t| + t.xml 'payload', default: {} + end + end + rescue ActiveRecord::StatementInvalid + return skip "do not test on PG without xml" + end + @column = XmlDataType.columns.find { |c| c.name == 'payload' } + end + + def teardown + @connection.execute 'drop table if exists xml_data_type' + end + + def test_column + assert_equal :xml, @column.type + end + + def test_null_xml + @connection.execute %q|insert into xml_data_type (payload) VALUES(null)| + x = XmlDataType.first + assert_equal(nil, x.payload) + end +end |