From d0bd3b5af4a796d8f0b83815a3f164ae811c0626 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 12 Jun 2005 06:56:51 +0000 Subject: Return PostgreSQL columns in the order they are declared #1374 (perlguy@gmail.com). Unit test column order, adapter housekeeping, simplify users of columns_hash. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1405 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/fixtures/db_definitions/postgresql.sql | 2 +- activerecord/test/reflection_test.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'activerecord/test') diff --git a/activerecord/test/fixtures/db_definitions/postgresql.sql b/activerecord/test/fixtures/db_definitions/postgresql.sql index 2fd210cb1b..6eb2304957 100644 --- a/activerecord/test/fixtures/db_definitions/postgresql.sql +++ b/activerecord/test/fixtures/db_definitions/postgresql.sql @@ -50,10 +50,10 @@ CREATE TABLE topics ( bonus_time time, last_read date, content text, + approved smallint DEFAULT 1, replies_count integer default 0, parent_id integer, "type" character varying(50), - approved smallint DEFAULT 1, PRIMARY KEY (id) ); SELECT setval('topics_id_seq', 100); diff --git a/activerecord/test/reflection_test.rb b/activerecord/test/reflection_test.rb index a892fb4acb..1658408d7a 100644 --- a/activerecord/test/reflection_test.rb +++ b/activerecord/test/reflection_test.rb @@ -22,6 +22,11 @@ class ReflectionTest < Test::Unit::TestCase assert_equal 12, Topic.columns.length end + def test_columns_are_returned_in_the_order_they_were_declared + column_names = Topic.columns.map { |column| column.name } + assert_equal %w(id title author_name author_email_address written_on bonus_time last_read content approved replies_count parent_id type), column_names + end + def test_content_columns assert_equal 8, Topic.content_columns.length end -- cgit v1.2.3