Sha256: 1270762540d4ffd6c051bbc168e8f1cfc32cef0a211e27db319dd98c9c27afa3
Contents?: true
Size: 1.59 KB
Versions: 37
Compression:
Stored size: 1.59 KB
Contents
require "cases/helper" class ColumnDefinitionTest < ActiveRecord::TestCase def setup @adapter = ActiveRecord::ConnectionAdapters::AbstractAdapter.new(nil) def @adapter.native_database_types {:string => "varchar"} end end # Avoid column definitions in create table statements like: # `title` varchar(255) DEFAULT NULL def test_should_not_include_default_clause_when_default_is_null column = ActiveRecord::ConnectionAdapters::Column.new("title", nil, "varchar(20)") column_def = ActiveRecord::ConnectionAdapters::ColumnDefinition.new( @adapter, column.name, "string", column.limit, column.precision, column.scale, column.default, column.null) assert_equal "title varchar(20)", column_def.to_sql end def test_should_include_default_clause_when_default_is_present column = ActiveRecord::ConnectionAdapters::Column.new("title", "Hello", "varchar(20)") column_def = ActiveRecord::ConnectionAdapters::ColumnDefinition.new( @adapter, column.name, "string", column.limit, column.precision, column.scale, column.default, column.null) assert_equal %Q{title varchar(20) DEFAULT 'Hello'}, column_def.to_sql end def test_should_specify_not_null_if_null_option_is_false column = ActiveRecord::ConnectionAdapters::Column.new("title", "Hello", "varchar(20)", false) column_def = ActiveRecord::ConnectionAdapters::ColumnDefinition.new( @adapter, column.name, "string", column.limit, column.precision, column.scale, column.default, column.null) assert_equal %Q{title varchar(20) DEFAULT 'Hello' NOT NULL}, column_def.to_sql end end
Version data entries
37 entries across 34 versions & 10 rubygems