ibm_db 2.5.27-x86-mingw32 → 2.6.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +5 -0
  3. data/MANIFEST +14 -14
  4. data/README +225 -225
  5. data/ext/Makefile.nt32 +181 -181
  6. data/ext/Makefile.nt32.191 +212 -212
  7. data/ext/extconf.rb +264 -264
  8. data/ext/extconf_MacOS.rb +269 -0
  9. data/ext/ibm_db.c +1 -1
  10. data/ext/ruby_ibm_db.h +241 -241
  11. data/init.rb +41 -41
  12. data/lib/IBM_DB.rb +27 -3
  13. data/lib/active_record/connection_adapters/ibm_db_adapter.rb +3290 -3290
  14. data/lib/active_record/connection_adapters/ibmdb_adapter.rb +1 -1
  15. data/lib/active_record/vendor/db2-i5-zOS.yaml +328 -328
  16. data/lib/mswin32/ibm_db.rb +104 -20
  17. data/lib/mswin32/rb19x/ibm_db.so +0 -0
  18. data/lib/mswin32/rb21x/i386/ibm_db.so +0 -0
  19. data/lib/mswin32/rb22x/i386/ibm_db.so +0 -0
  20. data/lib/mswin32/rb2x/i386/ibm_db.so +0 -0
  21. data/test/cases/adapter_test.rb +207 -207
  22. data/test/cases/associations/belongs_to_associations_test.rb +711 -711
  23. data/test/cases/associations/cascaded_eager_loading_test.rb +181 -181
  24. data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +851 -851
  25. data/test/cases/associations/join_model_test.rb +743 -743
  26. data/test/cases/attribute_methods_test.rb +822 -822
  27. data/test/cases/base_test.rb +2133 -2133
  28. data/test/cases/calculations_test.rb +482 -482
  29. data/test/cases/migration_test.rb +2408 -2408
  30. data/test/cases/persistence_test.rb +642 -642
  31. data/test/cases/query_cache_test.rb +257 -257
  32. data/test/cases/relations_test.rb +1182 -1182
  33. data/test/cases/schema_dumper_test.rb +256 -256
  34. data/test/cases/transaction_callbacks_test.rb +300 -300
  35. data/test/cases/validations/uniqueness_validation_test.rb +299 -299
  36. data/test/cases/xml_serialization_test.rb +408 -408
  37. data/test/config.yml +154 -154
  38. data/test/connections/native_ibm_db/connection.rb +43 -43
  39. data/test/ibm_db_test.rb +24 -24
  40. data/test/models/warehouse_thing.rb +4 -4
  41. data/test/schema/schema.rb +751 -751
  42. metadata +31 -16
@@ -1,256 +1,256 @@
1
- require "cases/helper"
2
-
3
-
4
- class SchemaDumperTest < ActiveRecord::TestCase
5
- def setup
6
- @stream = StringIO.new
7
- end
8
-
9
- def standard_dump
10
- @stream = StringIO.new
11
- ActiveRecord::SchemaDumper.ignore_tables = []
12
- ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, @stream)
13
- @stream.string
14
- end
15
-
16
- if "string".encoding_aware?
17
- def test_magic_comment
18
- assert_match "# encoding: #{@stream.external_encoding.name}", standard_dump
19
- end
20
- end
21
-
22
- def test_schema_dump
23
- output = standard_dump
24
- assert_match %r{create_table "accounts"}, output
25
- assert_match %r{create_table "authors"}, output
26
- assert_no_match %r{create_table "schema_migrations"}, output
27
- end
28
-
29
- def test_schema_dump_excludes_sqlite_sequence
30
- output = standard_dump
31
- assert_no_match %r{create_table "sqlite_sequence"}, output
32
- end
33
-
34
- def test_schema_dump_includes_camelcase_table_name
35
- output = standard_dump
36
- if current_adapter?(:IBM_DBAdapter)
37
- #DB2 is case insensitive
38
- assert_match %r{create_table "camelcase"}, output
39
- else
40
- assert_match %r{create_table "CamelCase"}, output
41
- end
42
- end
43
-
44
- def assert_line_up(lines, pattern, required = false)
45
- return assert(true) if lines.empty?
46
- matches = lines.map { |line| line.match(pattern) }
47
- assert matches.all? if required
48
- matches.compact!
49
- return assert(true) if matches.empty?
50
- assert_equal 1, matches.map{ |match| match.offset(0).first }.uniq.length
51
- end
52
-
53
- def column_definition_lines(output = standard_dump)
54
- output.scan(/^( *)create_table.*?\n(.*?)^\1end/m).map{ |m| m.last.split(/\n/) }
55
- end
56
-
57
- def test_types_line_up
58
- column_definition_lines.each do |column_set|
59
- next if column_set.empty?
60
-
61
- lengths = column_set.map do |column|
62
- if match = column.match(/t\.(?:integer|decimal|float|datetime|timestamp|time|date|text|binary|string|boolean)\s+"/)
63
- match[0].length
64
- end
65
- end
66
-
67
- assert_equal 1, lengths.uniq.length
68
- end
69
- end
70
-
71
- def test_arguments_line_up
72
- column_definition_lines.each do |column_set|
73
- assert_line_up(column_set, /:default => /)
74
- assert_line_up(column_set, /:limit => /)
75
- assert_line_up(column_set, /:null => /)
76
- end
77
- end
78
-
79
- def test_no_dump_errors
80
- output = standard_dump
81
- assert_no_match %r{\# Could not dump table}, output
82
- end
83
-
84
- def test_schema_dump_includes_not_null_columns
85
- stream = StringIO.new
86
-
87
- ActiveRecord::SchemaDumper.ignore_tables = [/^[^r]/]
88
- ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
89
- output = stream.string
90
- assert_match %r{:null => false}, output
91
- end
92
-
93
- def test_schema_dump_includes_limit_constraint_for_integer_columns
94
- stream = StringIO.new
95
-
96
- ActiveRecord::SchemaDumper.ignore_tables = [/^(?!integer_limits)/]
97
- ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
98
- output = stream.string
99
-
100
- if current_adapter?(:PostgreSQLAdapter)
101
- assert_match %r{c_int_1.*:limit => 2}, output
102
- assert_match %r{c_int_2.*:limit => 2}, output
103
-
104
- # int 3 is 4 bytes in postgresql
105
- assert_match %r{c_int_3.*}, output
106
- assert_no_match %r{c_int_3.*:limit}, output
107
-
108
- assert_match %r{c_int_4.*}, output
109
- assert_no_match %r{c_int_4.*:limit}, output
110
- elsif current_adapter?(:MysqlAdapter) or current_adapter?(:Mysql2Adapter)
111
- assert_match %r{c_int_1.*:limit => 1}, output
112
- assert_match %r{c_int_2.*:limit => 2}, output
113
- assert_match %r{c_int_3.*:limit => 3}, output
114
-
115
- assert_match %r{c_int_4.*}, output
116
- assert_no_match %r{c_int_4.*:limit}, output
117
- elsif current_adapter?(:SQLite3Adapter)
118
- assert_match %r{c_int_1.*:limit => 1}, output
119
- assert_match %r{c_int_2.*:limit => 2}, output
120
- assert_match %r{c_int_3.*:limit => 3}, output
121
- assert_match %r{c_int_4.*:limit => 4}, output
122
- end
123
- assert_match %r{c_int_without_limit.*}, output
124
- assert_no_match %r{c_int_without_limit.*:limit}, output
125
-
126
- if current_adapter?(:SQLite3Adapter)
127
- assert_match %r{c_int_5.*:limit => 5}, output
128
- assert_match %r{c_int_6.*:limit => 6}, output
129
- assert_match %r{c_int_7.*:limit => 7}, output
130
- assert_match %r{c_int_8.*:limit => 8}, output
131
- elsif current_adapter?(:OracleAdapter)
132
- assert_match %r{c_int_5.*:limit => 5}, output
133
- assert_match %r{c_int_6.*:limit => 6}, output
134
- assert_match %r{c_int_7.*:limit => 7}, output
135
- assert_match %r{c_int_8.*:limit => 8}, output
136
- elsif current_adapter?(:IBM_DBAdapter)
137
- #Limits is not supported on integer column by DB2
138
- else
139
- assert_match %r{c_int_5.*:limit => 8}, output
140
- assert_match %r{c_int_6.*:limit => 8}, output
141
- assert_match %r{c_int_7.*:limit => 8}, output
142
- assert_match %r{c_int_8.*:limit => 8}, output
143
- end
144
- end
145
-
146
- def test_schema_dump_with_string_ignored_table
147
- stream = StringIO.new
148
-
149
- ActiveRecord::SchemaDumper.ignore_tables = ['accounts']
150
- ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
151
- output = stream.string
152
- assert_no_match %r{create_table "accounts"}, output
153
- assert_match %r{create_table "authors"}, output
154
- assert_no_match %r{create_table "schema_migrations"}, output
155
- end
156
-
157
- def test_schema_dump_with_regexp_ignored_table
158
- stream = StringIO.new
159
-
160
- ActiveRecord::SchemaDumper.ignore_tables = [/^account/]
161
- ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
162
- output = stream.string
163
- assert_no_match %r{create_table "accounts"}, output
164
- assert_match %r{create_table "authors"}, output
165
- assert_no_match %r{create_table "schema_migrations"}, output
166
- end
167
-
168
- def test_schema_dump_illegal_ignored_table_value
169
- stream = StringIO.new
170
- ActiveRecord::SchemaDumper.ignore_tables = [5]
171
- assert_raise(StandardError) do
172
- ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
173
- end
174
- end
175
-
176
- def test_schema_dumps_index_columns_in_right_order
177
- index_definition = standard_dump.split(/\n/).grep(/add_index.*companies/).first.strip
178
- assert_equal 'add_index "companies", ["firm_id", "type", "rating", "ruby_type"], :name => "company_index"', index_definition
179
- end
180
-
181
- def test_schema_dump_should_honor_nonstandard_primary_keys
182
- output = standard_dump
183
- match = output.match(%r{create_table "movies"(.*)do})
184
- assert_not_nil(match, "nonstandardpk table not found")
185
- assert_match %r(:primary_key => "movieid"), match[1], "non-standard primary key not preserved"
186
- end
187
-
188
- if current_adapter?(:MysqlAdapter) or current_adapter?(:Mysql2Adapter)
189
- def test_schema_dump_should_not_add_default_value_for_mysql_text_field
190
- output = standard_dump
191
- assert_match %r{t.text\s+"body",\s+:null => false$}, output
192
- end
193
-
194
- def test_schema_dump_includes_length_for_mysql_blob_and_text_fields
195
- output = standard_dump
196
- assert_match %r{t.binary\s+"tiny_blob",\s+:limit => 255$}, output
197
- assert_match %r{t.binary\s+"normal_blob"$}, output
198
- assert_match %r{t.binary\s+"medium_blob",\s+:limit => 16777215$}, output
199
- assert_match %r{t.binary\s+"long_blob",\s+:limit => 2147483647$}, output
200
- assert_match %r{t.text\s+"tiny_text",\s+:limit => 255$}, output
201
- assert_match %r{t.text\s+"normal_text"$}, output
202
- assert_match %r{t.text\s+"medium_text",\s+:limit => 16777215$}, output
203
- assert_match %r{t.text\s+"long_text",\s+:limit => 2147483647$}, output
204
- end
205
- end
206
-
207
- def test_schema_dump_includes_decimal_options
208
- stream = StringIO.new
209
- ActiveRecord::SchemaDumper.ignore_tables = [/^[^n]/]
210
- ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
211
- output = stream.string
212
- assert_match %r{:precision => 3,[[:space:]]+:scale => 2,[[:space:]]+:default => 2.78}, output
213
- end
214
-
215
- if current_adapter?(:PostgreSQLAdapter)
216
- def test_schema_dump_includes_xml_shorthand_definition
217
- output = standard_dump
218
- if %r{create_table "postgresql_xml_data_type"} =~ output
219
- assert_match %r{t.xml "data"}, output
220
- end
221
- end
222
-
223
- def test_schema_dump_includes_tsvector_shorthand_definition
224
- output = standard_dump
225
- if %r{create_table "postgresql_tsvectors"} =~ output
226
- assert_match %r{t.tsvector "text_vector"}, output
227
- end
228
- end
229
- end
230
-
231
- def test_schema_dump_keeps_large_precision_integer_columns_as_decimal
232
- output = standard_dump
233
- # Oracle supports precision up to 38 and it identifies decimals with scale 0 as integers
234
- if current_adapter?(:OracleAdapter)
235
- assert_match %r{t.integer\s+"atoms_in_universe",\s+:precision => 38,\s+:scale => 0}, output
236
- elsif current_adapter?(:IBM_DBAdapter)
237
- # DB2 supports precision up to 31
238
- assert_match %r{t.decimal\s+"atoms_in_universe",\s+:precision => 31,\s+:scale => 0}, output
239
- else
240
- assert_match %r{t.decimal\s+"atoms_in_universe",\s+:precision => 55,\s+:scale => 0}, output
241
- end
242
- end
243
-
244
- def test_schema_dump_keeps_id_column_when_id_is_false_and_id_column_added
245
- output = standard_dump
246
- match = output.match(%r{create_table "goofy_string_id"(.*)do.*\n(.*)\n})
247
- assert_not_nil(match, "goofy_string_id table not found")
248
- assert_match %r(:id => false), match[1], "no table id not preserved"
249
- assert_match %r{t.string[[:space:]]+"id",[[:space:]]+:null => false$}, match[2], "non-primary key id column not preserved"
250
- end
251
-
252
- def test_schema_dump_keeps_id_false_when_id_is_false_and_unique_not_null_column_added
253
- output = standard_dump
254
- assert_match %r{create_table "subscribers", :id => false}, output
255
- end
256
- end
1
+ require "cases/helper"
2
+
3
+
4
+ class SchemaDumperTest < ActiveRecord::TestCase
5
+ def setup
6
+ @stream = StringIO.new
7
+ end
8
+
9
+ def standard_dump
10
+ @stream = StringIO.new
11
+ ActiveRecord::SchemaDumper.ignore_tables = []
12
+ ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, @stream)
13
+ @stream.string
14
+ end
15
+
16
+ if "string".encoding_aware?
17
+ def test_magic_comment
18
+ assert_match "# encoding: #{@stream.external_encoding.name}", standard_dump
19
+ end
20
+ end
21
+
22
+ def test_schema_dump
23
+ output = standard_dump
24
+ assert_match %r{create_table "accounts"}, output
25
+ assert_match %r{create_table "authors"}, output
26
+ assert_no_match %r{create_table "schema_migrations"}, output
27
+ end
28
+
29
+ def test_schema_dump_excludes_sqlite_sequence
30
+ output = standard_dump
31
+ assert_no_match %r{create_table "sqlite_sequence"}, output
32
+ end
33
+
34
+ def test_schema_dump_includes_camelcase_table_name
35
+ output = standard_dump
36
+ if current_adapter?(:IBM_DBAdapter)
37
+ #DB2 is case insensitive
38
+ assert_match %r{create_table "camelcase"}, output
39
+ else
40
+ assert_match %r{create_table "CamelCase"}, output
41
+ end
42
+ end
43
+
44
+ def assert_line_up(lines, pattern, required = false)
45
+ return assert(true) if lines.empty?
46
+ matches = lines.map { |line| line.match(pattern) }
47
+ assert matches.all? if required
48
+ matches.compact!
49
+ return assert(true) if matches.empty?
50
+ assert_equal 1, matches.map{ |match| match.offset(0).first }.uniq.length
51
+ end
52
+
53
+ def column_definition_lines(output = standard_dump)
54
+ output.scan(/^( *)create_table.*?\n(.*?)^\1end/m).map{ |m| m.last.split(/\n/) }
55
+ end
56
+
57
+ def test_types_line_up
58
+ column_definition_lines.each do |column_set|
59
+ next if column_set.empty?
60
+
61
+ lengths = column_set.map do |column|
62
+ if match = column.match(/t\.(?:integer|decimal|float|datetime|timestamp|time|date|text|binary|string|boolean)\s+"/)
63
+ match[0].length
64
+ end
65
+ end
66
+
67
+ assert_equal 1, lengths.uniq.length
68
+ end
69
+ end
70
+
71
+ def test_arguments_line_up
72
+ column_definition_lines.each do |column_set|
73
+ assert_line_up(column_set, /:default => /)
74
+ assert_line_up(column_set, /:limit => /)
75
+ assert_line_up(column_set, /:null => /)
76
+ end
77
+ end
78
+
79
+ def test_no_dump_errors
80
+ output = standard_dump
81
+ assert_no_match %r{\# Could not dump table}, output
82
+ end
83
+
84
+ def test_schema_dump_includes_not_null_columns
85
+ stream = StringIO.new
86
+
87
+ ActiveRecord::SchemaDumper.ignore_tables = [/^[^r]/]
88
+ ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
89
+ output = stream.string
90
+ assert_match %r{:null => false}, output
91
+ end
92
+
93
+ def test_schema_dump_includes_limit_constraint_for_integer_columns
94
+ stream = StringIO.new
95
+
96
+ ActiveRecord::SchemaDumper.ignore_tables = [/^(?!integer_limits)/]
97
+ ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
98
+ output = stream.string
99
+
100
+ if current_adapter?(:PostgreSQLAdapter)
101
+ assert_match %r{c_int_1.*:limit => 2}, output
102
+ assert_match %r{c_int_2.*:limit => 2}, output
103
+
104
+ # int 3 is 4 bytes in postgresql
105
+ assert_match %r{c_int_3.*}, output
106
+ assert_no_match %r{c_int_3.*:limit}, output
107
+
108
+ assert_match %r{c_int_4.*}, output
109
+ assert_no_match %r{c_int_4.*:limit}, output
110
+ elsif current_adapter?(:MysqlAdapter) or current_adapter?(:Mysql2Adapter)
111
+ assert_match %r{c_int_1.*:limit => 1}, output
112
+ assert_match %r{c_int_2.*:limit => 2}, output
113
+ assert_match %r{c_int_3.*:limit => 3}, output
114
+
115
+ assert_match %r{c_int_4.*}, output
116
+ assert_no_match %r{c_int_4.*:limit}, output
117
+ elsif current_adapter?(:SQLite3Adapter)
118
+ assert_match %r{c_int_1.*:limit => 1}, output
119
+ assert_match %r{c_int_2.*:limit => 2}, output
120
+ assert_match %r{c_int_3.*:limit => 3}, output
121
+ assert_match %r{c_int_4.*:limit => 4}, output
122
+ end
123
+ assert_match %r{c_int_without_limit.*}, output
124
+ assert_no_match %r{c_int_without_limit.*:limit}, output
125
+
126
+ if current_adapter?(:SQLite3Adapter)
127
+ assert_match %r{c_int_5.*:limit => 5}, output
128
+ assert_match %r{c_int_6.*:limit => 6}, output
129
+ assert_match %r{c_int_7.*:limit => 7}, output
130
+ assert_match %r{c_int_8.*:limit => 8}, output
131
+ elsif current_adapter?(:OracleAdapter)
132
+ assert_match %r{c_int_5.*:limit => 5}, output
133
+ assert_match %r{c_int_6.*:limit => 6}, output
134
+ assert_match %r{c_int_7.*:limit => 7}, output
135
+ assert_match %r{c_int_8.*:limit => 8}, output
136
+ elsif current_adapter?(:IBM_DBAdapter)
137
+ #Limits is not supported on integer column by DB2
138
+ else
139
+ assert_match %r{c_int_5.*:limit => 8}, output
140
+ assert_match %r{c_int_6.*:limit => 8}, output
141
+ assert_match %r{c_int_7.*:limit => 8}, output
142
+ assert_match %r{c_int_8.*:limit => 8}, output
143
+ end
144
+ end
145
+
146
+ def test_schema_dump_with_string_ignored_table
147
+ stream = StringIO.new
148
+
149
+ ActiveRecord::SchemaDumper.ignore_tables = ['accounts']
150
+ ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
151
+ output = stream.string
152
+ assert_no_match %r{create_table "accounts"}, output
153
+ assert_match %r{create_table "authors"}, output
154
+ assert_no_match %r{create_table "schema_migrations"}, output
155
+ end
156
+
157
+ def test_schema_dump_with_regexp_ignored_table
158
+ stream = StringIO.new
159
+
160
+ ActiveRecord::SchemaDumper.ignore_tables = [/^account/]
161
+ ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
162
+ output = stream.string
163
+ assert_no_match %r{create_table "accounts"}, output
164
+ assert_match %r{create_table "authors"}, output
165
+ assert_no_match %r{create_table "schema_migrations"}, output
166
+ end
167
+
168
+ def test_schema_dump_illegal_ignored_table_value
169
+ stream = StringIO.new
170
+ ActiveRecord::SchemaDumper.ignore_tables = [5]
171
+ assert_raise(StandardError) do
172
+ ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
173
+ end
174
+ end
175
+
176
+ def test_schema_dumps_index_columns_in_right_order
177
+ index_definition = standard_dump.split(/\n/).grep(/add_index.*companies/).first.strip
178
+ assert_equal 'add_index "companies", ["firm_id", "type", "rating", "ruby_type"], :name => "company_index"', index_definition
179
+ end
180
+
181
+ def test_schema_dump_should_honor_nonstandard_primary_keys
182
+ output = standard_dump
183
+ match = output.match(%r{create_table "movies"(.*)do})
184
+ assert_not_nil(match, "nonstandardpk table not found")
185
+ assert_match %r(:primary_key => "movieid"), match[1], "non-standard primary key not preserved"
186
+ end
187
+
188
+ if current_adapter?(:MysqlAdapter) or current_adapter?(:Mysql2Adapter)
189
+ def test_schema_dump_should_not_add_default_value_for_mysql_text_field
190
+ output = standard_dump
191
+ assert_match %r{t.text\s+"body",\s+:null => false$}, output
192
+ end
193
+
194
+ def test_schema_dump_includes_length_for_mysql_blob_and_text_fields
195
+ output = standard_dump
196
+ assert_match %r{t.binary\s+"tiny_blob",\s+:limit => 255$}, output
197
+ assert_match %r{t.binary\s+"normal_blob"$}, output
198
+ assert_match %r{t.binary\s+"medium_blob",\s+:limit => 16777215$}, output
199
+ assert_match %r{t.binary\s+"long_blob",\s+:limit => 2147483647$}, output
200
+ assert_match %r{t.text\s+"tiny_text",\s+:limit => 255$}, output
201
+ assert_match %r{t.text\s+"normal_text"$}, output
202
+ assert_match %r{t.text\s+"medium_text",\s+:limit => 16777215$}, output
203
+ assert_match %r{t.text\s+"long_text",\s+:limit => 2147483647$}, output
204
+ end
205
+ end
206
+
207
+ def test_schema_dump_includes_decimal_options
208
+ stream = StringIO.new
209
+ ActiveRecord::SchemaDumper.ignore_tables = [/^[^n]/]
210
+ ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
211
+ output = stream.string
212
+ assert_match %r{:precision => 3,[[:space:]]+:scale => 2,[[:space:]]+:default => 2.78}, output
213
+ end
214
+
215
+ if current_adapter?(:PostgreSQLAdapter)
216
+ def test_schema_dump_includes_xml_shorthand_definition
217
+ output = standard_dump
218
+ if %r{create_table "postgresql_xml_data_type"} =~ output
219
+ assert_match %r{t.xml "data"}, output
220
+ end
221
+ end
222
+
223
+ def test_schema_dump_includes_tsvector_shorthand_definition
224
+ output = standard_dump
225
+ if %r{create_table "postgresql_tsvectors"} =~ output
226
+ assert_match %r{t.tsvector "text_vector"}, output
227
+ end
228
+ end
229
+ end
230
+
231
+ def test_schema_dump_keeps_large_precision_integer_columns_as_decimal
232
+ output = standard_dump
233
+ # Oracle supports precision up to 38 and it identifies decimals with scale 0 as integers
234
+ if current_adapter?(:OracleAdapter)
235
+ assert_match %r{t.integer\s+"atoms_in_universe",\s+:precision => 38,\s+:scale => 0}, output
236
+ elsif current_adapter?(:IBM_DBAdapter)
237
+ # DB2 supports precision up to 31
238
+ assert_match %r{t.decimal\s+"atoms_in_universe",\s+:precision => 31,\s+:scale => 0}, output
239
+ else
240
+ assert_match %r{t.decimal\s+"atoms_in_universe",\s+:precision => 55,\s+:scale => 0}, output
241
+ end
242
+ end
243
+
244
+ def test_schema_dump_keeps_id_column_when_id_is_false_and_id_column_added
245
+ output = standard_dump
246
+ match = output.match(%r{create_table "goofy_string_id"(.*)do.*\n(.*)\n})
247
+ assert_not_nil(match, "goofy_string_id table not found")
248
+ assert_match %r(:id => false), match[1], "no table id not preserved"
249
+ assert_match %r{t.string[[:space:]]+"id",[[:space:]]+:null => false$}, match[2], "non-primary key id column not preserved"
250
+ end
251
+
252
+ def test_schema_dump_keeps_id_false_when_id_is_false_and_unique_not_null_column_added
253
+ output = standard_dump
254
+ assert_match %r{create_table "subscribers", :id => false}, output
255
+ end
256
+ end