From 50f00463bd8348c35cc5dad40116e21323f6822f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 20 Nov 2012 08:00:52 -0800 Subject: Merge pull request #8276 from pwnall/pgsql_text_limits Postgresql doesn't accepts limits on text columns Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb --- .../test/cases/adapters/postgresql/sql_types_test.rb | 18 ++++++++++++++++++ activerecord/test/schema/postgresql_specific_schema.rb | 5 +++++ 2 files changed, 23 insertions(+) create mode 100644 activerecord/test/cases/adapters/postgresql/sql_types_test.rb (limited to 'activerecord/test') diff --git a/activerecord/test/cases/adapters/postgresql/sql_types_test.rb b/activerecord/test/cases/adapters/postgresql/sql_types_test.rb new file mode 100644 index 0000000000..d7d40f6385 --- /dev/null +++ b/activerecord/test/cases/adapters/postgresql/sql_types_test.rb @@ -0,0 +1,18 @@ +require "cases/helper" + +class SqlTypesTest < ActiveRecord::TestCase + def test_binary_types + assert_equal 'bytea', type_to_sql(:binary, 100_000) + assert_raise ActiveRecord::ActiveRecordError do + type_to_sql :binary, 4294967295 + end + assert_equal 'text', type_to_sql(:text, 100_000) + assert_raise ActiveRecord::ActiveRecordError do + type_to_sql :text, 4294967295 + end + end + + def type_to_sql(*args) + ActiveRecord::Base.connection.type_to_sql(*args) + end +end diff --git a/activerecord/test/schema/postgresql_specific_schema.rb b/activerecord/test/schema/postgresql_specific_schema.rb index 34e24b5a2e..35e12b1875 100644 --- a/activerecord/test/schema/postgresql_specific_schema.rb +++ b/activerecord/test/schema/postgresql_specific_schema.rb @@ -132,5 +132,10 @@ _SQL _SQL rescue #This version of PostgreSQL either has no XML support or is was not compiled with XML support: skipping table end + + create_table :limitless_fields, force: true do |t| + t.binary :binary, limit: 100_000 + t.text :text, limit: 100_000 + end end -- cgit v1.2.3