@@ -12,45 +12,45 @@ def @adapter.native_database_types
12
12
end
13
13
14
14
def test_can_set_coder
15
- column = Column . new ( "title" , nil , "varchar(20)" )
15
+ column = Column . new ( "title" , nil , Type :: Value . new , "varchar(20)" )
16
16
column . coder = YAML
17
17
assert_equal YAML , column . coder
18
18
end
19
19
20
20
def test_encoded?
21
- column = Column . new ( "title" , nil , "varchar(20)" )
21
+ column = Column . new ( "title" , nil , Type :: Value . new , "varchar(20)" )
22
22
assert !column . encoded?
23
23
24
24
column . coder = YAML
25
25
assert column . encoded?
26
26
end
27
27
28
28
def test_type_case_coded_column
29
- column = Column . new ( "title" , nil , "varchar(20)" )
29
+ column = Column . new ( "title" , nil , Type :: Value . new , "varchar(20)" )
30
30
column . coder = YAML
31
31
assert_equal "hello" , column . type_cast ( "--- hello" )
32
32
end
33
33
34
34
# Avoid column definitions in create table statements like:
35
35
# `title` varchar(255) DEFAULT NULL
36
36
def test_should_not_include_default_clause_when_default_is_null
37
- column = Column . new ( "title" , nil , "varchar(20)" )
37
+ column = Column . new ( "title" , nil , Type :: Value . new , "varchar(20)" )
38
38
column_def = ColumnDefinition . new (
39
39
column . name , "string" ,
40
40
column . limit , column . precision , column . scale , column . default , column . null )
41
41
assert_equal "title varchar(20)" , @viz . accept ( column_def )
42
42
end
43
43
44
44
def test_should_include_default_clause_when_default_is_present
45
- column = Column . new ( "title" , "Hello" , "varchar(20)" )
45
+ column = Column . new ( "title" , "Hello" , Type :: Value . new , "varchar(20)" )
46
46
column_def = ColumnDefinition . new (
47
47
column . name , "string" ,
48
48
column . limit , column . precision , column . scale , column . default , column . null )
49
49
assert_equal %Q{title varchar(20) DEFAULT 'Hello'} , @viz . accept ( column_def )
50
50
end
51
51
52
52
def test_should_specify_not_null_if_null_option_is_false
53
- column = Column . new ( "title" , "Hello" , "varchar(20)" , false )
53
+ column = Column . new ( "title" , "Hello" , Type :: Value . new , "varchar(20)" , false )
54
54
column_def = ColumnDefinition . new (
55
55
column . name , "string" ,
56
56
column . limit , column . precision , column . scale , column . default , column . null )
@@ -59,68 +59,68 @@ def test_should_specify_not_null_if_null_option_is_false
59
59
60
60
if current_adapter? ( :MysqlAdapter )
61
61
def test_should_set_default_for_mysql_binary_data_types
62
- binary_column = MysqlAdapter ::Column . new ( "title" , "a" , "binary(1)" )
62
+ binary_column = MysqlAdapter ::Column . new ( "title" , "a" , Type :: Value . new , "binary(1)" )
63
63
assert_equal "a" , binary_column . default
64
64
65
- varbinary_column = MysqlAdapter ::Column . new ( "title" , "a" , "varbinary(1)" )
65
+ varbinary_column = MysqlAdapter ::Column . new ( "title" , "a" , Type :: Value . new , "varbinary(1)" )
66
66
assert_equal "a" , varbinary_column . default
67
67
end
68
68
69
69
def test_should_not_set_default_for_blob_and_text_data_types
70
70
assert_raise ArgumentError do
71
- MysqlAdapter ::Column . new ( "title" , "a" , "blob" )
71
+ MysqlAdapter ::Column . new ( "title" , "a" , Type :: Value . new , "blob" )
72
72
end
73
73
74
74
assert_raise ArgumentError do
75
- MysqlAdapter ::Column . new ( "title" , "Hello" , "text" )
75
+ MysqlAdapter ::Column . new ( "title" , "Hello" , Type :: Value . new , "text" )
76
76
end
77
77
78
- text_column = MysqlAdapter ::Column . new ( "title" , nil , "text" )
78
+ text_column = MysqlAdapter ::Column . new ( "title" , nil , Type :: Value . new , "text" )
79
79
assert_equal nil , text_column . default
80
80
81
- not_null_text_column = MysqlAdapter ::Column . new ( "title" , nil , "text" , false )
81
+ not_null_text_column = MysqlAdapter ::Column . new ( "title" , nil , Type :: Value . new , "text" , false )
82
82
assert_equal "" , not_null_text_column . default
83
83
end
84
84
85
85
def test_has_default_should_return_false_for_blob_and_text_data_types
86
- blob_column = MysqlAdapter ::Column . new ( "title" , nil , "blob" )
86
+ blob_column = MysqlAdapter ::Column . new ( "title" , nil , Type :: Value . new , "blob" )
87
87
assert !blob_column . has_default?
88
88
89
- text_column = MysqlAdapter ::Column . new ( "title" , nil , "text" )
89
+ text_column = MysqlAdapter ::Column . new ( "title" , nil , Type :: Value . new , "text" )
90
90
assert !text_column . has_default?
91
91
end
92
92
end
93
93
94
94
if current_adapter? ( :Mysql2Adapter )
95
95
def test_should_set_default_for_mysql_binary_data_types
96
- binary_column = Mysql2Adapter ::Column . new ( "title" , "a" , "binary(1)" )
96
+ binary_column = Mysql2Adapter ::Column . new ( "title" , "a" , Type :: Value . new , "binary(1)" )
97
97
assert_equal "a" , binary_column . default
98
98
99
- varbinary_column = Mysql2Adapter ::Column . new ( "title" , "a" , "varbinary(1)" )
99
+ varbinary_column = Mysql2Adapter ::Column . new ( "title" , "a" , Type :: Value . new , "varbinary(1)" )
100
100
assert_equal "a" , varbinary_column . default
101
101
end
102
102
103
103
def test_should_not_set_default_for_blob_and_text_data_types
104
104
assert_raise ArgumentError do
105
- Mysql2Adapter ::Column . new ( "title" , "a" , "blob" )
105
+ Mysql2Adapter ::Column . new ( "title" , "a" , Type :: Value . new , "blob" )
106
106
end
107
107
108
108
assert_raise ArgumentError do
109
- Mysql2Adapter ::Column . new ( "title" , "Hello" , "text" )
109
+ Mysql2Adapter ::Column . new ( "title" , "Hello" , Type :: Value . new , "text" )
110
110
end
111
111
112
- text_column = Mysql2Adapter ::Column . new ( "title" , nil , "text" )
112
+ text_column = Mysql2Adapter ::Column . new ( "title" , nil , Type :: Value . new , "text" )
113
113
assert_equal nil , text_column . default
114
114
115
- not_null_text_column = Mysql2Adapter ::Column . new ( "title" , nil , "text" , false )
115
+ not_null_text_column = Mysql2Adapter ::Column . new ( "title" , nil , Type :: Value . new , "text" , false )
116
116
assert_equal "" , not_null_text_column . default
117
117
end
118
118
119
119
def test_has_default_should_return_false_for_blob_and_text_data_types
120
- blob_column = Mysql2Adapter ::Column . new ( "title" , nil , "blob" )
120
+ blob_column = Mysql2Adapter ::Column . new ( "title" , nil , Type :: Value . new , "blob" )
121
121
assert !blob_column . has_default?
122
122
123
- text_column = Mysql2Adapter ::Column . new ( "title" , nil , "text" )
123
+ text_column = Mysql2Adapter ::Column . new ( "title" , nil , Type :: Value . new , "text" )
124
124
assert !text_column . has_default?
125
125
end
126
126
end
0 commit comments