Commits

Anonymous committed cf93efa Merge

Merge branch 'master' of https://github.com/rails/rails

Comments (0)

Files changed (8)

activerecord/lib/active_record/connection_adapters/abstract_adapter.rb

         # override in derived class
         ActiveRecord::StatementInvalid.new(message)
       end
+
+      def valid_types?(type)
+        true
+      end
     end
   end
 end

activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb

         execute("SET #{encoding} #{variable_assignments}", :skip_logging)
       end
 
+      def valid_type?(type)
+        !native_database_types[type].nil?
+      end  
     end
   end
 end

activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb

         def table_definition
           TableDefinition.new(self)
         end
+
+        def valid_type?(type)
+          !native_database_types[type].nil?
+        end
     end
   end
 end

activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb

           end
         end
 
+        def valid_type?(type)
+          true
+        end
+
     end
   end
 end

activerecord/lib/active_record/schema_dumper.rb

 
           # then dump all non-primary key columns
           column_specs = columns.map do |column|
-            raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" if @types[column.type].nil?
+            raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" unless @connection.valid_type?(column.type)
             next if column.name == pk
             @connection.column_spec(column, @types)
           end.compact

activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb

         eosql
       end
 
+      def test_valid_column
+        column = @conn.column('ex').find { |col| col.name == 'id' }
+        assert @conn.valid_type?(column.type)
+      end
+
+      def test_invalid_column
+        assert !@conn.valid_type?(:foobar)
+      end
+
       def test_client_encoding
         assert_equal Encoding::UTF_8, @conn.client_encoding
       end

activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb

         @connection.exec_query('create table ex(id serial primary key, number integer, data character varying(255))')
       end
 
+      def test_valid_column
+        column = @connection.column('ex').find { |col| col.name == 'id' }
+        assert @connection.valid_type?(column.type)
+      end
+
+      def test_invalid_column
+        assert !@connection.valid_type?(:foobar)
+      end
+
       def test_primary_key
         assert_equal 'id', @connection.primary_key('ex')
       end

activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb

         @conn.intercepted = true
       end
 
+      def test_valid_column
+        column = @conn.column('items').find { |col| col.name == 'id' }
+        assert @conn.valid_type?(column.type)
+      end
+
+      def test_invalid_column
+        assert @conn.valid_type?(:foobar)
+      end
+
       def teardown
         @conn.intercepted = false
         @conn.logged = []