sequel 4.33.0 → 4.34.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +22 -0
  3. data/doc/release_notes/4.34.0.txt +86 -0
  4. data/doc/testing.rdoc +1 -0
  5. data/doc/validations.rdoc +12 -1
  6. data/lib/sequel/adapters/ado.rb +1 -1
  7. data/lib/sequel/adapters/amalgalite.rb +1 -1
  8. data/lib/sequel/adapters/cubrid.rb +1 -1
  9. data/lib/sequel/adapters/do.rb +1 -1
  10. data/lib/sequel/adapters/ibmdb.rb +1 -1
  11. data/lib/sequel/adapters/jdbc.rb +1 -1
  12. data/lib/sequel/adapters/mock.rb +1 -1
  13. data/lib/sequel/adapters/mysql.rb +1 -1
  14. data/lib/sequel/adapters/mysql2.rb +1 -1
  15. data/lib/sequel/adapters/odbc.rb +1 -1
  16. data/lib/sequel/adapters/oracle.rb +1 -1
  17. data/lib/sequel/adapters/postgres.rb +1 -1
  18. data/lib/sequel/adapters/shared/mssql.rb +1 -1
  19. data/lib/sequel/adapters/sqlanywhere.rb +1 -1
  20. data/lib/sequel/adapters/sqlite.rb +1 -1
  21. data/lib/sequel/adapters/swift.rb +1 -1
  22. data/lib/sequel/adapters/tinytds.rb +2 -2
  23. data/lib/sequel/connection_pool.rb +2 -0
  24. data/lib/sequel/connection_pool/sharded_single.rb +1 -1
  25. data/lib/sequel/connection_pool/sharded_threaded.rb +17 -4
  26. data/lib/sequel/connection_pool/single.rb +1 -1
  27. data/lib/sequel/connection_pool/threaded.rb +17 -4
  28. data/lib/sequel/database/misc.rb +5 -1
  29. data/lib/sequel/dataset.rb +4 -0
  30. data/lib/sequel/dataset/actions.rb +28 -15
  31. data/lib/sequel/extensions/columns_introspection.rb +1 -1
  32. data/lib/sequel/extensions/duplicate_columns_handler.rb +87 -0
  33. data/lib/sequel/extensions/migration.rb +9 -7
  34. data/lib/sequel/extensions/pg_range.rb +73 -14
  35. data/lib/sequel/model/base.rb +2 -2
  36. data/lib/sequel/plugins/dataset_associations.rb +21 -1
  37. data/lib/sequel/plugins/prepared_statements_safe.rb +2 -1
  38. data/lib/sequel/plugins/update_or_create.rb +1 -1
  39. data/lib/sequel/plugins/validation_helpers.rb +7 -0
  40. data/lib/sequel/version.rb +1 -1
  41. data/spec/adapters/postgres_spec.rb +14 -0
  42. data/spec/adapters/spec_helper.rb +6 -0
  43. data/spec/core/connection_pool_spec.rb +30 -3
  44. data/spec/core/database_spec.rb +2 -0
  45. data/spec/core/dataset_spec.rb +8 -0
  46. data/spec/extensions/dataset_associations_spec.rb +32 -0
  47. data/spec/extensions/duplicate_columns_handler_spec.rb +110 -0
  48. data/spec/extensions/pg_range_spec.rb +40 -0
  49. data/spec/extensions/prepared_statements_safe_spec.rb +1 -1
  50. data/spec/extensions/validation_helpers_spec.rb +11 -0
  51. data/spec/integration/associations_test.rb +22 -8
  52. data/spec/integration/dataset_test.rb +10 -0
  53. data/spec/integration/eager_loader_test.rb +1 -1
  54. data/spec/integration/plugin_test.rb +3 -3
  55. data/spec/integration/spec_helper.rb +4 -0
  56. metadata +6 -2
@@ -171,6 +171,10 @@ describe "Simple Dataset operations" do
171
171
  @ds.all.must_equal [{:id=>1, :number=>10}]
172
172
  end
173
173
 
174
+ it "should raise exception if raising on duplication columns" do
175
+ proc{@ds.select_map([:id, :id])}.must_raise Sequel::DuplicateColumnError
176
+ end if DB.opts[:on_duplicate_columns] == :raise
177
+
174
178
  it "should fetch a single row correctly" do
175
179
  @ds.first.must_equal(:id=>1, :number=>10)
176
180
  @ds.single_record.must_equal(:id=>1, :number=>10)
@@ -1169,6 +1173,8 @@ describe "Sequel::Dataset convenience methods" do
1169
1173
  @ds.to_hash([:a, :c], :b).must_equal([1, 3]=>2, [5, 7]=>6)
1170
1174
  @ds.to_hash(:a, [:b, :c]).must_equal(1=>[2, 3], 5=>[6, 7])
1171
1175
  @ds.to_hash([:a, :c], [:b, :d]).must_equal([1, 3]=>[2, 4], [5, 7]=>[6, 8])
1176
+
1177
+ @ds.to_hash(:a, :b, :hash => (tmp = {})).must_be_same_as(tmp)
1172
1178
  end
1173
1179
 
1174
1180
  it "should have working #to_hash_groups" do
@@ -1182,6 +1188,8 @@ describe "Sequel::Dataset convenience methods" do
1182
1188
  ds.to_hash_groups([:a, :c], :d).must_equal([1, 3]=>[4, 9], [5, 7]=>[8])
1183
1189
  ds.to_hash_groups(:a, [:b, :d]).must_equal(1=>[[2, 4], [2, 9]], 5=>[[6, 8]])
1184
1190
  ds.to_hash_groups([:a, :c], [:b, :d]).must_equal([1, 3]=>[[2, 4], [2, 9]], [5, 7]=>[[6, 8]])
1191
+
1192
+ ds.to_hash_groups(:a, :d, :hash => (tmp = {})).must_be_same_as(tmp)
1185
1193
  end
1186
1194
 
1187
1195
  it "should have working #select_map" do
@@ -1225,6 +1233,7 @@ describe "Sequel::Dataset convenience methods" do
1225
1233
  @ds.select_hash([:a, :c], :b).must_equal([1, 3]=>2, [5, 7]=>6)
1226
1234
  @ds.select_hash(:a, [:b, :c]).must_equal(1=>[2, 3], 5=>[6, 7])
1227
1235
  @ds.select_hash([:a, :c], [:b, :d]).must_equal([1, 3]=>[2, 4], [5, 7]=>[6, 8])
1236
+ @ds.select_hash(:a, :b, :hash => (tmp = {})).must_be_same_as(tmp)
1228
1237
  end
1229
1238
 
1230
1239
  it "should have working #select_hash_groups" do
@@ -1238,6 +1247,7 @@ describe "Sequel::Dataset convenience methods" do
1238
1247
  ds.select_hash_groups([:a, :c], :d).must_equal([1, 3]=>[4, 9], [5, 7]=>[8])
1239
1248
  ds.select_hash_groups(:a, [:b, :d]).must_equal(1=>[[2, 4], [2, 9]], 5=>[[6, 8]])
1240
1249
  ds.select_hash_groups([:a, :c], [:b, :d]).must_equal([1, 3]=>[[2, 4], [2, 9]], [5, 7]=>[[6, 8]])
1250
+ ds.select_hash_groups(:a, :d, :hash => (tmp = {})).must_be_same_as(tmp)
1241
1251
  end
1242
1252
  end
1243
1253
 
@@ -511,7 +511,7 @@ describe "many_to_one/one_to_many not referencing primary key" do
511
511
 
512
512
  it "should load all associated one_to_many objects for a single object" do
513
513
  invs = @client1.invoices
514
- invs.must_equal [@invoice1, @invoice2]
514
+ invs.sort_by{|x| x.pk}.must_equal [@invoice1, @invoice2]
515
515
  invs[0].client.must_equal @client1
516
516
  invs[1].client.must_equal @client1
517
517
  end
@@ -158,15 +158,15 @@ describe "Class Table Inheritance Plugin" do
158
158
  end
159
159
 
160
160
  it "should handle one_to_many relationships" do
161
- Executive.first.staff_members.must_equal [Staff[@i2]]
161
+ Executive.first(:name=>'Ex').staff_members.must_equal [Staff[@i2]]
162
162
  end
163
163
 
164
164
  it "should handle eagerly loading one_to_many relationships" do
165
- Executive.limit(1).eager(:staff_members).first.staff_members.must_equal [Staff[@i2]]
165
+ Executive.where(:name=>'Ex').eager(:staff_members).first.staff_members.must_equal [Staff[@i2]]
166
166
  end
167
167
 
168
168
  it "should handle eagerly graphing one_to_many relationships" do
169
- es = Executive.limit(1).eager_graph(:staff_members).all
169
+ es = Executive.where(:name=>'Ex').eager_graph(:staff_members).all
170
170
  es.must_equal [Executive[@i4]]
171
171
  es.map{|x| x.staff_members}.must_equal [[Staff[@i2]]]
172
172
  end
@@ -50,3 +50,7 @@ if ENV['SEQUEL_CONNECTION_VALIDATOR']
50
50
  DB.pool.connection_validation_timeout = -1
51
51
  end
52
52
 
53
+ if dch = ENV['SEQUEL_DUPLICATE_COLUMNS_HANDLER']
54
+ DB.extension :duplicate_columns_handler
55
+ DB.opts[:on_duplicate_columns] = dch.to_sym unless dch.empty?
56
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.33.0
4
+ version: 4.34.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-01 00:00:00.000000000 Z
11
+ date: 2016-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -234,6 +234,7 @@ extra_rdoc_files:
234
234
  - doc/release_notes/4.31.0.txt
235
235
  - doc/release_notes/4.32.0.txt
236
236
  - doc/release_notes/4.33.0.txt
237
+ - doc/release_notes/4.34.0.txt
237
238
  files:
238
239
  - CHANGELOG
239
240
  - MIT-LICENSE
@@ -356,6 +357,7 @@ files:
356
357
  - doc/release_notes/4.31.0.txt
357
358
  - doc/release_notes/4.32.0.txt
358
359
  - doc/release_notes/4.33.0.txt
360
+ - doc/release_notes/4.34.0.txt
359
361
  - doc/release_notes/4.4.0.txt
360
362
  - doc/release_notes/4.5.0.txt
361
363
  - doc/release_notes/4.6.0.txt
@@ -478,6 +480,7 @@ files:
478
480
  - lib/sequel/extensions/current_datetime_timestamp.rb
479
481
  - lib/sequel/extensions/dataset_source_alias.rb
480
482
  - lib/sequel/extensions/date_arithmetic.rb
483
+ - lib/sequel/extensions/duplicate_columns_handler.rb
481
484
  - lib/sequel/extensions/empty_array_consider_nulls.rb
482
485
  - lib/sequel/extensions/empty_array_ignore_nulls.rb
483
486
  - lib/sequel/extensions/error_sql.rb
@@ -673,6 +676,7 @@ files:
673
676
  - spec/extensions/defaults_setter_spec.rb
674
677
  - spec/extensions/delay_add_association_spec.rb
675
678
  - spec/extensions/dirty_spec.rb
679
+ - spec/extensions/duplicate_columns_handler_spec.rb
676
680
  - spec/extensions/eager_each_spec.rb
677
681
  - spec/extensions/empty_array_consider_nulls_spec.rb
678
682
  - spec/extensions/error_splitter_spec.rb