sequel 4.22.0 → 4.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +22 -0
  3. data/README.rdoc +6 -0
  4. data/Rakefile +59 -81
  5. data/doc/migration.rdoc +2 -0
  6. data/doc/release_notes/4.23.0.txt +65 -0
  7. data/doc/sharding.rdoc +16 -14
  8. data/doc/testing.rdoc +61 -77
  9. data/lib/sequel/adapters/jdbc.rb +1 -0
  10. data/lib/sequel/adapters/mock.rb +0 -1
  11. data/lib/sequel/adapters/postgres.rb +1 -0
  12. data/lib/sequel/adapters/postgresql.rb +1 -0
  13. data/lib/sequel/adapters/shared/postgres.rb +3 -3
  14. data/lib/sequel/connection_pool/sharded_threaded.rb +5 -0
  15. data/lib/sequel/connection_pool/threaded.rb +9 -1
  16. data/lib/sequel/database/connecting.rb +1 -1
  17. data/lib/sequel/database/transactions.rb +2 -1
  18. data/lib/sequel/dataset/prepared_statements.rb +1 -1
  19. data/lib/sequel/extensions/constraint_validations.rb +12 -12
  20. data/lib/sequel/extensions/date_arithmetic.rb +0 -4
  21. data/lib/sequel/extensions/pagination.rb +14 -2
  22. data/lib/sequel/extensions/pg_enum.rb +2 -2
  23. data/lib/sequel/extensions/pg_hstore.rb +1 -1
  24. data/lib/sequel/extensions/pg_json_ops.rb +2 -2
  25. data/lib/sequel/plugins/csv_serializer.rb +2 -0
  26. data/lib/sequel/plugins/delay_add_association.rb +50 -0
  27. data/lib/sequel/plugins/list.rb +2 -2
  28. data/lib/sequel/plugins/nested_attributes.rb +8 -28
  29. data/lib/sequel/plugins/update_refresh.rb +50 -0
  30. data/lib/sequel/plugins/validate_associated.rb +55 -0
  31. data/lib/sequel/version.rb +1 -1
  32. data/spec/adapters/db2_spec.rb +29 -29
  33. data/spec/adapters/firebird_spec.rb +97 -103
  34. data/spec/adapters/informix_spec.rb +25 -25
  35. data/spec/adapters/mssql_spec.rb +156 -172
  36. data/spec/adapters/mysql_spec.rb +334 -359
  37. data/spec/adapters/oracle_spec.rb +67 -69
  38. data/spec/adapters/postgres_spec.rb +1298 -1249
  39. data/spec/adapters/spec_helper.rb +2 -35
  40. data/spec/adapters/sqlanywhere_spec.rb +39 -39
  41. data/spec/adapters/sqlite_spec.rb +203 -200
  42. data/spec/bin_spec.rb +57 -59
  43. data/spec/core/connection_pool_spec.rb +402 -401
  44. data/spec/core/database_spec.rb +953 -944
  45. data/spec/core/dataset_spec.rb +2178 -2168
  46. data/spec/core/deprecated_spec.rb +19 -19
  47. data/spec/core/expression_filters_spec.rb +415 -415
  48. data/spec/core/mock_adapter_spec.rb +212 -212
  49. data/spec/core/object_graph_spec.rb +73 -73
  50. data/spec/core/placeholder_literalizer_spec.rb +71 -71
  51. data/spec/core/schema_generator_spec.rb +44 -44
  52. data/spec/core/schema_spec.rb +470 -472
  53. data/spec/core/spec_helper.rb +5 -20
  54. data/spec/core/version_spec.rb +2 -2
  55. data/spec/core_extensions_spec.rb +320 -320
  56. data/spec/extensions/accessed_columns_spec.rb +12 -12
  57. data/spec/extensions/active_model_spec.rb +3 -3
  58. data/spec/extensions/after_initialize_spec.rb +2 -2
  59. data/spec/extensions/arbitrary_servers_spec.rb +23 -23
  60. data/spec/extensions/association_dependencies_spec.rb +34 -34
  61. data/spec/extensions/association_pks_spec.rb +98 -98
  62. data/spec/extensions/association_proxies_spec.rb +33 -33
  63. data/spec/extensions/auto_validations_spec.rb +46 -46
  64. data/spec/extensions/blacklist_security_spec.rb +19 -18
  65. data/spec/extensions/blank_spec.rb +36 -36
  66. data/spec/extensions/boolean_readers_spec.rb +36 -36
  67. data/spec/extensions/caching_spec.rb +82 -82
  68. data/spec/extensions/class_table_inheritance_spec.rb +72 -72
  69. data/spec/extensions/column_conflicts_spec.rb +19 -14
  70. data/spec/extensions/column_select_spec.rb +19 -19
  71. data/spec/extensions/columns_introspection_spec.rb +43 -43
  72. data/spec/extensions/composition_spec.rb +64 -64
  73. data/spec/extensions/connection_validator_spec.rb +92 -90
  74. data/spec/extensions/constraint_validations_plugin_spec.rb +92 -92
  75. data/spec/extensions/constraint_validations_spec.rb +80 -80
  76. data/spec/extensions/core_refinements_spec.rb +220 -220
  77. data/spec/extensions/csv_serializer_spec.rb +44 -44
  78. data/spec/extensions/current_datetime_timestamp_spec.rb +8 -8
  79. data/spec/extensions/dataset_associations_spec.rb +65 -65
  80. data/spec/extensions/dataset_source_alias_spec.rb +16 -16
  81. data/spec/extensions/date_arithmetic_spec.rb +51 -58
  82. data/spec/extensions/defaults_setter_spec.rb +19 -19
  83. data/spec/extensions/delay_add_association_spec.rb +52 -0
  84. data/spec/extensions/dirty_spec.rb +51 -51
  85. data/spec/extensions/eager_each_spec.rb +8 -8
  86. data/spec/extensions/empty_array_ignore_nulls_spec.rb +10 -10
  87. data/spec/extensions/error_splitter_spec.rb +2 -2
  88. data/spec/extensions/error_sql_spec.rb +4 -4
  89. data/spec/extensions/eval_inspect_spec.rb +3 -3
  90. data/spec/extensions/filter_having_spec.rb +8 -8
  91. data/spec/extensions/force_encoding_spec.rb +30 -30
  92. data/spec/extensions/from_block_spec.rb +7 -7
  93. data/spec/extensions/graph_each_spec.rb +19 -19
  94. data/spec/extensions/hash_aliases_spec.rb +5 -5
  95. data/spec/extensions/hook_class_methods_spec.rb +100 -100
  96. data/spec/extensions/inflector_spec.rb +54 -54
  97. data/spec/extensions/input_transformer_spec.rb +10 -10
  98. data/spec/extensions/insert_returning_select_spec.rb +8 -8
  99. data/spec/extensions/instance_filters_spec.rb +26 -26
  100. data/spec/extensions/instance_hooks_spec.rb +85 -85
  101. data/spec/extensions/json_serializer_spec.rb +68 -68
  102. data/spec/extensions/lazy_attributes_spec.rb +49 -49
  103. data/spec/extensions/list_spec.rb +77 -75
  104. data/spec/extensions/looser_typecasting_spec.rb +16 -16
  105. data/spec/extensions/many_through_many_spec.rb +627 -627
  106. data/spec/extensions/meta_def_spec.rb +7 -7
  107. data/spec/extensions/migration_spec.rb +217 -217
  108. data/spec/extensions/modification_detection_spec.rb +20 -20
  109. data/spec/extensions/mssql_optimistic_locking_spec.rb +21 -21
  110. data/spec/extensions/named_timezones_spec.rb +18 -18
  111. data/spec/extensions/nested_attributes_spec.rb +107 -107
  112. data/spec/extensions/null_dataset_spec.rb +24 -24
  113. data/spec/extensions/optimistic_locking_spec.rb +21 -21
  114. data/spec/extensions/pagination_spec.rb +52 -52
  115. data/spec/extensions/pg_array_associations_spec.rb +273 -273
  116. data/spec/extensions/pg_array_ops_spec.rb +52 -52
  117. data/spec/extensions/pg_array_spec.rb +152 -152
  118. data/spec/extensions/pg_enum_spec.rb +13 -13
  119. data/spec/extensions/pg_hstore_ops_spec.rb +63 -63
  120. data/spec/extensions/pg_hstore_spec.rb +84 -84
  121. data/spec/extensions/pg_inet_spec.rb +15 -15
  122. data/spec/extensions/pg_interval_spec.rb +29 -29
  123. data/spec/extensions/pg_json_ops_spec.rb +86 -84
  124. data/spec/extensions/pg_json_spec.rb +104 -104
  125. data/spec/extensions/pg_loose_count_spec.rb +6 -6
  126. data/spec/extensions/pg_range_ops_spec.rb +24 -24
  127. data/spec/extensions/pg_range_spec.rb +143 -143
  128. data/spec/extensions/pg_row_ops_spec.rb +14 -14
  129. data/spec/extensions/pg_row_plugin_spec.rb +12 -12
  130. data/spec/extensions/pg_row_spec.rb +118 -118
  131. data/spec/extensions/pg_static_cache_updater_spec.rb +28 -28
  132. data/spec/extensions/pg_typecast_on_load_spec.rb +21 -21
  133. data/spec/extensions/prepared_statements_associations_spec.rb +42 -42
  134. data/spec/extensions/prepared_statements_safe_spec.rb +18 -18
  135. data/spec/extensions/prepared_statements_spec.rb +28 -28
  136. data/spec/extensions/prepared_statements_with_pk_spec.rb +11 -11
  137. data/spec/extensions/pretty_table_spec.rb +16 -16
  138. data/spec/extensions/query_literals_spec.rb +37 -37
  139. data/spec/extensions/query_spec.rb +32 -32
  140. data/spec/extensions/rcte_tree_spec.rb +141 -141
  141. data/spec/extensions/round_timestamps_spec.rb +21 -21
  142. data/spec/extensions/schema_caching_spec.rb +8 -8
  143. data/spec/extensions/schema_dumper_spec.rb +78 -78
  144. data/spec/extensions/schema_spec.rb +31 -27
  145. data/spec/extensions/scissors_spec.rb +3 -3
  146. data/spec/extensions/select_remove_spec.rb +14 -14
  147. data/spec/extensions/sequel_3_dataset_methods_spec.rb +28 -28
  148. data/spec/extensions/serialization_modification_detection_spec.rb +33 -33
  149. data/spec/extensions/serialization_spec.rb +79 -78
  150. data/spec/extensions/server_block_spec.rb +17 -17
  151. data/spec/extensions/set_overrides_spec.rb +30 -30
  152. data/spec/extensions/sharding_spec.rb +65 -65
  153. data/spec/extensions/shared_caching_spec.rb +29 -29
  154. data/spec/extensions/single_table_inheritance_spec.rb +79 -79
  155. data/spec/extensions/skip_create_refresh_spec.rb +3 -3
  156. data/spec/extensions/spec_helper.rb +4 -29
  157. data/spec/extensions/split_array_nil_spec.rb +9 -9
  158. data/spec/extensions/split_values_spec.rb +7 -7
  159. data/spec/extensions/sql_expr_spec.rb +32 -32
  160. data/spec/extensions/static_cache_spec.rb +123 -123
  161. data/spec/extensions/string_date_time_spec.rb +34 -34
  162. data/spec/extensions/string_stripper_spec.rb +15 -15
  163. data/spec/extensions/subclasses_spec.rb +31 -31
  164. data/spec/extensions/table_select_spec.rb +15 -15
  165. data/spec/extensions/tactical_eager_loading_spec.rb +23 -23
  166. data/spec/extensions/thread_local_timezones_spec.rb +13 -13
  167. data/spec/extensions/timestamps_spec.rb +40 -40
  168. data/spec/extensions/to_dot_spec.rb +34 -34
  169. data/spec/extensions/touch_spec.rb +52 -52
  170. data/spec/extensions/tree_spec.rb +72 -72
  171. data/spec/extensions/typecast_on_load_spec.rb +25 -25
  172. data/spec/extensions/unlimited_update_spec.rb +2 -2
  173. data/spec/extensions/update_or_create_spec.rb +36 -36
  174. data/spec/extensions/update_primary_key_spec.rb +35 -35
  175. data/spec/extensions/update_refresh_spec.rb +41 -0
  176. data/spec/extensions/validate_associated_spec.rb +52 -0
  177. data/spec/extensions/validation_class_methods_spec.rb +314 -317
  178. data/spec/extensions/validation_helpers_spec.rb +195 -195
  179. data/spec/extensions/xml_serializer_spec.rb +48 -48
  180. data/spec/guards_helper.rb +55 -0
  181. data/spec/integration/associations_test.rb +1089 -1088
  182. data/spec/integration/database_test.rb +29 -29
  183. data/spec/integration/dataset_test.rb +661 -661
  184. data/spec/integration/eager_loader_test.rb +147 -147
  185. data/spec/integration/migrator_test.rb +122 -122
  186. data/spec/integration/model_test.rb +70 -70
  187. data/spec/integration/plugin_test.rb +682 -640
  188. data/spec/integration/prepared_statement_test.rb +172 -172
  189. data/spec/integration/schema_test.rb +245 -245
  190. data/spec/integration/spec_helper.rb +1 -64
  191. data/spec/integration/timezone_test.rb +17 -17
  192. data/spec/integration/transaction_test.rb +87 -87
  193. data/spec/integration/type_test.rb +33 -33
  194. data/spec/model/association_reflection_spec.rb +130 -121
  195. data/spec/model/associations_spec.rb +1112 -1113
  196. data/spec/model/base_spec.rb +197 -196
  197. data/spec/model/class_dataset_methods_spec.rb +118 -118
  198. data/spec/model/dataset_methods_spec.rb +49 -49
  199. data/spec/model/eager_loading_spec.rb +705 -702
  200. data/spec/model/hooks_spec.rb +169 -168
  201. data/spec/model/inflector_spec.rb +5 -5
  202. data/spec/model/model_spec.rb +287 -297
  203. data/spec/model/plugins_spec.rb +47 -47
  204. data/spec/model/record_spec.rb +534 -535
  205. data/spec/model/spec_helper.rb +3 -21
  206. data/spec/model/validations_spec.rb +72 -70
  207. data/spec/spec_config.rb +8 -0
  208. metadata +41 -9
  209. data/lib/sequel/adapters/fdbsql.rb +0 -286
  210. data/lib/sequel/adapters/jdbc/fdbsql.rb +0 -66
  211. data/lib/sequel/adapters/openbase.rb +0 -54
  212. data/lib/sequel/adapters/shared/fdbsql.rb +0 -550
  213. data/spec/adapters/fdbsql_spec.rb +0 -429
  214. data/spec/rspec_helper.rb +0 -22
@@ -6,36 +6,36 @@ describe "Sequel::Dataset::RoundTimestamps" do
6
6
  @dataset = Sequel.mock.dataset.extension(:round_timestamps)
7
7
  end
8
8
 
9
- specify "should round times properly for databases supporting microsecond precision" do
10
- @dataset.literal(Sequel::SQLTime.create(1, 2, 3, 499999.5)).should == "'01:02:03.500000'"
11
- @dataset.literal(Time.local(2010, 1, 2, 3, 4, 5.4999995)).should == "'2010-01-02 03:04:05.500000'"
12
- @dataset.literal(DateTime.new(2010, 1, 2, 3, 4, Rational(54999995, 10000000))).should == "'2010-01-02 03:04:05.500000'"
9
+ it "should round times properly for databases supporting microsecond precision" do
10
+ @dataset.literal(Sequel::SQLTime.create(1, 2, 3, 499999.5)).must_equal "'01:02:03.500000'"
11
+ @dataset.literal(Time.local(2010, 1, 2, 3, 4, 5.4999995)).must_equal "'2010-01-02 03:04:05.500000'"
12
+ @dataset.literal(DateTime.new(2010, 1, 2, 3, 4, Rational(54999995, 10000000))).must_equal "'2010-01-02 03:04:05.500000'"
13
13
 
14
- @dataset.literal(Sequel::SQLTime.create(1, 2, 3, 499999.4)).should == "'01:02:03.499999'"
15
- @dataset.literal(Time.local(2010, 1, 2, 3, 4, 5.4999994)).should == "'2010-01-02 03:04:05.499999'"
16
- @dataset.literal(DateTime.new(2010, 1, 2, 3, 4, Rational(54999994, 10000000))).should == "'2010-01-02 03:04:05.499999'"
14
+ @dataset.literal(Sequel::SQLTime.create(1, 2, 3, 499999.4)).must_equal "'01:02:03.499999'"
15
+ @dataset.literal(Time.local(2010, 1, 2, 3, 4, 5.4999994)).must_equal "'2010-01-02 03:04:05.499999'"
16
+ @dataset.literal(DateTime.new(2010, 1, 2, 3, 4, Rational(54999994, 10000000))).must_equal "'2010-01-02 03:04:05.499999'"
17
17
  end
18
18
 
19
- specify "should round times properly for databases supporting millisecond precision" do
19
+ it "should round times properly for databases supporting millisecond precision" do
20
20
  def @dataset.timestamp_precision() 3 end
21
- @dataset.literal(Sequel::SQLTime.create(1, 2, 3, 499500)).should == "'01:02:03.500'"
22
- @dataset.literal(Time.local(2010, 1, 2, 3, 4, 5.4995)).should == "'2010-01-02 03:04:05.500'"
23
- @dataset.literal(DateTime.new(2010, 1, 2, 3, 4, Rational(54995, 10000))).should == "'2010-01-02 03:04:05.500'"
21
+ @dataset.literal(Sequel::SQLTime.create(1, 2, 3, 499500)).must_equal "'01:02:03.500'"
22
+ @dataset.literal(Time.local(2010, 1, 2, 3, 4, 5.4995)).must_equal "'2010-01-02 03:04:05.500'"
23
+ @dataset.literal(DateTime.new(2010, 1, 2, 3, 4, Rational(54995, 10000))).must_equal "'2010-01-02 03:04:05.500'"
24
24
 
25
- @dataset.literal(Sequel::SQLTime.create(1, 2, 3, 499499)).should == "'01:02:03.499'"
26
- @dataset.literal(Time.local(2010, 1, 2, 3, 4, 5.4994)).should == "'2010-01-02 03:04:05.499'"
27
- @dataset.literal(DateTime.new(2010, 1, 2, 3, 4, Rational(54994, 10000))).should == "'2010-01-02 03:04:05.499'"
25
+ @dataset.literal(Sequel::SQLTime.create(1, 2, 3, 499499)).must_equal "'01:02:03.499'"
26
+ @dataset.literal(Time.local(2010, 1, 2, 3, 4, 5.4994)).must_equal "'2010-01-02 03:04:05.499'"
27
+ @dataset.literal(DateTime.new(2010, 1, 2, 3, 4, Rational(54994, 10000))).must_equal "'2010-01-02 03:04:05.499'"
28
28
  end
29
29
 
30
- specify "should round times properly for databases supporting second precision" do
30
+ it "should round times properly for databases supporting second precision" do
31
31
  def @dataset.supports_timestamp_usecs?() false end
32
- @dataset.literal(Sequel::SQLTime.create(1, 2, 3, 500000)).should == "'01:02:04'"
33
- @dataset.literal(Time.local(2010, 1, 2, 3, 4, 5.5)).should == "'2010-01-02 03:04:06'"
34
- @dataset.literal(DateTime.new(2010, 1, 2, 3, 4, Rational(55, 10))).should == "'2010-01-02 03:04:06'"
32
+ @dataset.literal(Sequel::SQLTime.create(1, 2, 3, 500000)).must_equal "'01:02:04'"
33
+ @dataset.literal(Time.local(2010, 1, 2, 3, 4, 5.5)).must_equal "'2010-01-02 03:04:06'"
34
+ @dataset.literal(DateTime.new(2010, 1, 2, 3, 4, Rational(55, 10))).must_equal "'2010-01-02 03:04:06'"
35
35
 
36
- @dataset.literal(Sequel::SQLTime.create(1, 2, 3, 499999)).should == "'01:02:03'"
37
- @dataset.literal(Time.local(2010, 1, 2, 3, 4, 5.4999999)).should == "'2010-01-02 03:04:05'"
38
- @dataset.literal(DateTime.new(2010, 1, 2, 3, 4, Rational(54999999, 10000000))).should == "'2010-01-02 03:04:05'"
36
+ @dataset.literal(Sequel::SQLTime.create(1, 2, 3, 499999)).must_equal "'01:02:03'"
37
+ @dataset.literal(Time.local(2010, 1, 2, 3, 4, 5.4999999)).must_equal "'2010-01-02 03:04:05'"
38
+ @dataset.literal(DateTime.new(2010, 1, 2, 3, 4, Rational(54999999, 10000000))).must_equal "'2010-01-02 03:04:05'"
39
39
  end
40
40
  end
41
41
  else
@@ -12,30 +12,30 @@ describe "schema_caching extension" do
12
12
  end
13
13
 
14
14
  it "Database#dump_schema_cache should dump cached schema to the given file" do
15
- File.exist?(@filename).should == false
15
+ File.exist?(@filename).must_equal false
16
16
  @db.dump_schema_cache(@filename)
17
- File.exist?(@filename).should == true
18
- File.size(@filename).should > 0
17
+ File.exist?(@filename).must_equal true
18
+ File.size(@filename).must_be :>, 0
19
19
  end
20
20
 
21
21
  it "Database#load_schema_cache should load cached schema from the given file dumped by #dump_schema_cache" do
22
22
  @db.dump_schema_cache(@filename)
23
23
  db = Sequel::Database.new.extension(:schema_caching)
24
24
  db.load_schema_cache(@filename)
25
- @db.instance_variable_get(:@schemas).should == @schemas
25
+ @db.instance_variable_get(:@schemas).must_equal @schemas
26
26
  end
27
27
 
28
28
  it "Database#dump_schema_cache? should dump cached schema to the given file unless the file exists" do
29
29
  File.open(@filename, 'wb'){|f|}
30
- File.size(@filename).should == 0
30
+ File.size(@filename).must_equal 0
31
31
  @db.dump_schema_cache?(@filename)
32
- File.size(@filename).should == 0
32
+ File.size(@filename).must_equal 0
33
33
  end
34
34
 
35
35
  it "Database#load_schema_cache? should load cached schema from the given file if it exists" do
36
36
  db = Sequel::Database.new.extension(:schema_caching)
37
- File.exist?(@filename).should == false
37
+ File.exist?(@filename).must_equal false
38
38
  db.load_schema_cache?(@filename)
39
- db.instance_variable_get(:@schemas).should == {}
39
+ db.instance_variable_get(:@schemas).must_equal({})
40
40
  end
41
41
  end
@@ -31,9 +31,9 @@ describe "Sequel::Schema::Generator dump methods" do
31
31
  instance_eval(g.dump_constraints, __FILE__, __LINE__)
32
32
  instance_eval(g.dump_indexes, __FILE__, __LINE__)
33
33
  end
34
- g.columns.should == g2.columns
35
- g.constraints.should == g2.constraints
36
- g.indexes.should == g2.indexes
34
+ g.columns.must_equal g2.columns
35
+ g.constraints.must_equal g2.constraints
36
+ g.indexes.must_equal g2.indexes
37
37
  end
38
38
 
39
39
  it "should allow dumping indexes as separate add_index and drop_index methods" do
@@ -43,13 +43,13 @@ describe "Sequel::Schema::Generator dump methods" do
43
43
  index [:b, :c], :unique=>true
44
44
  end
45
45
 
46
- g.dump_indexes(:add_index=>:t).should == (<<END_CODE).strip
46
+ g.dump_indexes(:add_index=>:t).must_equal((<<END_CODE).strip)
47
47
  add_index :t, [:a]
48
48
  add_index :t, [:c, :e], :name=>:blah
49
49
  add_index :t, [:b, :c], :unique=>true
50
50
  END_CODE
51
51
 
52
- g.dump_indexes(:drop_index=>:t).should == (<<END_CODE).strip
52
+ g.dump_indexes(:drop_index=>:t).must_equal((<<END_CODE).strip)
53
53
  drop_index :t, [:b, :c], :unique=>true
54
54
  drop_index :t, [:c, :e], :name=>:blah
55
55
  drop_index :t, [:a]
@@ -57,7 +57,7 @@ END_CODE
57
57
  end
58
58
 
59
59
  it "should raise an error if you try to dump a Generator that uses a constraint with a proc" do
60
- proc{@g.new(@d){check{a>1}}.dump_constraints}.should raise_error(Sequel::Error)
60
+ proc{@g.new(@d){check{a>1}}.dump_constraints}.must_raise(Sequel::Error)
61
61
  end
62
62
  end
63
63
 
@@ -80,27 +80,27 @@ describe "Sequel::Database dump methods" do
80
80
  end
81
81
 
82
82
  it "should support dumping table schemas as create_table method calls" do
83
- @d.dump_table_schema(:t1).should == "create_table(:t1) do\n primary_key :c1\n String :c2, :size=>20\nend"
83
+ @d.dump_table_schema(:t1).must_equal "create_table(:t1) do\n primary_key :c1\n String :c2, :size=>20\nend"
84
84
  end
85
85
 
86
86
  it "should support dumping table schemas when given a string" do
87
- @d.dump_table_schema('t__t1').should == "create_table(\"t__t1\") do\n primary_key :c1\n String :c2, :size=>20\nend"
87
+ @d.dump_table_schema('t__t1').must_equal "create_table(\"t__t1\") do\n primary_key :c1\n String :c2, :size=>20\nend"
88
88
  end
89
89
 
90
90
  it "should support dumping table schemas when given an identifier" do
91
- @d.dump_table_schema(Sequel.identifier(:t__t1)).should == "create_table(\"t__t1\") do\n primary_key :c1\n String :c2, :size=>20\nend"
91
+ @d.dump_table_schema(Sequel.identifier(:t__t1)).must_equal "create_table(\"t__t1\") do\n primary_key :c1\n String :c2, :size=>20\nend"
92
92
  end
93
93
 
94
94
  it "should dump non-Integer primary key columns with explicit :type" do
95
95
  @d.meta_def(:schema){|*s| [[:c1, {:db_type=>'bigint', :primary_key=>true, :allow_null=>true, :auto_increment=>true}]]}
96
- @d.dump_table_schema(:t6).should == "create_table(:t6) do\n primary_key :c1, :type=>Bignum\nend"
96
+ @d.dump_table_schema(:t6).must_equal "create_table(:t6) do\n primary_key :c1, :type=>Bignum\nend"
97
97
  end
98
98
 
99
99
  it "should handle foreign keys" do
100
100
  @d.meta_def(:schema){|*s| [[:c1, {:db_type=>'integer', :allow_null=>true}]]}
101
101
  @d.meta_def(:supports_foreign_key_parsing?){true}
102
102
  @d.meta_def(:foreign_key_list){|*s| [{:columns=>[:c1], :table=>:t2, :key=>[:c2]}]}
103
- @d.dump_table_schema(:t6).should == "create_table(:t6) do\n foreign_key :c1, :t2, :key=>[:c2]\nend"
103
+ @d.dump_table_schema(:t6).must_equal "create_table(:t6) do\n foreign_key :c1, :t2, :key=>[:c2]\nend"
104
104
  end
105
105
 
106
106
  it "should handle primary keys that are also foreign keys" do
@@ -108,9 +108,9 @@ describe "Sequel::Database dump methods" do
108
108
  @d.meta_def(:supports_foreign_key_parsing?){true}
109
109
  @d.meta_def(:foreign_key_list){|*s| [{:columns=>[:c1], :table=>:t2, :key=>[:c2]}]}
110
110
  s = @d.dump_table_schema(:t6)
111
- s.should =~ /create_table\(:t6\) do\n primary_key :c1, /
112
- s.should =~ /:table=>:t2/
113
- s.should =~ /:key=>\[:c2\]/
111
+ s.must_match(/create_table\(:t6\) do\n primary_key :c1, /)
112
+ s.must_match(/:table=>:t2/)
113
+ s.must_match(/:key=>\[:c2\]/)
114
114
  end
115
115
 
116
116
  it "should handle foreign key options" do
@@ -118,11 +118,11 @@ describe "Sequel::Database dump methods" do
118
118
  @d.meta_def(:supports_foreign_key_parsing?){true}
119
119
  @d.meta_def(:foreign_key_list){|*s| [{:columns=>[:c1], :table=>:t2, :key=>[:c2], :on_delete=>:restrict, :on_update=>:set_null, :deferrable=>true}]}
120
120
  s = @d.dump_table_schema(:t6)
121
- s.should =~ /create_table\(:t6\) do\n foreign_key :c1, :t2, /
122
- s.should =~ /:key=>\[:c2\]/
123
- s.should =~ /:on_delete=>:restrict/
124
- s.should =~ /:on_update=>:set_null/
125
- s.should =~ /:deferrable=>true/
121
+ s.must_match(/create_table\(:t6\) do\n foreign_key :c1, :t2, /)
122
+ s.must_match(/:key=>\[:c2\]/)
123
+ s.must_match(/:on_delete=>:restrict/)
124
+ s.must_match(/:on_update=>:set_null/)
125
+ s.must_match(/:deferrable=>true/)
126
126
  end
127
127
 
128
128
  it "should handle foreign key options in the primary key" do
@@ -130,12 +130,12 @@ describe "Sequel::Database dump methods" do
130
130
  @d.meta_def(:supports_foreign_key_parsing?){true}
131
131
  @d.meta_def(:foreign_key_list){|*s| [{:columns=>[:c1], :table=>:t2, :key=>[:c2], :on_delete=>:restrict, :on_update=>:set_null, :deferrable=>true}]}
132
132
  s = @d.dump_table_schema(:t6)
133
- s.should =~ /create_table\(:t6\) do\n primary_key :c1, /
134
- s.should =~ /:table=>:t2/
135
- s.should =~ /:key=>\[:c2\]/
136
- s.should =~ /:on_delete=>:restrict/
137
- s.should =~ /:on_update=>:set_null/
138
- s.should =~ /:deferrable=>true/
133
+ s.must_match(/create_table\(:t6\) do\n primary_key :c1, /)
134
+ s.must_match(/:table=>:t2/)
135
+ s.must_match(/:key=>\[:c2\]/)
136
+ s.must_match(/:on_delete=>:restrict/)
137
+ s.must_match(/:on_update=>:set_null/)
138
+ s.must_match(/:deferrable=>true/)
139
139
  end
140
140
 
141
141
  it "should omit foreign key options that are the same as defaults" do
@@ -143,11 +143,11 @@ describe "Sequel::Database dump methods" do
143
143
  @d.meta_def(:supports_foreign_key_parsing?){true}
144
144
  @d.meta_def(:foreign_key_list){|*s| [{:columns=>[:c1], :table=>:t2, :key=>[:c2], :on_delete=>:no_action, :on_update=>:no_action, :deferrable=>false}]}
145
145
  s = @d.dump_table_schema(:t6)
146
- s.should =~ /create_table\(:t6\) do\n foreign_key :c1, :t2, /
147
- s.should =~ /:key=>\[:c2\]/
148
- s.should_not =~ /:on_delete/
149
- s.should_not =~ /:on_update/
150
- s.should_not =~ /:deferrable/
146
+ s.must_match(/create_table\(:t6\) do\n foreign_key :c1, :t2, /)
147
+ s.must_match(/:key=>\[:c2\]/)
148
+ s.wont_match(/:on_delete/)
149
+ s.wont_match(/:on_update/)
150
+ s.wont_match(/:deferrable/)
151
151
  end
152
152
 
153
153
  it "should omit foreign key options that are the same as defaults in the primary key" do
@@ -155,28 +155,28 @@ describe "Sequel::Database dump methods" do
155
155
  @d.meta_def(:supports_foreign_key_parsing?){true}
156
156
  @d.meta_def(:foreign_key_list){|*s| [{:columns=>[:c1], :table=>:t2, :key=>[:c2], :on_delete=>:no_action, :on_update=>:no_action, :deferrable=>false}]}
157
157
  s = @d.dump_table_schema(:t6)
158
- s.should =~ /create_table\(:t6\) do\n primary_key :c1, /
159
- s.should =~ /:table=>:t2/
160
- s.should =~ /:key=>\[:c2\]/
161
- s.should_not =~ /:on_delete/
162
- s.should_not =~ /:on_update/
163
- s.should_not =~ /:deferrable/
158
+ s.must_match(/create_table\(:t6\) do\n primary_key :c1, /)
159
+ s.must_match(/:table=>:t2/)
160
+ s.must_match(/:key=>\[:c2\]/)
161
+ s.wont_match(/:on_delete/)
162
+ s.wont_match(/:on_update/)
163
+ s.wont_match(/:deferrable/)
164
164
  end
165
165
 
166
166
  it "should dump primary key columns with explicit type equal to the database type when :same_db option is passed" do
167
167
  @d.meta_def(:schema){|*s| [[:c1, {:db_type=>'somedbspecifictype', :primary_key=>true, :allow_null=>false}]]}
168
- @d.dump_table_schema(:t7, :same_db => true).should == "create_table(:t7) do\n column :c1, \"somedbspecifictype\", :null=>false\n \n primary_key [:c1]\nend"
168
+ @d.dump_table_schema(:t7, :same_db => true).must_equal "create_table(:t7) do\n column :c1, \"somedbspecifictype\", :null=>false\n \n primary_key [:c1]\nend"
169
169
  end
170
170
 
171
171
  it "should use a composite primary_key calls if there is a composite primary key" do
172
- @d.dump_table_schema(:t2).should == "create_table(:t2) do\n Integer :c1, :null=>false\n BigDecimal :c2, :null=>false\n \n primary_key [:c1, :c2]\nend"
172
+ @d.dump_table_schema(:t2).must_equal "create_table(:t2) do\n Integer :c1, :null=>false\n BigDecimal :c2, :null=>false\n \n primary_key [:c1, :c2]\nend"
173
173
  end
174
174
 
175
175
  it "should use a composite foreign_key calls if there is a composite foreign key" do
176
176
  @d.meta_def(:schema){|*s| [[:c1, {:db_type=>'integer'}], [:c2, {:db_type=>'integer'}]]}
177
177
  @d.meta_def(:supports_foreign_key_parsing?){true}
178
178
  @d.meta_def(:foreign_key_list){|*s| [{:columns=>[:c1, :c2], :table=>:t2, :key=>[:c3, :c4]}]}
179
- @d.dump_table_schema(:t1).should == "create_table(:t1) do\n Integer :c1\n Integer :c2\n \n foreign_key [:c1, :c2], :t2, :key=>[:c3, :c4]\nend"
179
+ @d.dump_table_schema(:t1).must_equal "create_table(:t1) do\n Integer :c1\n Integer :c2\n \n foreign_key [:c1, :c2], :t2, :key=>[:c3, :c4]\nend"
180
180
  end
181
181
 
182
182
  it "should include index information if available" do
@@ -185,11 +185,11 @@ describe "Sequel::Database dump methods" do
185
185
  {:i1=>{:columns=>[:c1], :unique=>false},
186
186
  :t1_c2_c1_index=>{:columns=>[:c2, :c1], :unique=>true}}
187
187
  end
188
- @d.dump_table_schema(:t1).should == "create_table(:t1, :ignore_index_errors=>true) do\n primary_key :c1\n String :c2, :size=>20\n \n index [:c1], :name=>:i1\n index [:c2, :c1], :unique=>true\nend"
188
+ @d.dump_table_schema(:t1).must_equal "create_table(:t1, :ignore_index_errors=>true) do\n primary_key :c1\n String :c2, :size=>20\n \n index [:c1], :name=>:i1\n index [:c2, :c1], :unique=>true\nend"
189
189
  end
190
190
 
191
191
  it "should support dumping the whole database as a migration" do
192
- @d.dump_schema_migration.should == <<-END_MIG
192
+ @d.dump_schema_migration.must_equal <<-END_MIG
193
193
  Sequel.migration do
194
194
  change do
195
195
  create_table(:t1) do
@@ -210,7 +210,7 @@ END_MIG
210
210
 
211
211
  it "should sort table names when dumping a migration" do
212
212
  @d.meta_def(:tables){|o| [:t2, :t1]}
213
- @d.dump_schema_migration.should == <<-END_MIG
213
+ @d.dump_schema_migration.must_equal <<-END_MIG
214
214
  Sequel.migration do
215
215
  change do
216
216
  create_table(:t1) do
@@ -238,7 +238,7 @@ END_MIG
238
238
  @d.meta_def(:foreign_key_list) do |t|
239
239
  t == :t1 ? [{:columns=>[:c2], :table=>:t2, :key=>[:c1]}] : []
240
240
  end
241
- @d.dump_schema_migration.should == <<-END_MIG
241
+ @d.dump_schema_migration.must_equal <<-END_MIG
242
242
  Sequel.migration do
243
243
  change do
244
244
  create_table(:t2) do
@@ -262,7 +262,7 @@ END_MIG
262
262
  @d.meta_def(:foreign_key_list) do |t|
263
263
  t == :t1 ? [{:columns=>[:c2], :table=>:t2, :key=>[:c1]}] : [{:columns=>[:c1], :table=>:t1, :key=>[:c2]}]
264
264
  end
265
- @d.dump_schema_migration.should == <<-END_MIG
265
+ @d.dump_schema_migration.must_equal <<-END_MIG
266
266
  Sequel.migration do
267
267
  change do
268
268
  create_table(:t1) do
@@ -291,7 +291,7 @@ END_MIG
291
291
  raise Sequel::DatabaseError unless [:t1, :t2].include?(t)
292
292
  t == :t1 ? [{:columns=>[:c2], :table=>:t2, :key=>[:c1]}] : []
293
293
  end
294
- @d.dump_schema_migration.should == <<-END_MIG
294
+ @d.dump_schema_migration.must_equal <<-END_MIG
295
295
  Sequel.migration do
296
296
  change do
297
297
  create_table(:t2) do
@@ -307,8 +307,8 @@ END_MIG
307
307
  end
308
308
 
309
309
  it "should honor the :same_db option to not convert types" do
310
- @d.dump_table_schema(:t1, :same_db=>true).should == "create_table(:t1) do\n primary_key :c1\n column :c2, \"varchar(20)\"\nend"
311
- @d.dump_schema_migration(:same_db=>true).should == <<-END_MIG
310
+ @d.dump_table_schema(:t1, :same_db=>true).must_equal "create_table(:t1) do\n primary_key :c1\n column :c2, \"varchar(20)\"\nend"
311
+ @d.dump_schema_migration(:same_db=>true).must_equal <<-END_MIG
312
312
  Sequel.migration do
313
313
  change do
314
314
  create_table(:t1) do
@@ -333,8 +333,8 @@ END_MIG
333
333
  {:i1=>{:columns=>[:c1], :unique=>false},
334
334
  :t1_c2_c1_index=>{:columns=>[:c2, :c1], :unique=>true}}
335
335
  end
336
- @d.dump_table_schema(:t1, :index_names=>false).should == "create_table(:t1, :ignore_index_errors=>true) do\n primary_key :c1\n String :c2, :size=>20\n \n index [:c1]\n index [:c2, :c1], :unique=>true\nend"
337
- @d.dump_schema_migration(:index_names=>false).should == <<-END_MIG
336
+ @d.dump_table_schema(:t1, :index_names=>false).must_equal "create_table(:t1, :ignore_index_errors=>true) do\n primary_key :c1\n String :c2, :size=>20\n \n index [:c1]\n index [:c2, :c1], :unique=>true\nend"
337
+ @d.dump_schema_migration(:index_names=>false).must_equal <<-END_MIG
338
338
  Sequel.migration do
339
339
  change do
340
340
  create_table(:t1, :ignore_index_errors=>true) do
@@ -365,8 +365,8 @@ END_MIG
365
365
  {:i1=>{:columns=>[:c1], :unique=>false},
366
366
  :t1_c2_c1_index=>{:columns=>[:c2, :c1], :unique=>false}}
367
367
  end
368
- @d.dump_table_schema(:t1, :index_names=>:namespace).should == "create_table(:t1, :ignore_index_errors=>true) do\n primary_key :c1\n String :c2, :size=>20\n \n index [:c1], :name=>:i1\n index [:c2, :c1]\nend"
369
- @d.dump_schema_migration(:index_names=>:namespace).should == <<-END_MIG
368
+ @d.dump_table_schema(:t1, :index_names=>:namespace).must_equal "create_table(:t1, :ignore_index_errors=>true) do\n primary_key :c1\n String :c2, :size=>20\n \n index [:c1], :name=>:i1\n index [:c2, :c1]\nend"
369
+ @d.dump_schema_migration(:index_names=>:namespace).must_equal <<-END_MIG
370
370
  Sequel.migration do
371
371
  change do
372
372
  create_table(:t1, :ignore_index_errors=>true) do
@@ -398,8 +398,8 @@ END_MIG
398
398
  {:i1=>{:columns=>[:c1], :unique=>false},
399
399
  :t1_c2_c1_index=>{:columns=>[:c2, :c1], :unique=>false}}
400
400
  end
401
- @d.dump_table_schema(:t1, :index_names=>:namespace).should == "create_table(:t1, :ignore_index_errors=>true) do\n primary_key :c1\n String :c2, :size=>20\n \n index [:c1], :name=>:t1_i1\n index [:c2, :c1]\nend"
402
- @d.dump_schema_migration(:index_names=>:namespace).should == <<-END_MIG
401
+ @d.dump_table_schema(:t1, :index_names=>:namespace).must_equal "create_table(:t1, :ignore_index_errors=>true) do\n primary_key :c1\n String :c2, :size=>20\n \n index [:c1], :name=>:t1_i1\n index [:c2, :c1]\nend"
402
+ @d.dump_schema_migration(:index_names=>:namespace).must_equal <<-END_MIG
403
403
  Sequel.migration do
404
404
  change do
405
405
  create_table(:t1, :ignore_index_errors=>true) do
@@ -430,8 +430,8 @@ END_MIG
430
430
  {:i1=>{:columns=>[:c1], :unique=>false},
431
431
  :t1_c2_c1_index=>{:columns=>[:c2, :c1], :unique=>true}}
432
432
  end
433
- @d.dump_table_schema(:t1, :indexes=>false).should == "create_table(:t1) do\n primary_key :c1\n String :c2, :size=>20\nend"
434
- @d.dump_schema_migration(:indexes=>false).should == <<-END_MIG
433
+ @d.dump_table_schema(:t1, :indexes=>false).must_equal "create_table(:t1) do\n primary_key :c1\n String :c2, :size=>20\nend"
434
+ @d.dump_schema_migration(:indexes=>false).must_equal <<-END_MIG
435
435
  Sequel.migration do
436
436
  change do
437
437
  create_table(:t1) do
@@ -454,7 +454,7 @@ END_MIG
454
454
  @d.meta_def(:foreign_key_list) do |t|
455
455
  t == :t1 ? [{:columns=>[:c2], :table=>:t2, :key=>[:c1]}] : []
456
456
  end
457
- @d.dump_schema_migration(:indexes=>false).should_not =~ /foreign_key/
457
+ @d.dump_schema_migration(:indexes=>false).wont_match(/foreign_key/)
458
458
  end
459
459
 
460
460
  it "should have :foreign_keys option override :indexes => false disabling of foreign keys" do
@@ -462,7 +462,7 @@ END_MIG
462
462
  @d.meta_def(:foreign_key_list) do |t|
463
463
  t == :t1 ? [{:columns=>[:c2], :table=>:t2, :key=>[:c1]}] : []
464
464
  end
465
- @d.dump_schema_migration(:indexes=>false, :foreign_keys=>true).should =~ /foreign_key/
465
+ @d.dump_schema_migration(:indexes=>false, :foreign_keys=>true).must_match(/foreign_key/)
466
466
  end
467
467
 
468
468
  it "should support dumping just indexes as a migration" do
@@ -472,7 +472,7 @@ END_MIG
472
472
  {:i1=>{:columns=>[:c1], :unique=>false},
473
473
  :t1_c2_c1_index=>{:columns=>[:c2, :c1], :unique=>true}}
474
474
  end
475
- @d.dump_indexes_migration.should == <<-END_MIG
475
+ @d.dump_indexes_migration.must_equal <<-END_MIG
476
476
  Sequel.migration do
477
477
  change do
478
478
  add_index :t1, [:c1], :ignore_errors=>true, :name=>:i1
@@ -489,7 +489,7 @@ END_MIG
489
489
  {:i1=>{:columns=>[:c1], :unique=>false},
490
490
  :t1_c2_c1_index=>{:columns=>[:c2, :c1], :unique=>true}}
491
491
  end
492
- @d.dump_indexes_migration(:index_names=>false).should == <<-END_MIG
492
+ @d.dump_indexes_migration(:index_names=>false).must_equal <<-END_MIG
493
493
  Sequel.migration do
494
494
  change do
495
495
  add_index :t1, [:c1], :ignore_errors=>true
@@ -506,7 +506,7 @@ END_MIG
506
506
  {:i1=>{:columns=>[:c1], :unique=>false},
507
507
  :t1_c2_c1_index=>{:columns=>[:c2, :c1], :unique=>false}}
508
508
  end
509
- @d.dump_indexes_migration(:index_names=>:namespace).should == <<-END_MIG
509
+ @d.dump_indexes_migration(:index_names=>:namespace).must_equal <<-END_MIG
510
510
  Sequel.migration do
511
511
  change do
512
512
  add_index :t1, [:c1], :ignore_errors=>true, :name=>:i1
@@ -527,7 +527,7 @@ END_MIG
527
527
  {:i1=>{:columns=>[:c1], :unique=>false},
528
528
  :t1_c2_c1_index=>{:columns=>[:c2, :c1], :unique=>false}}
529
529
  end
530
- @d.dump_indexes_migration(:index_names=>:namespace).should == <<-END_MIG
530
+ @d.dump_indexes_migration(:index_names=>:namespace).must_equal <<-END_MIG
531
531
  Sequel.migration do
532
532
  change do
533
533
  add_index :t1, [:c1], :ignore_errors=>true, :name=>:t1_i1
@@ -542,7 +542,7 @@ END_MIG
542
542
 
543
543
  it "should handle missing index parsing support when dumping index migration" do
544
544
  @d.meta_def(:tables){|o| [:t1]}
545
- @d.dump_indexes_migration.should == <<-END_MIG
545
+ @d.dump_indexes_migration.must_equal <<-END_MIG
546
546
  Sequel.migration do
547
547
  change do
548
548
 
@@ -553,7 +553,7 @@ END_MIG
553
553
 
554
554
  it "should handle missing foreign key parsing support when dumping foreign key migration" do
555
555
  @d.meta_def(:tables){|o| [:t1]}
556
- @d.dump_foreign_key_migration.should == <<-END_MIG
556
+ @d.dump_foreign_key_migration.must_equal <<-END_MIG
557
557
  Sequel.migration do
558
558
  change do
559
559
 
@@ -578,7 +578,7 @@ END_MIG
578
578
  []
579
579
  end
580
580
  end
581
- @d.dump_foreign_key_migration.should == <<-END_MIG
581
+ @d.dump_foreign_key_migration.must_equal <<-END_MIG
582
582
  Sequel.migration do
583
583
  change do
584
584
  alter_table(:t1) do
@@ -595,7 +595,7 @@ END_MIG
595
595
 
596
596
  it "should handle not null values and defaults" do
597
597
  @d.meta_def(:schema){|*s| [[:c1, {:db_type=>'date', :default=>"'now()'", :allow_null=>true}], [:c2, {:db_type=>'datetime', :allow_null=>false}]]}
598
- @d.dump_table_schema(:t3).should == "create_table(:t3) do\n Date :c1\n DateTime :c2, :null=>false\nend"
598
+ @d.dump_table_schema(:t3).must_equal "create_table(:t3) do\n Date :c1\n DateTime :c2, :null=>false\nend"
599
599
  end
600
600
 
601
601
  it "should handle converting common defaults" do
@@ -615,8 +615,8 @@ END_MIG
615
615
  s.each{|_, c| c[:ruby_default] = column_schema_to_ruby_default(c[:default], c[:type])}
616
616
  s
617
617
  end
618
- @d.dump_table_schema(:t4).gsub(/[+-]\d\d\d\d"\)/, '")').gsub(/\.0+/, '.0').should == "create_table(:t4) do\n TrueClass :c1, :default=>false\n String :c2, :default=>\"blah\"\n Integer :c3, :default=>-1\n Float :c4, :default=>1.0\n BigDecimal :c5, :default=>BigDecimal.new(\"0.1005E3\")\n File :c6, :default=>Sequel::SQL::Blob.new(\"blah\")\n Date :c7, :default=>Date.new(2008, 10, 29)\n DateTime :c8, :default=>DateTime.parse(\"2008-10-29T10:20:30.0\")\n Time :c9, :default=>Sequel::SQLTime.parse(\"10:20:30.0\"), :only_time=>true\n String :c10\n Date :c11, :default=>Sequel::CURRENT_DATE\n DateTime :c12, :default=>Sequel::CURRENT_TIMESTAMP\nend"
619
- @d.dump_table_schema(:t4, :same_db=>true).gsub(/[+-]\d\d\d\d"\)/, '")').gsub(/\.0+/, '.0').should == "create_table(:t4) do\n column :c1, \"boolean\", :default=>false\n column :c2, \"varchar\", :default=>\"blah\"\n column :c3, \"integer\", :default=>-1\n column :c4, \"float\", :default=>1.0\n column :c5, \"decimal\", :default=>BigDecimal.new(\"0.1005E3\")\n column :c6, \"blob\", :default=>Sequel::SQL::Blob.new(\"blah\")\n column :c7, \"date\", :default=>Date.new(2008, 10, 29)\n column :c8, \"datetime\", :default=>DateTime.parse(\"2008-10-29T10:20:30.0\")\n column :c9, \"time\", :default=>Sequel::SQLTime.parse(\"10:20:30.0\")\n column :c10, \"foo\", :default=>Sequel::LiteralString.new(\"'6 weeks'\")\n column :c11, \"date\", :default=>Sequel::CURRENT_DATE\n column :c12, \"timestamp\", :default=>Sequel::CURRENT_TIMESTAMP\nend"
618
+ @d.dump_table_schema(:t4).gsub(/[+-]\d\d\d\d"\)/, '")').gsub(/\.0+/, '.0').must_equal "create_table(:t4) do\n TrueClass :c1, :default=>false\n String :c2, :default=>\"blah\"\n Integer :c3, :default=>-1\n Float :c4, :default=>1.0\n BigDecimal :c5, :default=>BigDecimal.new(\"0.1005E3\")\n File :c6, :default=>Sequel::SQL::Blob.new(\"blah\")\n Date :c7, :default=>Date.new(2008, 10, 29)\n DateTime :c8, :default=>DateTime.parse(\"2008-10-29T10:20:30.0\")\n Time :c9, :default=>Sequel::SQLTime.parse(\"10:20:30.0\"), :only_time=>true\n String :c10\n Date :c11, :default=>Sequel::CURRENT_DATE\n DateTime :c12, :default=>Sequel::CURRENT_TIMESTAMP\nend"
619
+ @d.dump_table_schema(:t4, :same_db=>true).gsub(/[+-]\d\d\d\d"\)/, '")').gsub(/\.0+/, '.0').must_equal "create_table(:t4) do\n column :c1, \"boolean\", :default=>false\n column :c2, \"varchar\", :default=>\"blah\"\n column :c3, \"integer\", :default=>-1\n column :c4, \"float\", :default=>1.0\n column :c5, \"decimal\", :default=>BigDecimal.new(\"0.1005E3\")\n column :c6, \"blob\", :default=>Sequel::SQL::Blob.new(\"blah\")\n column :c7, \"date\", :default=>Date.new(2008, 10, 29)\n column :c8, \"datetime\", :default=>DateTime.parse(\"2008-10-29T10:20:30.0\")\n column :c9, \"time\", :default=>Sequel::SQLTime.parse(\"10:20:30.0\")\n column :c10, \"foo\", :default=>Sequel::LiteralString.new(\"'6 weeks'\")\n column :c11, \"date\", :default=>Sequel::CURRENT_DATE\n column :c12, \"timestamp\", :default=>Sequel::CURRENT_TIMESTAMP\nend"
620
620
  end
621
621
 
622
622
  it "should not use a literal string as a fallback if using MySQL with the :same_db option" do
@@ -628,11 +628,11 @@ END_MIG
628
628
  s.each{|_, c| c[:ruby_default] = column_schema_to_ruby_default(c[:default], c[:type])}
629
629
  s
630
630
  end
631
- @d.dump_table_schema(:t5, :same_db=>true).should == "create_table(:t5) do\n column :c10, \"foo\"\nend"
631
+ @d.dump_table_schema(:t5, :same_db=>true).must_equal "create_table(:t5) do\n column :c10, \"foo\"\nend"
632
632
  end
633
633
 
634
634
  it "should convert unknown database types to strings" do
635
- @d.dump_table_schema(:t5).should == "create_table(:t5) do\n String :c1\nend"
635
+ @d.dump_table_schema(:t5).must_equal "create_table(:t5) do\n String :c1\nend"
636
636
  end
637
637
 
638
638
  it "should convert many database types to ruby types" do
@@ -652,7 +652,7 @@ END_MIG
652
652
  i = 0
653
653
  types.map{|x| [:"c#{i+=1}", {:db_type=>x, :allow_null=>true}]}
654
654
  end
655
- @d.dump_table_schema(:x).should == (<<END_MIG).chomp
655
+ @d.dump_table_schema(:x).must_equal((<<END_MIG).chomp)
656
656
  create_table(:x) do
657
657
  Integer :c1
658
658
  Integer :c2
@@ -744,7 +744,7 @@ END_MIG
744
744
  i = 0
745
745
  types.map{|x| [:"c#{i+=1}", {:db_type=>x, :allow_null=>true}]}
746
746
  end
747
- @d.dump_table_schema(:x).should == (<<END_MIG).chomp
747
+ @d.dump_table_schema(:x).must_equal((<<END_MIG).chomp)
748
748
  create_table(:x) do
749
749
  Float :c1
750
750
  Float :c2
@@ -757,16 +757,16 @@ END_MIG
757
757
  it "should force specify :null option for MySQL timestamp columns when using :same_db" do
758
758
  @d.meta_def(:database_type){:mysql}
759
759
  @d.meta_def(:schema){|*s| [[:c1, {:db_type=>'timestamp', :primary_key=>true, :allow_null=>true}]]}
760
- @d.dump_table_schema(:t3, :same_db=>true).should == "create_table(:t3) do\n column :c1, \"timestamp\", :null=>true\n \n primary_key [:c1]\nend"
760
+ @d.dump_table_schema(:t3, :same_db=>true).must_equal "create_table(:t3) do\n column :c1, \"timestamp\", :null=>true\n \n primary_key [:c1]\nend"
761
761
 
762
762
  @d.meta_def(:schema){|*s| [[:c1, {:db_type=>'timestamp', :primary_key=>true, :allow_null=>false}]]}
763
- @d.dump_table_schema(:t3, :same_db=>true).should == "create_table(:t3) do\n column :c1, \"timestamp\", :null=>false\n \n primary_key [:c1]\nend"
763
+ @d.dump_table_schema(:t3, :same_db=>true).must_equal "create_table(:t3) do\n column :c1, \"timestamp\", :null=>false\n \n primary_key [:c1]\nend"
764
764
  end
765
765
 
766
766
  it "should use separate primary_key call with non autoincrementable types" do
767
767
  @d.meta_def(:schema){|*s| [[:c1, {:db_type=>'varchar(8)', :primary_key=>true, :auto_increment=>false}]]}
768
- @d.dump_table_schema(:t3).should == "create_table(:t3) do\n String :c1, :size=>8\n \n primary_key [:c1]\nend"
769
- @d.dump_table_schema(:t3, :same_db=>true).should == "create_table(:t3) do\n column :c1, \"varchar(8)\"\n \n primary_key [:c1]\nend"
768
+ @d.dump_table_schema(:t3).must_equal "create_table(:t3) do\n String :c1, :size=>8\n \n primary_key [:c1]\nend"
769
+ @d.dump_table_schema(:t3, :same_db=>true).must_equal "create_table(:t3) do\n column :c1, \"varchar(8)\"\n \n primary_key [:c1]\nend"
770
770
  end
771
771
 
772
772
  it "should use explicit type for non integer foreign_key types" do
@@ -774,9 +774,9 @@ END_MIG
774
774
  @d.meta_def(:supports_foreign_key_parsing?){true}
775
775
  @d.meta_def(:foreign_key_list){|t, *a| [{:columns=>[:c1], :table=>:t3, :key=>[:c1]}] if t == :t4}
776
776
  ["create_table(:t4) do\n foreign_key :c1, :t3, :type=>Date, :key=>[:c1]\n \n primary_key [:c1]\nend",
777
- "create_table(:t4) do\n foreign_key :c1, :t3, :key=>[:c1], :type=>Date\n \n primary_key [:c1]\nend"].should include(@d.dump_table_schema(:t4))
777
+ "create_table(:t4) do\n foreign_key :c1, :t3, :key=>[:c1], :type=>Date\n \n primary_key [:c1]\nend"].must_include(@d.dump_table_schema(:t4))
778
778
  ["create_table(:t4) do\n foreign_key :c1, :t3, :type=>\"date\", :key=>[:c1]\n \n primary_key [:c1]\nend",
779
- "create_table(:t4) do\n foreign_key :c1, :t3, :key=>[:c1], :type=>\"date\"\n \n primary_key [:c1]\nend"].should include(@d.dump_table_schema(:t4, :same_db=>true))
779
+ "create_table(:t4) do\n foreign_key :c1, :t3, :key=>[:c1], :type=>\"date\"\n \n primary_key [:c1]\nend"].must_include(@d.dump_table_schema(:t4, :same_db=>true))
780
780
  end
781
781
 
782
782
  it "should correctly handing autoincrementing primary keys that are also foreign keys" do
@@ -784,6 +784,6 @@ END_MIG
784
784
  @d.meta_def(:supports_foreign_key_parsing?){true}
785
785
  @d.meta_def(:foreign_key_list){|t, *a| [{:columns=>[:c1], :table=>:t3, :key=>[:c1]}] if t == :t4}
786
786
  ["create_table(:t4) do\n primary_key :c1, :table=>:t3, :key=>[:c1]\nend",
787
- "create_table(:t4) do\n primary_key :c1, :key=>[:c1], :table=>:t3\nend"].should include(@d.dump_table_schema(:t4))
787
+ "create_table(:t4) do\n primary_key :c1, :key=>[:c1], :table=>:t3\nend"].must_include(@d.dump_table_schema(:t4))
788
788
  end
789
789
  end