sequel 4.46.0 → 4.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +210 -0
  3. data/Rakefile +1 -1
  4. data/doc/advanced_associations.rdoc +1 -1
  5. data/doc/opening_databases.rdoc +3 -2
  6. data/doc/release_notes/4.47.0.txt +56 -0
  7. data/doc/release_notes/4.48.0.txt +293 -0
  8. data/doc/release_notes/4.49.0.txt +222 -0
  9. data/lib/sequel/adapters/ado/access.rb +2 -1
  10. data/lib/sequel/adapters/do/postgres.rb +5 -2
  11. data/lib/sequel/adapters/ibmdb.rb +30 -8
  12. data/lib/sequel/adapters/jdbc/as400.rb +1 -1
  13. data/lib/sequel/adapters/jdbc/db2.rb +12 -3
  14. data/lib/sequel/adapters/jdbc/derby.rb +4 -5
  15. data/lib/sequel/adapters/jdbc/h2.rb +10 -1
  16. data/lib/sequel/adapters/jdbc/oracle.rb +16 -2
  17. data/lib/sequel/adapters/jdbc/postgresql.rb +46 -20
  18. data/lib/sequel/adapters/jdbc/sqlanywhere.rb +9 -7
  19. data/lib/sequel/adapters/jdbc/sqlserver.rb +20 -6
  20. data/lib/sequel/adapters/jdbc.rb +39 -23
  21. data/lib/sequel/adapters/mock.rb +27 -19
  22. data/lib/sequel/adapters/mysql.rb +17 -16
  23. data/lib/sequel/adapters/mysql2.rb +5 -6
  24. data/lib/sequel/adapters/oracle.rb +5 -9
  25. data/lib/sequel/adapters/postgres.rb +91 -103
  26. data/lib/sequel/adapters/shared/db2.rb +22 -6
  27. data/lib/sequel/adapters/shared/mssql.rb +5 -4
  28. data/lib/sequel/adapters/shared/mysql.rb +79 -25
  29. data/lib/sequel/adapters/shared/oracle.rb +26 -3
  30. data/lib/sequel/adapters/shared/postgres.rb +199 -95
  31. data/lib/sequel/adapters/shared/sqlanywhere.rb +23 -10
  32. data/lib/sequel/adapters/shared/sqlite.rb +72 -82
  33. data/lib/sequel/adapters/sqlanywhere.rb +4 -1
  34. data/lib/sequel/adapters/sqlite.rb +5 -3
  35. data/lib/sequel/adapters/swift/postgres.rb +5 -2
  36. data/lib/sequel/adapters/tinytds.rb +0 -5
  37. data/lib/sequel/adapters/utils/mysql_mysql2.rb +1 -1
  38. data/lib/sequel/adapters/utils/pg_types.rb +2 -76
  39. data/lib/sequel/ast_transformer.rb +1 -1
  40. data/lib/sequel/connection_pool/sharded_single.rb +1 -1
  41. data/lib/sequel/connection_pool/sharded_threaded.rb +1 -1
  42. data/lib/sequel/connection_pool/single.rb +2 -2
  43. data/lib/sequel/connection_pool/threaded.rb +2 -2
  44. data/lib/sequel/connection_pool.rb +9 -2
  45. data/lib/sequel/core.rb +2 -2
  46. data/lib/sequel/database/connecting.rb +8 -8
  47. data/lib/sequel/database/dataset.rb +6 -3
  48. data/lib/sequel/database/dataset_defaults.rb +14 -1
  49. data/lib/sequel/database/misc.rb +1 -1
  50. data/lib/sequel/database/query.rb +3 -0
  51. data/lib/sequel/database/schema_methods.rb +1 -1
  52. data/lib/sequel/dataset/actions.rb +72 -10
  53. data/lib/sequel/dataset/dataset_module.rb +58 -0
  54. data/lib/sequel/dataset/graph.rb +1 -1
  55. data/lib/sequel/dataset/misc.rb +1 -0
  56. data/lib/sequel/dataset/prepared_statements.rb +3 -3
  57. data/lib/sequel/dataset/query.rb +22 -11
  58. data/lib/sequel/dataset.rb +1 -1
  59. data/lib/sequel/exceptions.rb +8 -0
  60. data/lib/sequel/extensions/_model_pg_row.rb +5 -2
  61. data/lib/sequel/extensions/core_extensions.rb +4 -1
  62. data/lib/sequel/extensions/current_datetime_timestamp.rb +2 -1
  63. data/lib/sequel/extensions/date_arithmetic.rb +1 -0
  64. data/lib/sequel/extensions/duplicate_columns_handler.rb +3 -3
  65. data/lib/sequel/extensions/empty_array_ignore_nulls.rb +3 -0
  66. data/lib/sequel/extensions/filter_having.rb +2 -0
  67. data/lib/sequel/extensions/freeze_datasets.rb +2 -0
  68. data/lib/sequel/extensions/from_block.rb +1 -1
  69. data/lib/sequel/extensions/graph_each.rb +2 -2
  70. data/lib/sequel/extensions/hash_aliases.rb +2 -0
  71. data/lib/sequel/extensions/identifier_mangling.rb +0 -7
  72. data/lib/sequel/extensions/meta_def.rb +2 -0
  73. data/lib/sequel/extensions/migration.rb +11 -8
  74. data/lib/sequel/extensions/no_auto_literal_strings.rb +1 -1
  75. data/lib/sequel/extensions/null_dataset.rb +1 -0
  76. data/lib/sequel/extensions/pagination.rb +1 -1
  77. data/lib/sequel/extensions/pg_array.rb +207 -130
  78. data/lib/sequel/extensions/pg_hstore.rb +38 -20
  79. data/lib/sequel/extensions/pg_inet.rb +18 -6
  80. data/lib/sequel/extensions/pg_interval.rb +19 -12
  81. data/lib/sequel/extensions/pg_json.rb +25 -14
  82. data/lib/sequel/extensions/pg_json_ops.rb +2 -2
  83. data/lib/sequel/extensions/pg_range.rb +133 -100
  84. data/lib/sequel/extensions/pg_range_ops.rb +4 -3
  85. data/lib/sequel/extensions/pg_row.rb +68 -39
  86. data/lib/sequel/extensions/pg_row_ops.rb +11 -5
  87. data/lib/sequel/extensions/query_literals.rb +2 -0
  88. data/lib/sequel/extensions/ruby18_symbol_extensions.rb +2 -0
  89. data/lib/sequel/extensions/s.rb +1 -1
  90. data/lib/sequel/extensions/schema_dumper.rb +29 -25
  91. data/lib/sequel/extensions/sequel_3_dataset_methods.rb +3 -1
  92. data/lib/sequel/extensions/sequel_4_dataset_methods.rb +83 -0
  93. data/lib/sequel/extensions/server_block.rb +32 -15
  94. data/lib/sequel/extensions/set_overrides.rb +2 -2
  95. data/lib/sequel/extensions/string_agg.rb +0 -1
  96. data/lib/sequel/extensions/symbol_aref.rb +0 -4
  97. data/lib/sequel/model/associations.rb +35 -7
  98. data/lib/sequel/model/base.rb +113 -87
  99. data/lib/sequel/model/dataset_module.rb +5 -43
  100. data/lib/sequel/model/errors.rb +2 -1
  101. data/lib/sequel/model/inflections.rb +17 -5
  102. data/lib/sequel/model.rb +26 -58
  103. data/lib/sequel/plugins/active_model.rb +2 -2
  104. data/lib/sequel/plugins/association_autoreloading.rb +2 -0
  105. data/lib/sequel/plugins/association_dependencies.rb +3 -3
  106. data/lib/sequel/plugins/association_pks.rb +73 -46
  107. data/lib/sequel/plugins/association_proxies.rb +1 -1
  108. data/lib/sequel/plugins/auto_validations.rb +6 -2
  109. data/lib/sequel/plugins/boolean_readers.rb +2 -2
  110. data/lib/sequel/plugins/boolean_subsets.rb +1 -1
  111. data/lib/sequel/plugins/caching.rb +19 -13
  112. data/lib/sequel/plugins/class_table_inheritance.rb +24 -13
  113. data/lib/sequel/plugins/column_conflicts.rb +7 -2
  114. data/lib/sequel/plugins/column_select.rb +3 -3
  115. data/lib/sequel/plugins/composition.rb +2 -2
  116. data/lib/sequel/plugins/csv_serializer.rb +8 -8
  117. data/lib/sequel/plugins/dataset_associations.rb +25 -13
  118. data/lib/sequel/plugins/defaults_setter.rb +13 -1
  119. data/lib/sequel/plugins/eager_each.rb +1 -1
  120. data/lib/sequel/plugins/force_encoding.rb +2 -2
  121. data/lib/sequel/plugins/hook_class_methods.rb +9 -12
  122. data/lib/sequel/plugins/identifier_columns.rb +2 -0
  123. data/lib/sequel/plugins/instance_filters.rb +3 -1
  124. data/lib/sequel/plugins/instance_hooks.rb +17 -9
  125. data/lib/sequel/plugins/json_serializer.rb +19 -12
  126. data/lib/sequel/plugins/lazy_attributes.rb +8 -7
  127. data/lib/sequel/plugins/many_to_one_pk_lookup.rb +2 -0
  128. data/lib/sequel/plugins/modification_detection.rb +3 -0
  129. data/lib/sequel/plugins/nested_attributes.rb +6 -2
  130. data/lib/sequel/plugins/pg_array_associations.rb +5 -0
  131. data/lib/sequel/plugins/pg_row.rb +4 -2
  132. data/lib/sequel/plugins/pg_typecast_on_load.rb +2 -0
  133. data/lib/sequel/plugins/prepared_statements.rb +1 -0
  134. data/lib/sequel/plugins/rcte_tree.rb +4 -24
  135. data/lib/sequel/plugins/serialization.rb +9 -15
  136. data/lib/sequel/plugins/single_table_inheritance.rb +8 -3
  137. data/lib/sequel/plugins/split_values.rb +6 -5
  138. data/lib/sequel/plugins/static_cache.rb +31 -25
  139. data/lib/sequel/plugins/subset_conditions.rb +3 -1
  140. data/lib/sequel/plugins/table_select.rb +1 -1
  141. data/lib/sequel/plugins/touch.rb +4 -2
  142. data/lib/sequel/plugins/validation_class_methods.rb +5 -6
  143. data/lib/sequel/plugins/validation_helpers.rb +14 -8
  144. data/lib/sequel/plugins/xml_serializer.rb +4 -4
  145. data/lib/sequel/sql.rb +18 -9
  146. data/lib/sequel/version.rb +1 -1
  147. data/spec/adapters/db2_spec.rb +115 -14
  148. data/spec/adapters/mssql_spec.rb +4 -4
  149. data/spec/adapters/mysql_spec.rb +83 -29
  150. data/spec/adapters/oracle_spec.rb +28 -24
  151. data/spec/adapters/postgres_spec.rb +40 -24
  152. data/spec/adapters/sqlanywhere_spec.rb +88 -86
  153. data/spec/adapters/sqlite_spec.rb +29 -24
  154. data/spec/bin_spec.rb +7 -1
  155. data/spec/core/connection_pool_spec.rb +45 -14
  156. data/spec/core/database_spec.rb +155 -0
  157. data/spec/core/dataset_spec.rb +219 -36
  158. data/spec/core/schema_spec.rb +16 -0
  159. data/spec/core/spec_helper.rb +1 -0
  160. data/spec/core_extensions_spec.rb +6 -2
  161. data/spec/extensions/active_model_spec.rb +1 -1
  162. data/spec/extensions/arbitrary_servers_spec.rb +1 -1
  163. data/spec/extensions/association_pks_spec.rb +34 -2
  164. data/spec/extensions/auto_literal_strings_spec.rb +5 -1
  165. data/spec/extensions/auto_validations_spec.rb +2 -0
  166. data/spec/extensions/boolean_readers_spec.rb +1 -1
  167. data/spec/extensions/boolean_subsets_spec.rb +1 -1
  168. data/spec/extensions/class_table_inheritance_spec.rb +106 -19
  169. data/spec/extensions/column_conflicts_spec.rb +11 -0
  170. data/spec/extensions/column_select_spec.rb +1 -0
  171. data/spec/extensions/composition_spec.rb +13 -0
  172. data/spec/extensions/connection_validator_spec.rb +1 -1
  173. data/spec/extensions/dataset_associations_spec.rb +20 -8
  174. data/spec/extensions/defaults_setter_spec.rb +15 -1
  175. data/spec/extensions/filter_having_spec.rb +5 -3
  176. data/spec/extensions/hash_aliases_spec.rb +3 -1
  177. data/spec/extensions/identifier_columns_spec.rb +3 -1
  178. data/spec/extensions/implicit_subquery_spec.rb +4 -2
  179. data/spec/extensions/json_serializer_spec.rb +18 -0
  180. data/spec/extensions/lazy_attributes_spec.rb +3 -3
  181. data/spec/extensions/many_through_many_spec.rb +4 -4
  182. data/spec/extensions/meta_def_spec.rb +9 -0
  183. data/spec/extensions/migration_spec.rb +3 -3
  184. data/spec/extensions/nested_attributes_spec.rb +14 -3
  185. data/spec/extensions/no_auto_literal_strings_spec.rb +8 -4
  186. data/spec/extensions/null_dataset_spec.rb +1 -1
  187. data/spec/extensions/pg_array_associations_spec.rb +29 -18
  188. data/spec/extensions/pg_array_spec.rb +44 -25
  189. data/spec/extensions/pg_hstore_spec.rb +10 -0
  190. data/spec/extensions/pg_inet_spec.rb +26 -0
  191. data/spec/extensions/pg_interval_spec.rb +20 -0
  192. data/spec/extensions/pg_json_spec.rb +24 -0
  193. data/spec/extensions/pg_range_spec.rb +98 -14
  194. data/spec/extensions/pg_row_spec.rb +14 -4
  195. data/spec/extensions/pg_typecast_on_load_spec.rb +11 -9
  196. data/spec/extensions/prepared_statements_safe_spec.rb +1 -1
  197. data/spec/extensions/query_literals_spec.rb +3 -1
  198. data/spec/extensions/schema_dumper_spec.rb +108 -94
  199. data/spec/extensions/sequel_3_dataset_methods_spec.rb +10 -6
  200. data/spec/extensions/sequel_4_dataset_methods_spec.rb +121 -0
  201. data/spec/extensions/serialization_spec.rb +1 -1
  202. data/spec/extensions/server_block_spec.rb +7 -0
  203. data/spec/extensions/single_table_inheritance_spec.rb +17 -1
  204. data/spec/extensions/spec_helper.rb +7 -1
  205. data/spec/extensions/static_cache_spec.rb +75 -24
  206. data/spec/extensions/string_agg_spec.rb +1 -1
  207. data/spec/extensions/touch_spec.rb +9 -0
  208. data/spec/extensions/validation_helpers_spec.rb +10 -5
  209. data/spec/extensions/whitelist_security_spec.rb +26 -0
  210. data/spec/integration/associations_test.rb +8 -0
  211. data/spec/integration/dataset_test.rb +45 -44
  212. data/spec/integration/model_test.rb +53 -4
  213. data/spec/integration/plugin_test.rb +28 -4
  214. data/spec/integration/prepared_statement_test.rb +3 -0
  215. data/spec/integration/schema_test.rb +21 -1
  216. data/spec/integration/transaction_test.rb +40 -40
  217. data/spec/model/association_reflection_spec.rb +43 -1
  218. data/spec/model/associations_spec.rb +29 -9
  219. data/spec/model/class_dataset_methods_spec.rb +20 -4
  220. data/spec/model/dataset_methods_spec.rb +12 -3
  221. data/spec/model/eager_loading_spec.rb +8 -8
  222. data/spec/model/model_spec.rb +45 -1
  223. data/spec/model/plugins_spec.rb +34 -0
  224. data/spec/model/record_spec.rb +1 -1
  225. data/spec/spec_config.rb +2 -0
  226. metadata +11 -4
  227. data/spec/adapters/firebird_spec.rb +0 -405
  228. data/spec/adapters/informix_spec.rb +0 -100
@@ -49,7 +49,7 @@ describe "Sequel::Model basic support" do
49
49
  Item.all.must_equal [Item.load(:id=>1, :name=>'J')]
50
50
  end
51
51
 
52
- it "should not raise an error if the implied database table doesn't exist " do
52
+ deprecated "should not raise an error if the implied database table doesn't exist" do
53
53
  class ::Item::Thing < Sequel::Model(@db)
54
54
  set_dataset :items
55
55
  end
@@ -57,6 +57,26 @@ describe "Sequel::Model basic support" do
57
57
  Item::Thing.first.must_equal Item::Thing.load(:id=>1, :name=>'J')
58
58
  end
59
59
 
60
+ it "should raise an error if the implied database table doesn't exist if require_valid_table is true" do
61
+ proc do
62
+ c = Sequel::Model(@db)
63
+ c.require_valid_table = true
64
+ class ::Item::Thing < c
65
+ set_dataset :items
66
+ end
67
+ end.must_raise Sequel::Error
68
+ end
69
+
70
+ it "should not raise an error if the implied database table doesn't exist if require_valid_table is false" do
71
+ c = Sequel::Model(@db)
72
+ c.require_valid_table = false
73
+ class ::Item::Thing < c
74
+ set_dataset :items
75
+ end
76
+ Item.create(:name=>'J')
77
+ Item::Thing.first.must_equal Item::Thing.load(:id=>1, :name=>'J')
78
+ end
79
+
60
80
  it "should create accessors for all table columns even if all dataset columns aren't selected" do
61
81
  c = Class.new(Sequel::Model(@db[:items].select(:id)))
62
82
  o = c.new
@@ -219,14 +239,43 @@ describe "Sequel::Model basic support" do
219
239
  end
220
240
 
221
241
  describe "Sequel::Model with no existing table" do
222
- it "should not raise an error when setting the dataset" do
242
+ deprecated "should not raise an error when setting the dataset" do
223
243
  db = DB
224
244
  db.drop_table?(:items)
225
- class ::Item < Sequel::Model(db); end; Object.send(:remove_const, :Item)
226
- c = Class.new(Sequel::Model); c.set_dataset(db[:items])
245
+ c = Class.new(Sequel::Model)
246
+ c.set_dataset(db[:items])
227
247
  db.transaction do
228
248
  c = Class.new(Sequel::Model(db[:items]))
229
249
  db.get(Sequel.cast(1, Integer)).must_equal 1
230
250
  end
231
251
  end
252
+
253
+ it "should not raise an error when setting the dataset when require_valid_table is true" do
254
+ db = DB
255
+ db.drop_table?(:items)
256
+ c1 = Sequel::Model(db);
257
+ c = Class.new(Sequel::Model)
258
+ c.require_valid_table = true
259
+ proc{c.set_dataset(db[:items])}.must_raise Sequel::Error
260
+ db.transaction do
261
+ c = Class.new(Sequel::Model)
262
+ c.require_valid_table = true
263
+ proc{c.dataset = db[:items]}.must_raise Sequel::Error
264
+ db.get(Sequel.cast(1, Integer)).must_equal 1
265
+ end
266
+ end
267
+
268
+ it "should not raise an error when setting the dataset when require_valid_table is false" do
269
+ db = DB
270
+ db.drop_table?(:items)
271
+ c = Class.new(Sequel::Model)
272
+ c.require_valid_table = false
273
+ c.set_dataset(db[:items])
274
+ db.transaction do
275
+ c = Class.new(Sequel::Model)
276
+ c.require_valid_table = false
277
+ c.dataset = db[:items]
278
+ db.get(Sequel.cast(1, Integer)).must_equal 1
279
+ end
280
+ end
232
281
  end
@@ -38,7 +38,8 @@ describe "Class Table Inheritance Plugin" do
38
38
  class ::Staff < Employee
39
39
  many_to_one :manager
40
40
  end
41
-
41
+ class ::Intern < Employee
42
+ end
42
43
 
43
44
  @i1 = @db[:employees].insert(:name=>'E', :kind=>'Employee')
44
45
  @i2 = @db[:employees].insert(:name=>'S', :kind=>'Staff')
@@ -51,9 +52,10 @@ describe "Class Table Inheritance Plugin" do
51
52
  @db[:managers].insert(:id=>@i5, :num_staff=>2)
52
53
  @db[:executives].insert(:id=>@i5, :num_managers=>1)
53
54
  @db[:staff].insert(:id=>@i2, :manager_id=>@i4)
55
+ @i6 = @db[:employees].insert(:name=>'I', :kind=>'Intern')
54
56
  end
55
57
  after do
56
- [:Ceo, :Executive, :Manager, :Staff, :Employee].each{|s| Object.send(:remove_const, s)}
58
+ [:Intern, :Ceo, :Executive, :Manager, :Staff, :Employee].each{|s| Object.send(:remove_const, s)}
57
59
  end
58
60
  after(:all) do
59
61
  @db.drop_table? :staff, :executives, :managers, :employees
@@ -65,7 +67,8 @@ describe "Class Table Inheritance Plugin" do
65
67
  Staff.load(:id=>@i2, :name=>'S', :kind=>'Staff'),
66
68
  Manager.load(:id=>@i3, :name=>'M', :kind=>'Manager'),
67
69
  Executive.load(:id=>@i4, :name=>'Ex', :kind=>'Executive'),
68
- Ceo.load(:id=>@i5, :name=>'C', :kind=>'Ceo')
70
+ Ceo.load(:id=>@i5, :name=>'C', :kind=>'Ceo'),
71
+ Intern.load(:id=>@i6, :name=>'I', :kind=>'Intern'),
69
72
  ]
70
73
  end
71
74
 
@@ -102,6 +105,7 @@ describe "Class Table Inheritance Plugin" do
102
105
  Manager.db_schema.keys.sort_by{|x| x.to_s}.must_equal [:id, :kind, :name, :num_staff]
103
106
  Executive.db_schema.keys.sort_by{|x| x.to_s}.must_equal [:id, :kind, :name, :num_managers, :num_staff]
104
107
  Ceo.db_schema.keys.sort_by{|x| x.to_s}.must_equal [:id, :kind, :name, :num_managers, :num_staff]
108
+ Intern.db_schema.keys.sort_by{|x| x.to_s}.must_equal [:id, :kind, :name]
105
109
  end
106
110
 
107
111
  it "should include columns for tables for ancestor classes" do
@@ -110,6 +114,7 @@ describe "Class Table Inheritance Plugin" do
110
114
  Manager.columns.must_equal [:id, :name, :kind, :num_staff]
111
115
  Executive.columns.must_equal [:id, :name, :kind, :num_staff, :num_managers]
112
116
  Ceo.columns.must_equal [:id, :name, :kind, :num_staff, :num_managers]
117
+ Intern.columns.must_equal [:id, :name, :kind]
113
118
  end
114
119
 
115
120
  it "should delete rows from all tables" do
@@ -1195,6 +1200,7 @@ describe "AssociationPks plugin" do
1195
1200
  class ::Album < Sequel::Model
1196
1201
  plugin :association_pks
1197
1202
  many_to_many :tags, :order=>:id, :delay_pks=>false
1203
+ many_to_many :uat_tags, :order=>Sequel[:tags][:id], :delay_pks=>false, :class=>:Tag, :right_key=>:tag_id, :association_pks_use_associated_table=>true
1198
1204
  end
1199
1205
  class ::Tag < Sequel::Model
1200
1206
  end
@@ -1260,6 +1266,10 @@ describe "AssociationPks plugin" do
1260
1266
  Album.order(:id).all.map{|a| a.tag_pks.sort}.must_equal [[@t1, @t2, @t3], [@t2], []]
1261
1267
  end
1262
1268
 
1269
+ it "should return correct associated pks for many_to_many associations using :association_pks_use_associated_table" do
1270
+ Album.order(:id).all.map{|a| a.uat_tag_pks.sort}.must_equal [[@t1, @t2, @t3], [@t2], []]
1271
+ end
1272
+
1263
1273
  it "should return correct associated right-side cpks for one_to_many associations" do
1264
1274
  Album.one_to_many :vocalists, :order=>:first
1265
1275
  Album.order(:id).all.map{|a| a.vocalist_pks.sort}.must_equal [[@v1, @v2, @v3], [], []]
@@ -1270,6 +1280,11 @@ describe "AssociationPks plugin" do
1270
1280
  Album.order(:id).all.map{|a| a.vocalist_pks.sort}.must_equal [[@v1, @v2, @v3], [@v2], []]
1271
1281
  end
1272
1282
 
1283
+ it "should return correct associated right-side cpks for many_to_many associations when using :association_pks_use_associated_table" do
1284
+ Album.many_to_many :vocalists, :join_table=>:albums_vocalists, :right_key=>[:first, :last], :order=>Sequel[:vocalists][:first], :association_pks_use_associated_table=>true
1285
+ Album.order(:id).all.map{|a| a.vocalist_pks.sort}.must_equal [[@v1, @v2, @v3], [@v2], []]
1286
+ end
1287
+
1273
1288
  it "should return correct associated pks for left-side cpks for one_to_many associations" do
1274
1289
  Vocalist.one_to_many :instruments, :key=>[:first, :last], :order=>:id
1275
1290
  Vocalist.order(:first, :last).all.map{|a| a.instrument_pks.sort}.must_equal [[@i1, @i2, @i3], [], []]
@@ -1280,6 +1295,11 @@ describe "AssociationPks plugin" do
1280
1295
  Vocalist.order(:first, :last).all.map{|a| a.instrument_pks.sort}.must_equal [[@i1, @i2, @i3], [@i2], []]
1281
1296
  end
1282
1297
 
1298
+ it "should return correct associated pks for left-side cpks for many_to_many associations when using :association_pks_use_associated_table" do
1299
+ Vocalist.many_to_many :instruments, :join_table=>:vocalists_instruments, :left_key=>[:first, :last], :order=>:id, :association_pks_use_associated_table=>true
1300
+ Vocalist.order(:first, :last).all.map{|a| a.instrument_pks.sort}.must_equal [[@i1, @i2, @i3], [@i2], []]
1301
+ end
1302
+
1283
1303
  it "should return correct associated right-side cpks for left-side cpks for one_to_many associations" do
1284
1304
  Vocalist.one_to_many :hits, :key=>[:first, :last], :order=>:week
1285
1305
  Vocalist.order(:first, :last).all.map{|a| a.hit_pks.sort}.must_equal [[@h1, @h2, @h3], [], []]
@@ -1290,6 +1310,11 @@ describe "AssociationPks plugin" do
1290
1310
  Vocalist.order(:first, :last).all.map{|a| a.hit_pks.sort}.must_equal [[@h1, @h2, @h3], [@h2], []]
1291
1311
  end
1292
1312
 
1313
+ it "should return correct associated right-side cpks for left-side cpks for many_to_many associations when using :association_pks_use_associated_table" do
1314
+ Vocalist.many_to_many :hits, :join_table=>:vocalists_hits, :left_key=>[:first, :last], :right_key=>[:year, :week], :order=>Sequel[:vocalists_hits][:week], :association_pks_use_associated_table=>true
1315
+ Vocalist.order(:first, :last).all.map{|a| a.hit_pks.sort}.must_equal [[@h1, @h2, @h3], [@h2], []]
1316
+ end
1317
+
1293
1318
  deprecated "should handle :delay_pks=>true association option for new instances" do
1294
1319
  album_class = Class.new(Album)
1295
1320
  album_class.many_to_many :tags, :clone=>:tags, :delay_pks=>true, :join_table=>:albums_tags, :left_key=>:album_id
@@ -1937,7 +1962,6 @@ describe "Caching plugins" do
1937
1962
  end
1938
1963
  before do
1939
1964
  @Album = Class.new(Sequel::Model(@db[:albums]))
1940
- @Album.plugin :many_to_one_pk_lookup
1941
1965
  end
1942
1966
  after(:all) do
1943
1967
  @db.drop_table?(:albums, :artists)
@@ -22,6 +22,7 @@ describe "Prepared Statements and Bound Arguments" do
22
22
  @ds.filter(:numb=>:$n).call(:all, :n=>10).must_equal [{:id=>1, :numb=>10}]
23
23
  @ds.filter(:numb=>:$n).call(:first, :n=>10).must_equal(:id=>1, :numb=>10)
24
24
  @ds.filter(:numb=>:$n).call([:map, :numb], :n=>10).must_equal [10]
25
+ @ds.filter(:numb=>:$n).call([:as_hash, :id, :numb], :n=>10).must_equal(1=>10)
25
26
  @ds.filter(:numb=>:$n).call([:to_hash, :id, :numb], :n=>10).must_equal(1=>10)
26
27
  @ds.filter(:numb=>:$n).call([:to_hash_groups, :id, :numb], :n=>10).must_equal(1=>[10])
27
28
  end
@@ -161,6 +162,8 @@ describe "Prepared Statements and Bound Arguments" do
161
162
  @db.call(:select_n, :n=>10).must_equal(:id=>1, :numb=>10)
162
163
  @ds.filter(:numb=>:$n).prepare([:map, :numb], :select_n)
163
164
  @db.call(:select_n, :n=>10).must_equal [10]
165
+ @ds.filter(:numb=>:$n).prepare([:as_hash, :id, :numb], :select_n)
166
+ @db.call(:select_n, :n=>10).must_equal(1=>10)
164
167
  @ds.filter(:numb=>:$n).prepare([:to_hash, :id, :numb], :select_n)
165
168
  @db.call(:select_n, :n=>10).must_equal(1=>10)
166
169
  end
@@ -215,7 +215,7 @@ describe "Database index parsing" do
215
215
  DB.indexes(:items).must_equal({})
216
216
  end
217
217
 
218
- cspecify "should not include partial indexes", :sqlite do
218
+ it "should not include partial indexes" do
219
219
  DB.create_table!(:items){Integer :n; Integer :a; index :n, :where=>proc{n > 10}}
220
220
  DB.indexes(:items).must_equal({})
221
221
  end if DB.supports_partial_indexes?
@@ -387,6 +387,26 @@ describe "Database schema modifiers" do
387
387
  @db.table_exists?(:items).must_equal false
388
388
  end if DB.supports_transactional_ddl?
389
389
 
390
+ it "should handle errors creating indexes when ignoring index errors" do
391
+ @db.drop_table?(:items)
392
+ @db.transaction do
393
+ @db.create_table(:items, :ignore_index_errors=>true) do
394
+ Integer :n1
395
+ Integer :n2
396
+ index :n1, :name=>'items_n1'
397
+ index :foo, :name=>'items_f'
398
+ index :n2, :name=>'items_n2'
399
+ index :bar, :name=>'items_g'
400
+ end
401
+ end
402
+ @db.table_exists?(:items).must_equal true
403
+ indexes = @db.indexes(:items).keys
404
+ indexes.must_include :items_n1
405
+ indexes.must_include :items_n2
406
+ indexes.wont_include :items_f
407
+ indexes.wont_include :items_g
408
+ end if DB.supports_transactional_ddl? && DB.database_type != :mssql
409
+
390
410
  describe "join tables" do
391
411
  after do
392
412
  @db.drop_join_table(:cat_id=>:cats, :dog_id=>:dogs) if @db.table_exists?(:cats_dogs)
@@ -14,7 +14,7 @@ describe "Database transactions" do
14
14
  end
15
15
 
16
16
  it "should support transactions" do
17
- @db.transaction{@d << {:name => 'abc', :value => 1}}
17
+ @db.transaction{@d.insert(:name => 'abc', :value => 1)}
18
18
  @d.count.must_equal 1
19
19
  end
20
20
 
@@ -32,25 +32,25 @@ describe "Database transactions" do
32
32
  it "should correctly rollback transactions" do
33
33
  proc do
34
34
  @db.transaction do
35
- @d << {:name => 'abc', :value => 1}
35
+ @d.insert(:name => 'abc', :value => 1)
36
36
  raise Interrupt, 'asdf'
37
37
  end
38
38
  end.must_raise(Interrupt)
39
39
 
40
40
  @db.transaction do
41
- @d << {:name => 'abc', :value => 1}
41
+ @d.insert(:name => 'abc', :value => 1)
42
42
  raise Sequel::Rollback
43
43
  end.must_be_nil
44
44
 
45
45
  proc do
46
46
  @db.transaction(:rollback=>:reraise) do
47
- @d << {:name => 'abc', :value => 1}
47
+ @d.insert(:name => 'abc', :value => 1)
48
48
  raise Sequel::Rollback
49
49
  end
50
50
  end.must_raise(Sequel::Rollback)
51
51
 
52
52
  @db.transaction(:rollback=>:always) do
53
- @d << {:name => 'abc', :value => 1}
53
+ @d.insert(:name => 'abc', :value => 1)
54
54
  2
55
55
  end.must_equal 2
56
56
 
@@ -60,14 +60,14 @@ describe "Database transactions" do
60
60
  it "should support nested transactions" do
61
61
  @db.transaction do
62
62
  @db.transaction do
63
- @d << {:name => 'abc', :value => 1}
63
+ @d.insert(:name => 'abc', :value => 1)
64
64
  end
65
65
  end
66
66
  @d.count.must_equal 1
67
67
 
68
68
  @d.delete
69
69
  @db.transaction do
70
- @d << {:name => 'abc', :value => 1}
70
+ @d.insert(:name => 'abc', :value => 1)
71
71
  @db.transaction do
72
72
  raise Sequel::Rollback
73
73
  end
@@ -75,7 +75,7 @@ describe "Database transactions" do
75
75
  @d.count.must_equal 0
76
76
 
77
77
  proc {@db.transaction do
78
- @d << {:name => 'abc', :value => 1}
78
+ @d.insert(:name => 'abc', :value => 1)
79
79
  @db.transaction do
80
80
  raise Interrupt, 'asdf'
81
81
  end
@@ -86,9 +86,9 @@ describe "Database transactions" do
86
86
  if DB.supports_savepoints?
87
87
  it "should handle table_exists? failures inside transactions" do
88
88
  @db.transaction do
89
- @d << {:name => '1'}
89
+ @d.insert(:name => '1')
90
90
  @db.table_exists?(:asadf098asd9asd98sa).must_equal false
91
- @d << {:name => '2'}
91
+ @d.insert(:name => '2')
92
92
  end
93
93
  @d.select_order_map(:name).must_equal %w'1 2'
94
94
  end
@@ -96,7 +96,7 @@ describe "Database transactions" do
96
96
  it "should handle :rollback=>:always inside transactions" do
97
97
  @db.transaction do
98
98
  @db.transaction(:rollback=>:always) do
99
- @d << {:name => 'abc', :value => 1}
99
+ @d.insert(:name => 'abc', :value => 1)
100
100
  2
101
101
  end.must_equal 2
102
102
  end
@@ -105,36 +105,36 @@ describe "Database transactions" do
105
105
 
106
106
  it "should handle table_exists? failures inside savepoints" do
107
107
  @db.transaction do
108
- @d << {:name => '1'}
108
+ @d.insert(:name => '1')
109
109
  @db.transaction(:savepoint=>true) do
110
- @d << {:name => '2'}
110
+ @d.insert(:name => '2')
111
111
  @db.table_exists?(:asadf098asd9asd98sa).must_equal false
112
- @d << {:name => '3'}
112
+ @d.insert(:name => '3')
113
113
  end
114
- @d << {:name => '4'}
114
+ @d.insert(:name => '4')
115
115
  end
116
116
  @d.select_order_map(:name).must_equal %w'1 2 3 4'
117
117
  end
118
118
 
119
119
  it "should support nested transactions through savepoints using the savepoint option" do
120
120
  @db.transaction do
121
- @d << {:name => '1'}
121
+ @d.insert(:name => '1')
122
122
  @db.transaction(:savepoint=>true) do
123
- @d << {:name => '2'}
123
+ @d.insert(:name => '2')
124
124
  @db.transaction do
125
- @d << {:name => '3'}
125
+ @d.insert(:name => '3')
126
126
  raise Sequel::Rollback
127
127
  end
128
128
  end
129
- @d << {:name => '4'}
129
+ @d.insert(:name => '4')
130
130
  @db.transaction do
131
- @d << {:name => '6'}
131
+ @d.insert(:name => '6')
132
132
  @db.transaction(:savepoint=>true) do
133
- @d << {:name => '7'}
133
+ @d.insert(:name => '7')
134
134
  raise Sequel::Rollback
135
135
  end
136
136
  end
137
- @d << {:name => '5'}
137
+ @d.insert(:name => '5')
138
138
  end
139
139
 
140
140
  @d.order(:name).map(:name).must_equal %w{1 4 5 6}
@@ -142,23 +142,23 @@ describe "Database transactions" do
142
142
 
143
143
  it "should support nested transactions through savepoints using the auto_savepoint option" do
144
144
  @db.transaction(:auto_savepoint=>true) do
145
- @d << {:name => '1'}
145
+ @d.insert(:name => '1')
146
146
  @db.transaction do
147
- @d << {:name => '2'}
147
+ @d.insert(:name => '2')
148
148
  @db.transaction do
149
- @d << {:name => '3'}
149
+ @d.insert(:name => '3')
150
150
  raise Sequel::Rollback
151
151
  end
152
152
  end
153
- @d << {:name => '4'}
153
+ @d.insert(:name => '4')
154
154
  @db.transaction(:auto_savepoint=>true) do
155
- @d << {:name => '6'}
155
+ @d.insert(:name => '6')
156
156
  @db.transaction do
157
- @d << {:name => '7'}
157
+ @d.insert(:name => '7')
158
158
  raise Sequel::Rollback
159
159
  end
160
160
  end
161
- @d << {:name => '5'}
161
+ @d.insert(:name => '5')
162
162
  end
163
163
 
164
164
  @d.order(:name).map(:name).must_equal %w{1 4 5 6}
@@ -168,7 +168,7 @@ describe "Database transactions" do
168
168
  it "should handle returning inside of the block by committing" do
169
169
  def ret_commit
170
170
  @db.transaction do
171
- @db[:items] << {:name => 'abc'}
171
+ @db[:items].insert(:name => 'abc')
172
172
  return
173
173
  end
174
174
  end
@@ -199,20 +199,20 @@ describe "Database transactions" do
199
199
  end
200
200
 
201
201
  it "should commit prepared transactions using commit_prepared_transaction" do
202
- @db.transaction(:prepare=>'XYZ'){@d << {:name => '1'}}
202
+ @db.transaction(:prepare=>'XYZ'){@d.insert(:name => '1')}
203
203
  @db.commit_prepared_transaction('XYZ')
204
204
  @d.select_order_map(:name).must_equal ['1']
205
205
  end
206
206
 
207
207
  it "should rollback prepared transactions using rollback_prepared_transaction" do
208
- @db.transaction(:prepare=>'XYZ'){@d << {:name => '1'}}
208
+ @db.transaction(:prepare=>'XYZ'){@d.insert(:name => '1')}
209
209
  @db.rollback_prepared_transaction('XYZ')
210
210
  @d.select_order_map(:name).must_equal []
211
211
  end
212
212
 
213
213
  if DB.supports_savepoints_in_prepared_transactions?
214
214
  it "should support savepoints when using prepared transactions" do
215
- @db.transaction(:prepare=>'XYZ'){@db.transaction(:savepoint=>true){@d << {:name => '1'}}}
215
+ @db.transaction(:prepare=>'XYZ'){@db.transaction(:savepoint=>true){@d.insert(:name => '1')}}
216
216
  @db.commit_prepared_transaction('XYZ')
217
217
  @d.select_order_map(:name).must_equal ['1']
218
218
  end
@@ -221,7 +221,7 @@ describe "Database transactions" do
221
221
 
222
222
  it "should support all transaction isolation levels" do
223
223
  [:uncommitted, :committed, :repeatable, :serializable].each_with_index do |l, i|
224
- @db.transaction(:isolation=>l){@d << {:name => 'abc', :value => 1}}
224
+ @db.transaction(:isolation=>l){@d.insert(:name => 'abc', :value => 1)}
225
225
  @d.count.must_equal i + 1
226
226
  end
227
227
  end
@@ -331,10 +331,10 @@ if (! defined?(RUBY_ENGINE) or RUBY_ENGINE == 'ruby') and RUBY_VERSION < '1.9'
331
331
  q1 = Queue.new
332
332
  t = Thread.new do
333
333
  @db.transaction do
334
- @d << {:name => 'abc', :value => 1}
334
+ @d.insert(:name => 'abc', :value => 1)
335
335
  q1.push nil
336
336
  q.pop
337
- @d << {:name => 'def', :value => 2}
337
+ @d.insert(:name => 'def', :value => 2)
338
338
  end
339
339
  end
340
340
  q1.pop
@@ -348,14 +348,14 @@ if (! defined?(RUBY_ENGINE) or RUBY_ENGINE == 'ruby') and RUBY_VERSION < '1.9'
348
348
  q1 = Queue.new
349
349
  t = Thread.new do
350
350
  @db.transaction do
351
- @d << {:name => 'abc', :value => 1}
351
+ @d.insert(:name => 'abc', :value => 1)
352
352
  @db.transaction(:savepoint=>true) do
353
- @d << {:name => 'def', :value => 2}
353
+ @d.insert(:name => 'def', :value => 2)
354
354
  q1.push nil
355
355
  q.pop
356
- @d << {:name => 'ghi', :value => 3}
356
+ @d.insert(:name => 'ghi', :value => 3)
357
357
  end
358
- @d << {:name => 'jkl', :value => 4}
358
+ @d.insert(:name => 'jkl', :value => 4)
359
359
  end
360
360
  end
361
361
  q1.pop
@@ -286,7 +286,7 @@ describe Sequel::Model::Associations::AssociationReflection do
286
286
  def @c.name() "C" end
287
287
  end
288
288
 
289
- it "#eager_loading_predicate_key should be an alias of predicate_key for backwards compatibility" do
289
+ deprecated "#eager_loading_predicate_key should be an alias of predicate_key for backwards compatibility" do
290
290
  @c.one_to_many :cs, :class=>@c
291
291
  @c.dataset.literal(@c.association_reflection(:cs).eager_loading_predicate_key).must_equal 'foo.c_id'
292
292
  end
@@ -586,6 +586,48 @@ describe Sequel::Model::Associations::AssociationReflection, "with default assoc
586
586
  r[:foo].must_equal 3
587
587
  r[:bar].must_equal 2
588
588
  end
589
+
590
+ it "should have default_association_type_options take precedence over default_association_options" do
591
+ @c.default_association_options = {:foo=>2, :bar=>3}
592
+ @c.default_association_type_options[:many_to_one] = {:foo=>1, :bar=>2}
593
+ @c.many_to_one :c, :class=>@c, :foo=>3
594
+ r = @c.association_reflection(:c)
595
+ r[:foo].must_equal 3
596
+ r[:bar].must_equal 2
597
+ end
598
+
599
+ it "should use default_association_type_options as defaults" do
600
+ @c.default_association_type_options[:many_to_one] = {:foo=>1, :bar=>2}
601
+ @c.many_to_one :c, :class=>@c, :foo=>3
602
+ r = @c.association_reflection(:c)
603
+ r[:foo].must_equal 3
604
+ r[:bar].must_equal 2
605
+
606
+ @c.one_to_many :cs, :class=>@c, :foo=>3
607
+ r = @c.association_reflection(:cs)
608
+ r[:foo].must_equal 3
609
+ r[:bar].must_be_nil
610
+ end
611
+
612
+ it "should inherit default_association_type_options" do
613
+ @c.default_association_type_options[:many_to_one] = {:foo=>1, :bar=>2}
614
+ c = Class.new(@c)
615
+ c.many_to_one :c, :class=>c, :foo=>3
616
+ r = c.association_reflection(:c)
617
+ r[:foo].must_equal 3
618
+ r[:bar].must_equal 2
619
+
620
+ @c.default_association_type_options[:many_to_one][:bar] = 4
621
+ c.many_to_one :d, :class=>c, :foo=>3
622
+ r = c.association_reflection(:d)
623
+ r[:foo].must_equal 3
624
+ r[:bar].must_equal 2
625
+
626
+ c.one_to_many :ds, :class=>c, :foo=>3
627
+ r = c.association_reflection(:ds)
628
+ r[:foo].must_equal 3
629
+ r[:bar].must_be_nil
630
+ end
589
631
  end
590
632
 
591
633
  describe "Sequel::Model.freeze" do
@@ -679,7 +679,7 @@ describe Sequel::Model, "many_to_one" do
679
679
  p.associations[:parent].must_equal :foo
680
680
  end
681
681
 
682
- it "should raise error and not call internal add or remove method if before callback returns false, even if raise_on_save_failure is false" do
682
+ deprecated "should raise error and not call internal add or remove method if before callback returns false, even if raise_on_save_failure is false" do
683
683
  p = @c2.new
684
684
  c = @c2.load(:id=>123)
685
685
  p.raise_on_save_failure = false
@@ -1126,7 +1126,7 @@ describe Sequel::Model, "one_to_one" do
1126
1126
  parent.pk.must_equal 20
1127
1127
  end
1128
1128
 
1129
- it "should raise error and not call internal add or remove method if before callback returns false, even if raise_on_save_failure is false" do
1129
+ deprecated "should raise error and not call internal add or remove method if before callback returns false, even if raise_on_save_failure is false" do
1130
1130
  p = @c2.load(:id=>321)
1131
1131
  c = @c2.load(:id=>123)
1132
1132
  p.raise_on_save_failure = false
@@ -1141,6 +1141,21 @@ describe Sequel::Model, "one_to_one" do
1141
1141
  proc{p.parent = nil}.must_raise(Sequel::HookFailed)
1142
1142
  end
1143
1143
 
1144
+ it "should raise error and not call internal add or remove method if before callback calls cancel_action, even if raise_on_save_failure is false" do
1145
+ p = @c2.load(:id=>321)
1146
+ c = @c2.load(:id=>123)
1147
+ p.raise_on_save_failure = false
1148
+ @c2.one_to_one :parent, :class => @c2, :before_set=>:bs
1149
+ def p.bs(x) cancel_action end
1150
+ def p._parent=; raise; end
1151
+ proc{p.parent = c}.must_raise(Sequel::HookFailed)
1152
+
1153
+ p.associations[:parent].must_be_nil
1154
+ p.associations[:parent] = c
1155
+ p.parent.must_equal c
1156
+ proc{p.parent = nil}.must_raise(Sequel::HookFailed)
1157
+ end
1158
+
1144
1159
  it "should not validate the associated object in setter if the :validate=>false option is used" do
1145
1160
  @c2.one_to_one :parent, :class => @c2, :validate=>false
1146
1161
  n = @c2.new(:id => 1234)
@@ -1878,7 +1893,7 @@ describe Sequel::Model, "one_to_many" do
1878
1893
  attributes.collect{|a| a.pk}.must_equal [20, 30]
1879
1894
  end
1880
1895
 
1881
- it "should raise error and not call internal add or remove method if before callback returns false if raise_on_save_failure is true" do
1896
+ deprecated "should raise error and not call internal add or remove method if before callback returns false if raise_on_save_failure is true" do
1882
1897
  p = @c2.load(:id=>10)
1883
1898
  c = @c1.load(:id=>123)
1884
1899
  @c2.one_to_many :attributes, :class => @c1, :before_add=>:ba, :before_remove=>:br
@@ -1894,7 +1909,7 @@ describe Sequel::Model, "one_to_many" do
1894
1909
  p.attributes.must_equal [c]
1895
1910
  end
1896
1911
 
1897
- it "should return nil and not call internal add or remove method if before callback returns false if raise_on_save_failure is false" do
1912
+ deprecated "should return nil and not call internal add or remove method if before callback returns false if raise_on_save_failure is false" do
1898
1913
  p = @c2.load(:id=>10)
1899
1914
  c = @c1.load(:id=>123)
1900
1915
  p.raise_on_save_failure = false
@@ -2051,11 +2066,16 @@ describe Sequel::Model, "many_to_many" do
2051
2066
  @c2.new(:id => 1234).attributes_dataset.sql.must_equal 'SELECT attributes.* FROM attributes INNER JOIN attributes_nodes ON (attributes_nodes.attribute_id = attributes.id) WHERE (attributes_nodes.node_id = 1234)'
2052
2067
  end
2053
2068
 
2054
- it "should respect :eager_loader_predicate_key when lazily loading" do
2069
+ deprecated "should respect :eager_loading_predicate_key when lazily loading" do
2055
2070
  @c2.many_to_many :attributes, :class => @c1, :eager_loading_predicate_key=>Sequel.subscript(Sequel[:attributes_nodes][:node_id], 0)
2056
2071
  @c2.new(:id => 1234).attributes_dataset.sql.must_equal 'SELECT attributes.* FROM attributes INNER JOIN attributes_nodes ON (attributes_nodes.attribute_id = attributes.id) WHERE (attributes_nodes.node_id[0] = 1234)'
2057
2072
  end
2058
2073
 
2074
+ it "should respect :predicate_key when lazily loading" do
2075
+ @c2.many_to_many :attributes, :class => @c1, :predicate_key=>Sequel.subscript(Sequel[:attributes_nodes][:node_id], 0)
2076
+ @c2.new(:id => 1234).attributes_dataset.sql.must_equal 'SELECT attributes.* FROM attributes INNER JOIN attributes_nodes ON (attributes_nodes.attribute_id = attributes.id) WHERE (attributes_nodes.node_id[0] = 1234)'
2077
+ end
2078
+
2059
2079
  it "should use explicit key values and join table if given" do
2060
2080
  @c2.many_to_many :attributes, :class => @c1, :left_key => :nodeid, :right_key => :attributeid, :join_table => :attribute2node
2061
2081
  @c2.new(:id => 1234).attributes_dataset.sql.must_equal 'SELECT attributes.* FROM attributes INNER JOIN attribute2node ON (attribute2node.attributeid = attributes.id) WHERE (attribute2node.nodeid = 1234)'
@@ -2746,7 +2766,7 @@ describe Sequel::Model, "many_to_many" do
2746
2766
  attributes.collect{|a| a.pk}.must_equal [20, 30]
2747
2767
  end
2748
2768
 
2749
- it "should raise error and not call internal add or remove method if before callback returns false if raise_on_save_failure is true" do
2769
+ deprecated "should raise error and not call internal add or remove method if before callback returns false if raise_on_save_failure is true" do
2750
2770
  p = @c2.load(:id=>10)
2751
2771
  c = @c1.load(:id=>123)
2752
2772
  @c2.many_to_many :attributes, :class => @c1, :before_add=>:ba, :before_remove=>:br
@@ -2763,7 +2783,7 @@ describe Sequel::Model, "many_to_many" do
2763
2783
  p.attributes.must_equal [c]
2764
2784
  end
2765
2785
 
2766
- it "should return nil and not call internal add or remove method if before callback returns false if raise_on_save_failure is false" do
2786
+ deprecated "should return nil and not call internal add or remove method if before callback returns false if raise_on_save_failure is false" do
2767
2787
  p = @c2.load(:id=>10)
2768
2788
  c = @c1.load(:id=>123)
2769
2789
  p.raise_on_save_failure = false
@@ -2882,8 +2902,8 @@ describe Sequel::Model, "one_through_one" do
2882
2902
  @c2.new(:id => 1234).attribute_dataset.sql.must_equal 'SELECT attributes.* FROM attributes INNER JOIN attributes_nodes ON (attributes_nodes.attribute_id = attributes.id) WHERE (attributes_nodes.node_id = 1234) LIMIT 1'
2883
2903
  end
2884
2904
 
2885
- it "should respect :eager_loader_predicate_key when lazily loading" do
2886
- @c2.one_through_one :attribute, :class => @c1, :eager_loading_predicate_key=>Sequel.subscript(Sequel[:attributes_nodes][:node_id], 0)
2905
+ it "should respect :predicate_key when lazily loading" do
2906
+ @c2.one_through_one :attribute, :class => @c1, :predicate_key=>Sequel.subscript(Sequel[:attributes_nodes][:node_id], 0)
2887
2907
  @c2.new(:id => 1234).attribute_dataset.sql.must_equal 'SELECT attributes.* FROM attributes INNER JOIN attributes_nodes ON (attributes_nodes.attribute_id = attributes.id) WHERE (attributes_nodes.node_id[0] = 1234) LIMIT 1'
2888
2908
  end
2889
2909