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
@@ -8,45 +8,45 @@ describe "pg_inet extension" do
8
8
  end
9
9
 
10
10
  it "should literalize IPAddr v4 instances to strings correctly" do
11
- @db.literal(IPAddr.new('127.0.0.1')).should == "'127.0.0.1/32'"
12
- @db.literal(IPAddr.new('127.0.0.0/8')).should == "'127.0.0.0/8'"
11
+ @db.literal(IPAddr.new('127.0.0.1')).must_equal "'127.0.0.1/32'"
12
+ @db.literal(IPAddr.new('127.0.0.0/8')).must_equal "'127.0.0.0/8'"
13
13
  end
14
14
 
15
15
  it "should literalize IPAddr v6 instances to strings correctly" do
16
- @db.literal(IPAddr.new('2001:4f8:3:ba::/64')).should == "'2001:4f8:3:ba::/64'"
17
- @db.literal(IPAddr.new('2001:4f8:3:ba:2e0:81ff:fe22:d1f1')).should == "'2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128'"
16
+ @db.literal(IPAddr.new('2001:4f8:3:ba::/64')).must_equal "'2001:4f8:3:ba::/64'"
17
+ @db.literal(IPAddr.new('2001:4f8:3:ba:2e0:81ff:fe22:d1f1')).must_equal "'2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128'"
18
18
  end unless ipv6_broken
19
19
 
20
20
  it "should not affect literalization of custom objects" do
21
21
  o = Object.new
22
22
  def o.sql_literal(ds) 'v' end
23
- @db.literal(o).should == 'v'
23
+ @db.literal(o).must_equal 'v'
24
24
  end
25
25
 
26
26
  it "should support using IPAddr as bound variables" do
27
- @db.bound_variable_arg(1, nil).should == 1
28
- @db.bound_variable_arg(IPAddr.new('127.0.0.1'), nil).should == '127.0.0.1/32'
27
+ @db.bound_variable_arg(1, nil).must_equal 1
28
+ @db.bound_variable_arg(IPAddr.new('127.0.0.1'), nil).must_equal '127.0.0.1/32'
29
29
  end
30
30
 
31
31
  it "should support using IPAddr instances in array types in bound variables" do
32
- @db.bound_variable_arg(Sequel.pg_array([IPAddr.new('127.0.0.1')]), nil).should == '{"127.0.0.1/32"}'
32
+ @db.bound_variable_arg(Sequel.pg_array([IPAddr.new('127.0.0.1')]), nil).must_equal '{"127.0.0.1/32"}'
33
33
  end
34
34
 
35
35
  it "should parse inet/cidr type from the schema correctly" do
36
36
  @db.fetch = [{:name=>'id', :db_type=>'integer'}, {:name=>'i', :db_type=>'inet'}, {:name=>'c', :db_type=>'cidr'}]
37
- @db.schema(:items).map{|e| e[1][:type]}.should == [:integer, :ipaddr, :ipaddr]
37
+ @db.schema(:items).map{|e| e[1][:type]}.must_equal [:integer, :ipaddr, :ipaddr]
38
38
  end
39
39
 
40
40
  it "should support typecasting for the ipaddr type" do
41
41
  ip = IPAddr.new('127.0.0.1')
42
- @db.typecast_value(:ipaddr, ip).should equal(ip)
43
- @db.typecast_value(:ipaddr, ip.to_s).should == ip
44
- proc{@db.typecast_value(:ipaddr, '')}.should raise_error(Sequel::InvalidValue)
45
- proc{@db.typecast_value(:ipaddr, 1)}.should raise_error(Sequel::InvalidValue)
42
+ @db.typecast_value(:ipaddr, ip).must_be_same_as(ip)
43
+ @db.typecast_value(:ipaddr, ip.to_s).must_equal ip
44
+ proc{@db.typecast_value(:ipaddr, '')}.must_raise(Sequel::InvalidValue)
45
+ proc{@db.typecast_value(:ipaddr, 1)}.must_raise(Sequel::InvalidValue)
46
46
  end
47
47
 
48
48
  it "should return correct results for Database#schema_type_class" do
49
- @db.schema_type_class(:ipaddr).should == IPAddr
50
- @db.schema_type_class(:integer).should == Integer
49
+ @db.schema_type_class(:ipaddr).must_equal IPAddr
50
+ @db.schema_type_class(:integer).must_equal Integer
51
51
  end
52
52
  end
@@ -12,65 +12,65 @@ describe "pg_interval extension" do
12
12
  end
13
13
 
14
14
  it "should literalize ActiveSupport::Duration instances to strings correctly" do
15
- @db.literal(ActiveSupport::Duration.new(0, [])).should == "'0'::interval"
16
- @db.literal(ActiveSupport::Duration.new(0, [[:seconds, 0]])).should == "'0'::interval"
17
- @db.literal(ActiveSupport::Duration.new(0, [[:seconds, 10], [:minutes, 20], [:days, 3], [:months, 4], [:years, 6]])).should == "'6 years 4 months 3 days 20 minutes 10 seconds '::interval"
18
- @db.literal(ActiveSupport::Duration.new(0, [[:seconds, -10.000001], [:minutes, -20], [:days, -3], [:months, -4], [:years, -6]])).should == "'-6 years -4 months -3 days -20 minutes -10.000001 seconds '::interval"
15
+ @db.literal(ActiveSupport::Duration.new(0, [])).must_equal "'0'::interval"
16
+ @db.literal(ActiveSupport::Duration.new(0, [[:seconds, 0]])).must_equal "'0'::interval"
17
+ @db.literal(ActiveSupport::Duration.new(0, [[:seconds, 10], [:minutes, 20], [:days, 3], [:months, 4], [:years, 6]])).must_equal "'6 years 4 months 3 days 20 minutes 10 seconds '::interval"
18
+ @db.literal(ActiveSupport::Duration.new(0, [[:seconds, -10.000001], [:minutes, -20], [:days, -3], [:months, -4], [:years, -6]])).must_equal "'-6 years -4 months -3 days -20 minutes -10.000001 seconds '::interval"
19
19
  end
20
20
 
21
21
  it "should literalize ActiveSupport::Duration instances with repeated parts correctly" do
22
- @db.literal(ActiveSupport::Duration.new(0, [[:seconds, 2], [:seconds, 1]])).should == "'3 seconds '::interval"
23
- @db.literal(ActiveSupport::Duration.new(0, [[:seconds, 2], [:seconds, 1], [:days, 1], [:days, 4]])).should == "'5 days 3 seconds '::interval"
22
+ @db.literal(ActiveSupport::Duration.new(0, [[:seconds, 2], [:seconds, 1]])).must_equal "'3 seconds '::interval"
23
+ @db.literal(ActiveSupport::Duration.new(0, [[:seconds, 2], [:seconds, 1], [:days, 1], [:days, 4]])).must_equal "'5 days 3 seconds '::interval"
24
24
  end
25
25
 
26
26
  it "should not affect literalization of custom objects" do
27
27
  o = Object.new
28
28
  def o.sql_literal(ds) 'v' end
29
- @db.literal(o).should == 'v'
29
+ @db.literal(o).must_equal 'v'
30
30
  end
31
31
 
32
32
  it "should support using ActiveSupport::Duration instances as bound variables" do
33
- @db.bound_variable_arg(1, nil).should == 1
34
- @db.bound_variable_arg(ActiveSupport::Duration.new(0, [[:seconds, 0]]), nil).should == '0'
35
- @db.bound_variable_arg(ActiveSupport::Duration.new(0, [[:seconds, -10.000001], [:minutes, -20], [:days, -3], [:months, -4], [:years, -6]]), nil).should == '-6 years -4 months -3 days -20 minutes -10.000001 seconds '
33
+ @db.bound_variable_arg(1, nil).must_equal 1
34
+ @db.bound_variable_arg(ActiveSupport::Duration.new(0, [[:seconds, 0]]), nil).must_equal '0'
35
+ @db.bound_variable_arg(ActiveSupport::Duration.new(0, [[:seconds, -10.000001], [:minutes, -20], [:days, -3], [:months, -4], [:years, -6]]), nil).must_equal '-6 years -4 months -3 days -20 minutes -10.000001 seconds '
36
36
  end
37
37
 
38
38
  it "should support using ActiveSupport::Duration instances in array types in bound variables" do
39
- @db.bound_variable_arg(Sequel.pg_array([ActiveSupport::Duration.new(0, [[:seconds, 0]])]), nil).should == '{"0"}'
40
- @db.bound_variable_arg(Sequel.pg_array([ActiveSupport::Duration.new(0, [[:seconds, -10.000001], [:minutes, -20], [:days, -3], [:months, -4], [:years, -6]])]), nil).should == '{"-6 years -4 months -3 days -20 minutes -10.000001 seconds "}'
39
+ @db.bound_variable_arg(Sequel.pg_array([ActiveSupport::Duration.new(0, [[:seconds, 0]])]), nil).must_equal '{"0"}'
40
+ @db.bound_variable_arg(Sequel.pg_array([ActiveSupport::Duration.new(0, [[:seconds, -10.000001], [:minutes, -20], [:days, -3], [:months, -4], [:years, -6]])]), nil).must_equal '{"-6 years -4 months -3 days -20 minutes -10.000001 seconds "}'
41
41
  end
42
42
 
43
43
  it "should parse interval type from the schema correctly" do
44
44
  @db.fetch = [{:name=>'id', :db_type=>'integer'}, {:name=>'i', :db_type=>'interval'}]
45
- @db.schema(:items).map{|e| e[1][:type]}.should == [:integer, :interval]
45
+ @db.schema(:items).map{|e| e[1][:type]}.must_equal [:integer, :interval]
46
46
  end
47
47
 
48
48
  it "should support typecasting for the interval type" do
49
49
  d = ActiveSupport::Duration.new(31557600 + 2*86400*30 + 3*86400*7 + 4*86400 + 5*3600 + 6*60 + 7, [[:years, 1], [:months, 2], [:days, 25], [:seconds, 18367]])
50
- @db.typecast_value(:interval, d).object_id.should == d.object_id
50
+ @db.typecast_value(:interval, d).object_id.must_equal d.object_id
51
51
 
52
- @db.typecast_value(:interval, "1 year 2 mons 25 days 05:06:07").is_a?(ActiveSupport::Duration).should == true
53
- @db.typecast_value(:interval, "1 year 2 mons 25 days 05:06:07").should == d
54
- @db.typecast_value(:interval, "1 year 2 mons 25 days 05:06:07").parts.sort_by{|k,v| k.to_s}.should == d.parts.sort_by{|k,v| k.to_s}
55
- @db.typecast_value(:interval, "1 year 2 mons 25 days 05:06:07.0").parts.sort_by{|k,v| k.to_s}.should == d.parts.sort_by{|k,v| k.to_s}
52
+ @db.typecast_value(:interval, "1 year 2 mons 25 days 05:06:07").is_a?(ActiveSupport::Duration).must_equal true
53
+ @db.typecast_value(:interval, "1 year 2 mons 25 days 05:06:07").must_equal d
54
+ @db.typecast_value(:interval, "1 year 2 mons 25 days 05:06:07").parts.sort_by{|k,v| k.to_s}.must_equal d.parts.sort_by{|k,v| k.to_s}
55
+ @db.typecast_value(:interval, "1 year 2 mons 25 days 05:06:07.0").parts.sort_by{|k,v| k.to_s}.must_equal d.parts.sort_by{|k,v| k.to_s}
56
56
 
57
- @db.typecast_value(:interval, "1 year 2 mons 25 days 5 hours 6 mins 7 secs").is_a?(ActiveSupport::Duration).should == true
58
- @db.typecast_value(:interval, "1 year 2 mons 25 days 5 hours 6 mins 7 secs").should == d
59
- @db.typecast_value(:interval, "1 year 2 mons 25 days 5 hours 6 mins 7 secs").parts.sort_by{|k,v| k.to_s}.should == d.parts.sort_by{|k,v| k.to_s}
60
- @db.typecast_value(:interval, "1 year 2 mons 25 days 5 hours 6 mins 7.0 secs").parts.sort_by{|k,v| k.to_s}.should == d.parts.sort_by{|k,v| k.to_s}
57
+ @db.typecast_value(:interval, "1 year 2 mons 25 days 5 hours 6 mins 7 secs").is_a?(ActiveSupport::Duration).must_equal true
58
+ @db.typecast_value(:interval, "1 year 2 mons 25 days 5 hours 6 mins 7 secs").must_equal d
59
+ @db.typecast_value(:interval, "1 year 2 mons 25 days 5 hours 6 mins 7 secs").parts.sort_by{|k,v| k.to_s}.must_equal d.parts.sort_by{|k,v| k.to_s}
60
+ @db.typecast_value(:interval, "1 year 2 mons 25 days 5 hours 6 mins 7.0 secs").parts.sort_by{|k,v| k.to_s}.must_equal d.parts.sort_by{|k,v| k.to_s}
61
61
 
62
62
  d2 = ActiveSupport::Duration.new(1, [[:seconds, 1]])
63
- @db.typecast_value(:interval, 1).is_a?(ActiveSupport::Duration).should == true
64
- @db.typecast_value(:interval, 1).should == d2
65
- @db.typecast_value(:interval, 1).parts.sort_by{|k,v| k.to_s}.should == d2.parts.sort_by{|k,v| k.to_s}
63
+ @db.typecast_value(:interval, 1).is_a?(ActiveSupport::Duration).must_equal true
64
+ @db.typecast_value(:interval, 1).must_equal d2
65
+ @db.typecast_value(:interval, 1).parts.sort_by{|k,v| k.to_s}.must_equal d2.parts.sort_by{|k,v| k.to_s}
66
66
 
67
- proc{@db.typecast_value(:interval, 'foo')}.should raise_error(Sequel::InvalidValue)
68
- proc{@db.typecast_value(:interval, Object.new)}.should raise_error(Sequel::InvalidValue)
67
+ proc{@db.typecast_value(:interval, 'foo')}.must_raise(Sequel::InvalidValue)
68
+ proc{@db.typecast_value(:interval, Object.new)}.must_raise(Sequel::InvalidValue)
69
69
  end
70
70
 
71
71
  it "should return correct results for Database#schema_type_class" do
72
- @db.schema_type_class(:interval).should == ActiveSupport::Duration
73
- @db.schema_type_class(:integer).should == Integer
72
+ @db.schema_type_class(:interval).must_equal ActiveSupport::Duration
73
+ @db.schema_type_class(:integer).must_equal Integer
74
74
  end
75
75
  end
76
76
  end
@@ -11,217 +11,219 @@ describe "Sequel::Postgres::JSONOp" do
11
11
  end
12
12
 
13
13
  it "should have #[] get the element" do
14
- @l[@j[1]].should == "(j -> 1)"
15
- @l[@j['a']].should == "(j -> 'a')"
14
+ @l[@j[1]].must_equal "(j -> 1)"
15
+ @l[@j['a']].must_equal "(j -> 'a')"
16
16
  end
17
17
 
18
18
  it "should have #[] accept an array" do
19
- @l[@j[%w'a b']].should == "(j #> ARRAY['a','b'])"
20
- @l[@j[Sequel.pg_array(%w'a b')]].should == "(j #> ARRAY['a','b'])"
21
- @l[@j[Sequel.pg_array(:a)]].should == "(j #> a)"
19
+ @l[@j[%w'a b']].must_equal "(j #> ARRAY['a','b'])"
20
+ @l[@j[Sequel.pg_array(%w'a b')]].must_equal "(j #> ARRAY['a','b'])"
21
+ @l[@j[Sequel.pg_array(:a)]].must_equal "(j #> a)"
22
22
  end
23
23
 
24
- it "should have #[] return a JSONOp" do
25
- @l[@j[1][2]].should == "((j -> 1) -> 2)"
26
- @l[@j[%w'a b'][2]].should == "((j #> ARRAY['a','b']) -> 2)"
24
+ it "should have #[] return an object of the same class" do
25
+ @l[@j[1].to_recordset].must_equal "json_to_recordset((j -> 1))"
26
+ @l[@j[%w'a b'][2]].must_equal "((j #> ARRAY['a','b']) -> 2)"
27
+ @l[@jb[1].to_recordset].must_equal "jsonb_to_recordset((j -> 1))"
28
+ @l[@jb[%w'a b'][2]].must_equal "((j #> ARRAY['a','b']) -> 2)"
27
29
  end
28
30
 
29
31
  it "should have #get be an alias to #[]" do
30
- @l[@j.get(1)].should == "(j -> 1)"
31
- @l[@j.get(%w'a b')].should == "(j #> ARRAY['a','b'])"
32
+ @l[@j.get(1)].must_equal "(j -> 1)"
33
+ @l[@j.get(%w'a b')].must_equal "(j #> ARRAY['a','b'])"
32
34
  end
33
35
 
34
36
  it "should have #get_text get the element as text" do
35
- @l[@j.get_text(1)].should == "(j ->> 1)"
36
- @l[@j.get_text('a')].should == "(j ->> 'a')"
37
+ @l[@j.get_text(1)].must_equal "(j ->> 1)"
38
+ @l[@j.get_text('a')].must_equal "(j ->> 'a')"
37
39
  end
38
40
 
39
41
  it "should have #get_text accept an array" do
40
- @l[@j.get_text(%w'a b')].should == "(j #>> ARRAY['a','b'])"
41
- @l[@j.get_text(Sequel.pg_array(%w'a b'))].should == "(j #>> ARRAY['a','b'])"
42
- @l[@j.get_text(Sequel.pg_array(:a))].should == "(j #>> a)"
42
+ @l[@j.get_text(%w'a b')].must_equal "(j #>> ARRAY['a','b'])"
43
+ @l[@j.get_text(Sequel.pg_array(%w'a b'))].must_equal "(j #>> ARRAY['a','b'])"
44
+ @l[@j.get_text(Sequel.pg_array(:a))].must_equal "(j #>> a)"
43
45
  end
44
46
 
45
47
  it "should have #get_text return an SQL::StringExpression" do
46
- @l[@j.get_text(1) + 'a'].should == "((j ->> 1) || 'a')"
47
- @l[@j.get_text(%w'a b') + 'a'].should == "((j #>> ARRAY['a','b']) || 'a')"
48
+ @l[@j.get_text(1) + 'a'].must_equal "((j ->> 1) || 'a')"
49
+ @l[@j.get_text(%w'a b') + 'a'].must_equal "((j #>> ARRAY['a','b']) || 'a')"
48
50
  end
49
51
 
50
52
  it "should have #array_length use the json_array_length function" do
51
- @l[@j.array_length].should == "json_array_length(j)"
52
- @l[@jb.array_length].should == "jsonb_array_length(j)"
53
+ @l[@j.array_length].must_equal "json_array_length(j)"
54
+ @l[@jb.array_length].must_equal "jsonb_array_length(j)"
53
55
  end
54
56
 
55
57
  it "should have #array_length return a numeric expression" do
56
- @l[@j.array_length & 1].should == "(json_array_length(j) & 1)"
57
- @l[@jb.array_length & 1].should == "(jsonb_array_length(j) & 1)"
58
+ @l[@j.array_length & 1].must_equal "(json_array_length(j) & 1)"
59
+ @l[@jb.array_length & 1].must_equal "(jsonb_array_length(j) & 1)"
58
60
  end
59
61
 
60
62
  it "should have #each use the json_each function" do
61
- @l[@j.each].should == "json_each(j)"
62
- @l[@jb.each].should == "jsonb_each(j)"
63
+ @l[@j.each].must_equal "json_each(j)"
64
+ @l[@jb.each].must_equal "jsonb_each(j)"
63
65
  end
64
66
 
65
67
  it "should have #each_text use the json_each_text function" do
66
- @l[@j.each_text].should == "json_each_text(j)"
67
- @l[@jb.each_text].should == "jsonb_each_text(j)"
68
+ @l[@j.each_text].must_equal "json_each_text(j)"
69
+ @l[@jb.each_text].must_equal "jsonb_each_text(j)"
68
70
  end
69
71
 
70
72
  it "should have #extract use the json_extract_path function" do
71
- @l[@j.extract('a')].should == "json_extract_path(j, 'a')"
72
- @l[@j.extract('a', 'b')].should == "json_extract_path(j, 'a', 'b')"
73
- @l[@jb.extract('a')].should == "jsonb_extract_path(j, 'a')"
74
- @l[@jb.extract('a', 'b')].should == "jsonb_extract_path(j, 'a', 'b')"
73
+ @l[@j.extract('a')].must_equal "json_extract_path(j, 'a')"
74
+ @l[@j.extract('a', 'b')].must_equal "json_extract_path(j, 'a', 'b')"
75
+ @l[@jb.extract('a')].must_equal "jsonb_extract_path(j, 'a')"
76
+ @l[@jb.extract('a', 'b')].must_equal "jsonb_extract_path(j, 'a', 'b')"
75
77
  end
76
78
 
77
79
  it "should have #extract return a JSONOp" do
78
- @l[@j.extract('a')[1]].should == "(json_extract_path(j, 'a') -> 1)"
79
- @l[@jb.extract('a')[1]].should == "(jsonb_extract_path(j, 'a') -> 1)"
80
+ @l[@j.extract('a')[1]].must_equal "(json_extract_path(j, 'a') -> 1)"
81
+ @l[@jb.extract('a')[1]].must_equal "(jsonb_extract_path(j, 'a') -> 1)"
80
82
  end
81
83
 
82
84
  it "should have #extract_text use the json_extract_path_text function" do
83
- @l[@j.extract_text('a')].should == "json_extract_path_text(j, 'a')"
84
- @l[@j.extract_text('a', 'b')].should == "json_extract_path_text(j, 'a', 'b')"
85
- @l[@jb.extract_text('a')].should == "jsonb_extract_path_text(j, 'a')"
86
- @l[@jb.extract_text('a', 'b')].should == "jsonb_extract_path_text(j, 'a', 'b')"
85
+ @l[@j.extract_text('a')].must_equal "json_extract_path_text(j, 'a')"
86
+ @l[@j.extract_text('a', 'b')].must_equal "json_extract_path_text(j, 'a', 'b')"
87
+ @l[@jb.extract_text('a')].must_equal "jsonb_extract_path_text(j, 'a')"
88
+ @l[@jb.extract_text('a', 'b')].must_equal "jsonb_extract_path_text(j, 'a', 'b')"
87
89
  end
88
90
 
89
91
  it "should have #extract_text return an SQL::StringExpression" do
90
- @l[@j.extract_text('a') + 'a'].should == "(json_extract_path_text(j, 'a') || 'a')"
91
- @l[@jb.extract_text('a') + 'a'].should == "(jsonb_extract_path_text(j, 'a') || 'a')"
92
+ @l[@j.extract_text('a') + 'a'].must_equal "(json_extract_path_text(j, 'a') || 'a')"
93
+ @l[@jb.extract_text('a') + 'a'].must_equal "(jsonb_extract_path_text(j, 'a') || 'a')"
92
94
  end
93
95
 
94
96
  it "should have #keys use the json_object_keys function" do
95
- @l[@j.keys].should == "json_object_keys(j)"
96
- @l[@jb.keys].should == "jsonb_object_keys(j)"
97
+ @l[@j.keys].must_equal "json_object_keys(j)"
98
+ @l[@jb.keys].must_equal "jsonb_object_keys(j)"
97
99
  end
98
100
 
99
101
  it "should have #array_elements use the json_array_elements function" do
100
- @l[@j.array_elements].should == "json_array_elements(j)"
101
- @l[@jb.array_elements].should == "jsonb_array_elements(j)"
102
+ @l[@j.array_elements].must_equal "json_array_elements(j)"
103
+ @l[@jb.array_elements].must_equal "jsonb_array_elements(j)"
102
104
  end
103
105
 
104
106
  it "should have #array_elements use the json_array_elements_text function" do
105
- @l[@j.array_elements_text].should == "json_array_elements_text(j)"
106
- @l[@jb.array_elements_text].should == "jsonb_array_elements_text(j)"
107
+ @l[@j.array_elements_text].must_equal "json_array_elements_text(j)"
108
+ @l[@jb.array_elements_text].must_equal "jsonb_array_elements_text(j)"
107
109
  end
108
110
 
109
111
  it "should have #typeof use the json_typeof function" do
110
- @l[@j.typeof].should == "json_typeof(j)"
111
- @l[@jb.typeof].should == "jsonb_typeof(j)"
112
+ @l[@j.typeof].must_equal "json_typeof(j)"
113
+ @l[@jb.typeof].must_equal "jsonb_typeof(j)"
112
114
  end
113
115
 
114
116
  it "should have #to_record use the json_to_record function" do
115
- @l[@j.to_record].should == "json_to_record(j)"
116
- @l[@jb.to_record].should == "jsonb_to_record(j)"
117
+ @l[@j.to_record].must_equal "json_to_record(j)"
118
+ @l[@jb.to_record].must_equal "jsonb_to_record(j)"
117
119
  end
118
120
 
119
121
  it "should have #to_recordset use the json_to_recordsetfunction" do
120
- @l[@j.to_recordset].should == "json_to_recordset(j)"
121
- @l[@jb.to_recordset].should == "jsonb_to_recordset(j)"
122
+ @l[@j.to_recordset].must_equal "json_to_recordset(j)"
123
+ @l[@jb.to_recordset].must_equal "jsonb_to_recordset(j)"
122
124
  end
123
125
 
124
126
  it "should have #populate use the json_populate_record function" do
125
- @l[@j.populate(:a)].should == "json_populate_record(a, j)"
126
- @l[@jb.populate(:a)].should == "jsonb_populate_record(a, j)"
127
+ @l[@j.populate(:a)].must_equal "json_populate_record(a, j)"
128
+ @l[@jb.populate(:a)].must_equal "jsonb_populate_record(a, j)"
127
129
  end
128
130
 
129
131
  it "should have #populate_set use the json_populate_record function" do
130
- @l[@j.populate_set(:a)].should == "json_populate_recordset(a, j)"
131
- @l[@jb.populate_set(:a)].should == "jsonb_populate_recordset(a, j)"
132
+ @l[@j.populate_set(:a)].must_equal "json_populate_recordset(a, j)"
133
+ @l[@jb.populate_set(:a)].must_equal "jsonb_populate_recordset(a, j)"
132
134
  end
133
135
 
134
136
  it "#contain_all should use the ?& operator" do
135
- @l[@jb.contain_all(:h1)].should == "(j ?& h1)"
137
+ @l[@jb.contain_all(:h1)].must_equal "(j ?& h1)"
136
138
  end
137
139
 
138
140
  it "#contain_all handle arrays" do
139
- @l[@jb.contain_all(%w'h1')].should == "(j ?& ARRAY['h1'])"
141
+ @l[@jb.contain_all(%w'h1')].must_equal "(j ?& ARRAY['h1'])"
140
142
  end
141
143
 
142
144
  it "#contain_any should use the ?| operator" do
143
- @l[@jb.contain_any(:h1)].should == "(j ?| h1)"
145
+ @l[@jb.contain_any(:h1)].must_equal "(j ?| h1)"
144
146
  end
145
147
 
146
148
  it "#contain_any should handle arrays" do
147
- @l[@jb.contain_any(%w'h1')].should == "(j ?| ARRAY['h1'])"
149
+ @l[@jb.contain_any(%w'h1')].must_equal "(j ?| ARRAY['h1'])"
148
150
  end
149
151
 
150
152
  it "#contains should use the @> operator" do
151
- @l[@jb.contains(:h1)].should == "(j @> h1)"
153
+ @l[@jb.contains(:h1)].must_equal "(j @> h1)"
152
154
  end
153
155
 
154
156
  it "#contains should handle hashes" do
155
- @l[@jb.contains('a'=>'b')].should == "(j @> '{\"a\":\"b\"}'::jsonb)"
157
+ @l[@jb.contains('a'=>'b')].must_equal "(j @> '{\"a\":\"b\"}'::jsonb)"
156
158
  end
157
159
 
158
160
  it "#contains should handle arrays" do
159
- @l[@jb.contains([1, 2])].should == "(j @> '[1,2]'::jsonb)"
161
+ @l[@jb.contains([1, 2])].must_equal "(j @> '[1,2]'::jsonb)"
160
162
  end
161
163
 
162
164
  it "#contained_by should use the <@ operator" do
163
- @l[@jb.contained_by(:h1)].should == "(j <@ h1)"
165
+ @l[@jb.contained_by(:h1)].must_equal "(j <@ h1)"
164
166
  end
165
167
 
166
168
  it "#contained_by should handle hashes" do
167
- @l[@jb.contained_by('a'=>'b')].should == "(j <@ '{\"a\":\"b\"}'::jsonb)"
169
+ @l[@jb.contained_by('a'=>'b')].must_equal "(j <@ '{\"a\":\"b\"}'::jsonb)"
168
170
  end
169
171
 
170
172
  it "#contained_by should handle arrays" do
171
- @l[@jb.contained_by([1, 2])].should == "(j <@ '[1,2]'::jsonb)"
173
+ @l[@jb.contained_by([1, 2])].must_equal "(j <@ '[1,2]'::jsonb)"
172
174
  end
173
175
 
174
176
  it "#has_key? and aliases should use the ? operator" do
175
- @l[@jb.has_key?('a')].should == "(j ? 'a')"
176
- @l[@jb.include?('a')].should == "(j ? 'a')"
177
+ @l[@jb.has_key?('a')].must_equal "(j ? 'a')"
178
+ @l[@jb.include?('a')].must_equal "(j ? 'a')"
177
179
  end
178
180
 
179
181
  it "#pg_json should return self" do
180
- @j.pg_json.should equal(@j)
181
- @jb.pg_jsonb.should equal(@jb)
182
+ @j.pg_json.must_be_same_as(@j)
183
+ @jb.pg_jsonb.must_be_same_as(@jb)
182
184
  end
183
185
 
184
186
  it "Sequel.pg_json_op should return arg for JSONOp" do
185
- Sequel.pg_json_op(@j).should equal(@j)
186
- Sequel.pg_jsonb_op(@jb).should equal(@jb)
187
+ Sequel.pg_json_op(@j).must_be_same_as(@j)
188
+ Sequel.pg_jsonb_op(@jb).must_be_same_as(@jb)
187
189
  end
188
190
 
189
191
  it "should be able to turn expressions into json ops using pg_json" do
190
- @db.literal(Sequel.qualify(:b, :a).pg_json[1]).should == "(b.a -> 1)"
191
- @db.literal(Sequel.function(:a, :b).pg_json[1]).should == "(a(b) -> 1)"
192
- @db.literal(Sequel.qualify(:b, :a).pg_jsonb[1]).should == "(b.a -> 1)"
193
- @db.literal(Sequel.function(:a, :b).pg_jsonb[1]).should == "(a(b) -> 1)"
192
+ @db.literal(Sequel.qualify(:b, :a).pg_json[1]).must_equal "(b.a -> 1)"
193
+ @db.literal(Sequel.function(:a, :b).pg_json[1]).must_equal "(a(b) -> 1)"
194
+ @db.literal(Sequel.qualify(:b, :a).pg_jsonb[1]).must_equal "(b.a -> 1)"
195
+ @db.literal(Sequel.function(:a, :b).pg_jsonb[1]).must_equal "(a(b) -> 1)"
194
196
  end
195
197
 
196
198
  it "should be able to turn literal strings into json ops using pg_json" do
197
- @db.literal(Sequel.lit('a').pg_json[1]).should == "(a -> 1)"
198
- @db.literal(Sequel.lit('a').pg_jsonb[1]).should == "(a -> 1)"
199
+ @db.literal(Sequel.lit('a').pg_json[1]).must_equal "(a -> 1)"
200
+ @db.literal(Sequel.lit('a').pg_jsonb[1]).must_equal "(a -> 1)"
199
201
  end
200
202
 
201
203
  it "should be able to turn symbols into json ops using Sequel.pg_json_op" do
202
- @db.literal(Sequel.pg_json_op(:a)[1]).should == "(a -> 1)"
203
- @db.literal(Sequel.pg_jsonb_op(:a)[1]).should == "(a -> 1)"
204
+ @db.literal(Sequel.pg_json_op(:a)[1]).must_equal "(a -> 1)"
205
+ @db.literal(Sequel.pg_jsonb_op(:a)[1]).must_equal "(a -> 1)"
204
206
  end
205
207
 
206
208
  it "should be able to turn symbols into json ops using Sequel.pg_json" do
207
- @db.literal(Sequel.pg_json(:a)[1]).should == "(a -> 1)"
208
- @db.literal(Sequel.pg_jsonb(:a)[1]).should == "(a -> 1)"
209
- @db.literal(Sequel.pg_jsonb(:a).contains('a'=>1)).should == "(a @> '{\"a\":1}'::jsonb)"
209
+ @db.literal(Sequel.pg_json(:a)[1]).must_equal "(a -> 1)"
210
+ @db.literal(Sequel.pg_jsonb(:a)[1]).must_equal "(a -> 1)"
211
+ @db.literal(Sequel.pg_jsonb(:a).contains('a'=>1)).must_equal "(a @> '{\"a\":1}'::jsonb)"
210
212
  end
211
213
 
212
214
  it "should allow transforming JSONArray instances into ArrayOp instances" do
213
- @db.literal(Sequel.pg_json([1,2]).op[1]).should == "('[1,2]'::json -> 1)"
215
+ @db.literal(Sequel.pg_json([1,2]).op[1]).must_equal "('[1,2]'::json -> 1)"
214
216
  end
215
217
 
216
218
  it "should allow transforming JSONHash instances into ArrayOp instances" do
217
- @db.literal(Sequel.pg_json('a'=>1).op['a']).should == "('{\"a\":1}'::json -> 'a')"
219
+ @db.literal(Sequel.pg_json('a'=>1).op['a']).must_equal "('{\"a\":1}'::json -> 'a')"
218
220
  end
219
221
 
220
222
  it "should allow transforming JSONBArray instances into ArrayOp instances" do
221
- @db.literal(Sequel.pg_jsonb([1,2]).op[1]).should == "('[1,2]'::jsonb -> 1)"
223
+ @db.literal(Sequel.pg_jsonb([1,2]).op[1]).must_equal "('[1,2]'::jsonb -> 1)"
222
224
  end
223
225
 
224
226
  it "should allow transforming JSONBHash instances into ArrayOp instances" do
225
- @db.literal(Sequel.pg_jsonb('a'=>1).op['a']).should == "('{\"a\":1}'::jsonb -> 'a')"
227
+ @db.literal(Sequel.pg_jsonb('a'=>1).op['a']).must_equal "('{\"a\":1}'::jsonb -> 'a')"
226
228
  end
227
229
  end