sequel 3.39.0 → 3.40.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/CHANGELOG +30 -0
  2. data/README.rdoc +4 -3
  3. data/doc/active_record.rdoc +1 -1
  4. data/doc/opening_databases.rdoc +7 -0
  5. data/doc/release_notes/3.40.0.txt +73 -0
  6. data/lib/sequel/adapters/ado.rb +29 -3
  7. data/lib/sequel/adapters/ado/access.rb +334 -0
  8. data/lib/sequel/adapters/ado/mssql.rb +0 -6
  9. data/lib/sequel/adapters/cubrid.rb +143 -0
  10. data/lib/sequel/adapters/jdbc.rb +26 -18
  11. data/lib/sequel/adapters/jdbc/cubrid.rb +52 -0
  12. data/lib/sequel/adapters/jdbc/derby.rb +7 -7
  13. data/lib/sequel/adapters/jdbc/hsqldb.rb +5 -0
  14. data/lib/sequel/adapters/jdbc/mysql.rb +9 -4
  15. data/lib/sequel/adapters/mysql.rb +0 -3
  16. data/lib/sequel/adapters/mysql2.rb +0 -3
  17. data/lib/sequel/adapters/oracle.rb +4 -1
  18. data/lib/sequel/adapters/postgres.rb +4 -4
  19. data/lib/sequel/adapters/shared/access.rb +205 -3
  20. data/lib/sequel/adapters/shared/cubrid.rb +216 -0
  21. data/lib/sequel/adapters/shared/db2.rb +7 -2
  22. data/lib/sequel/adapters/shared/mssql.rb +3 -34
  23. data/lib/sequel/adapters/shared/mysql.rb +4 -33
  24. data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +11 -0
  25. data/lib/sequel/adapters/shared/oracle.rb +5 -0
  26. data/lib/sequel/adapters/shared/postgres.rb +2 -1
  27. data/lib/sequel/adapters/utils/split_alter_table.rb +36 -0
  28. data/lib/sequel/database/connecting.rb +1 -1
  29. data/lib/sequel/database/query.rb +30 -7
  30. data/lib/sequel/database/schema_methods.rb +7 -2
  31. data/lib/sequel/dataset/query.rb +9 -10
  32. data/lib/sequel/dataset/sql.rb +14 -26
  33. data/lib/sequel/extensions/pg_hstore.rb +19 -0
  34. data/lib/sequel/extensions/pg_row.rb +5 -5
  35. data/lib/sequel/plugins/association_pks.rb +121 -18
  36. data/lib/sequel/plugins/json_serializer.rb +19 -0
  37. data/lib/sequel/sql.rb +11 -0
  38. data/lib/sequel/version.rb +1 -1
  39. data/spec/adapters/postgres_spec.rb +42 -0
  40. data/spec/core/database_spec.rb +17 -0
  41. data/spec/core/dataset_spec.rb +11 -0
  42. data/spec/core/expression_filters_spec.rb +13 -0
  43. data/spec/extensions/association_pks_spec.rb +163 -3
  44. data/spec/extensions/pg_hstore_spec.rb +6 -0
  45. data/spec/extensions/pg_row_spec.rb +17 -0
  46. data/spec/integration/associations_test.rb +1 -1
  47. data/spec/integration/dataset_test.rb +13 -13
  48. data/spec/integration/plugin_test.rb +232 -7
  49. data/spec/integration/schema_test.rb +8 -12
  50. data/spec/integration/spec_helper.rb +1 -1
  51. data/spec/integration/type_test.rb +6 -0
  52. metadata +9 -2
@@ -608,7 +608,7 @@ describe "Sequel::Model Simple Associations" do
608
608
  @els = {:eager_limit_strategy=>:correlated_subquery}
609
609
  end
610
610
  it_should_behave_like "eager limit strategies"
611
- end unless Sequel.guarded?(:mysql, :db2, :oracle, :h2)
611
+ end unless Sequel.guarded?(:mysql, :db2, :oracle, :h2, :cubrid)
612
612
 
613
613
  specify "should handle many_to_one associations with same name as :key" do
614
614
  Album.def_column_alias(:artist_id_id, :artist_id)
@@ -867,23 +867,23 @@ describe "Sequel::Dataset convenience methods" do
867
867
  end
868
868
 
869
869
  it "#group_and_count should return a grouping by count" do
870
- @ds.group_and_count(:a).order(:count).all.should == []
870
+ @ds.group_and_count(:a).order{count(:a)}.all.should == []
871
871
  @ds.insert(20, 10)
872
- @ds.group_and_count(:a).order(:count).all.each{|h| h[:count] = h[:count].to_i}.should == [{:a=>20, :count=>1}]
872
+ @ds.group_and_count(:a).order{count(:a)}.all.each{|h| h[:count] = h[:count].to_i}.should == [{:a=>20, :count=>1}]
873
873
  @ds.insert(20, 30)
874
- @ds.group_and_count(:a).order(:count).all.each{|h| h[:count] = h[:count].to_i}.should == [{:a=>20, :count=>2}]
874
+ @ds.group_and_count(:a).order{count(:a)}.all.each{|h| h[:count] = h[:count].to_i}.should == [{:a=>20, :count=>2}]
875
875
  @ds.insert(30, 30)
876
- @ds.group_and_count(:a).order(:count).all.each{|h| h[:count] = h[:count].to_i}.should == [{:a=>30, :count=>1}, {:a=>20, :count=>2}]
876
+ @ds.group_and_count(:a).order{count(:a)}.all.each{|h| h[:count] = h[:count].to_i}.should == [{:a=>30, :count=>1}, {:a=>20, :count=>2}]
877
877
  end
878
878
 
879
879
  it "#group_and_count should support column aliases" do
880
- @ds.group_and_count(:a___c).order(:count).all.should == []
880
+ @ds.group_and_count(:a___c).order{count(:a)}.all.should == []
881
881
  @ds.insert(20, 10)
882
- @ds.group_and_count(:a___c).order(:count).all.each{|h| h[:count] = h[:count].to_i}.should == [{:c=>20, :count=>1}]
882
+ @ds.group_and_count(:a___c).order{count(:a)}.all.each{|h| h[:count] = h[:count].to_i}.should == [{:c=>20, :count=>1}]
883
883
  @ds.insert(20, 30)
884
- @ds.group_and_count(:a___c).order(:count).all.each{|h| h[:count] = h[:count].to_i}.should == [{:c=>20, :count=>2}]
884
+ @ds.group_and_count(:a___c).order{count(:a)}.all.each{|h| h[:count] = h[:count].to_i}.should == [{:c=>20, :count=>2}]
885
885
  @ds.insert(30, 30)
886
- @ds.group_and_count(:a___c).order(:count).all.each{|h| h[:count] = h[:count].to_i}.should == [{:c=>30, :count=>1}, {:c=>20, :count=>2}]
886
+ @ds.group_and_count(:a___c).order{count(:a)}.all.each{|h| h[:count] = h[:count].to_i}.should == [{:c=>30, :count=>1}, {:c=>20, :count=>2}]
887
887
  end
888
888
 
889
889
  specify "#range should return the range between the maximum and minimum values" do
@@ -906,21 +906,21 @@ end
906
906
  describe "Sequel::Dataset main SQL methods" do
907
907
  before(:all) do
908
908
  @db = INTEGRATION_DB
909
- @db.create_table!(:a){Integer :a; Integer :b}
910
- @ds = @db[:a].order(:a)
909
+ @db.create_table!(:d){Integer :a; Integer :b}
910
+ @ds = @db[:d].order(:a)
911
911
  end
912
912
  before do
913
913
  @ds.delete
914
914
  end
915
915
  after(:all) do
916
- @db.drop_table?(:a)
916
+ @db.drop_table?(:d)
917
917
  end
918
918
 
919
919
  it "#exists should return a usable exists clause" do
920
- @ds.filter(@db[:a___c].filter(:c__a=>:a__b).exists).all.should == []
920
+ @ds.filter(@db[:d___c].filter(:c__a=>:d__b).exists).all.should == []
921
921
  @ds.insert(20, 30)
922
922
  @ds.insert(10, 20)
923
- @ds.filter(@db[:a___c].filter(:c__a=>:a__b).exists).all.should == [{:a=>10, :b=>20}]
923
+ @ds.filter(@db[:d___c].filter(:c__a=>:d__b).exists).all.should == [{:a=>10, :b=>20}]
924
924
  end
925
925
 
926
926
  it "#filter and #exclude should work with placeholder strings" do
@@ -1,9 +1,8 @@
1
1
  require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper.rb')
2
2
 
3
- # H2 and MSSQL don't support USING joins
4
3
  # DB2 does not seem to support USING joins in every version; it seems to be
5
4
  # valid expression in DB2 iSeries UDB though.
6
- unless Sequel.guarded?(:h2, :mssql, :db2)
5
+ unless !INTEGRATION_DB.dataset.supports_join_using? || Sequel.guarded?(:db2)
7
6
  describe "Class Table Inheritance Plugin" do
8
7
  before(:all) do
9
8
  @db = INTEGRATION_DB
@@ -1069,7 +1068,7 @@ end
1069
1068
  describe "AssociationPks plugin" do
1070
1069
  before(:all) do
1071
1070
  @db = INTEGRATION_DB
1072
- @db.drop_table?(:albums_tags, :tags, :albums, :artists)
1071
+ @db.drop_table?(:albums_tags, :albums_vocalists, :vocalists_instruments, :vocalists_hits, :hits, :instruments, :vocalists, :tags, :albums, :artists)
1073
1072
  @db.create_table(:artists) do
1074
1073
  primary_key :id
1075
1074
  String :name
@@ -1087,6 +1086,46 @@ describe "AssociationPks plugin" do
1087
1086
  foreign_key :album_id, :albums
1088
1087
  foreign_key :tag_id, :tags
1089
1088
  end
1089
+ @db.create_table(:vocalists) do
1090
+ String :first
1091
+ String :last
1092
+ primary_key [:first, :last]
1093
+ foreign_key :album_id, :albums
1094
+ end
1095
+ @db.create_table(:albums_vocalists) do
1096
+ foreign_key :album_id, :albums
1097
+ String :first
1098
+ String :last
1099
+ foreign_key [:first, :last], :vocalists
1100
+ end
1101
+ @db.create_table(:instruments) do
1102
+ primary_key :id
1103
+ String :first
1104
+ String :last
1105
+ foreign_key [:first, :last], :vocalists
1106
+ end
1107
+ @db.create_table(:vocalists_instruments) do
1108
+ String :first
1109
+ String :last
1110
+ foreign_key [:first, :last], :vocalists
1111
+ foreign_key :instrument_id, :instruments
1112
+ end
1113
+ @db.create_table(:hits) do
1114
+ Integer :year
1115
+ Integer :week
1116
+ primary_key [:year, :week]
1117
+ String :first
1118
+ String :last
1119
+ foreign_key [:first, :last], :vocalists
1120
+ end
1121
+ @db.create_table(:vocalists_hits) do
1122
+ String :first
1123
+ String :last
1124
+ foreign_key [:first, :last], :vocalists
1125
+ Integer :year
1126
+ Integer :week
1127
+ foreign_key [:year, :week], :hits
1128
+ end
1090
1129
  class ::Artist < Sequel::Model
1091
1130
  plugin :association_pks
1092
1131
  one_to_many :albums, :order=>:id
@@ -1097,9 +1136,19 @@ describe "AssociationPks plugin" do
1097
1136
  end
1098
1137
  class ::Tag < Sequel::Model
1099
1138
  end
1139
+ class ::Vocalist < Sequel::Model
1140
+ set_primary_key [:first, :last]
1141
+ plugin :association_pks
1142
+ end
1143
+ class ::Instrument < Sequel::Model
1144
+ plugin :association_pks
1145
+ end
1146
+ class ::Hit < Sequel::Model
1147
+ set_primary_key [:year, :week]
1148
+ end
1100
1149
  end
1101
1150
  before do
1102
- [:albums_tags, :tags, :albums, :artists].each{|t| @db[t].delete}
1151
+ [:albums_tags, :albums_vocalists, :vocalists_instruments, :vocalists_hits, :hits, :instruments, :vocalists, :tags, :albums, :artists].each{|t| @db[t].delete}
1103
1152
  @ar1 =@db[:artists].insert(:name=>'YJM')
1104
1153
  @ar2 =@db[:artists].insert(:name=>'AS')
1105
1154
  @al1 =@db[:albums].insert(:name=>'RF', :artist_id=>@ar1)
@@ -1111,10 +1160,34 @@ describe "AssociationPks plugin" do
1111
1160
  {@al1=>[@t1, @t2, @t3], @al2=>[@t2]}.each do |aid, tids|
1112
1161
  tids.each{|tid| @db[:albums_tags].insert([aid, tid])}
1113
1162
  end
1163
+ @v1 = ['F1', 'L1']
1164
+ @v2 = ['F2', 'L2']
1165
+ @v3 = ['F3', 'L3']
1166
+ @db[:vocalists].insert(@v1 + [@al1])
1167
+ @db[:vocalists].insert(@v2 + [@al1])
1168
+ @db[:vocalists].insert(@v3 + [@al1])
1169
+ @i1 = @db[:instruments].insert([:first, :last], @v1)
1170
+ @i2 = @db[:instruments].insert([:first, :last], @v1)
1171
+ @i3 = @db[:instruments].insert([:first, :last], @v1)
1172
+ @h1 = [1997, 1]
1173
+ @h2 = [1997, 2]
1174
+ @h3 = [1997, 3]
1175
+ @db[:hits].insert(@h1 + @v1)
1176
+ @db[:hits].insert(@h2 + @v1)
1177
+ @db[:hits].insert(@h3 + @v1)
1178
+ {@al1=>[@v1, @v2, @v3], @al2=>[@v2]}.each do |aid, vids|
1179
+ vids.each{|vid| @db[:albums_vocalists].insert([aid] + vid)}
1180
+ end
1181
+ {@v1=>[@i1, @i2, @i3], @v2=>[@i2]}.each do |vid, iids|
1182
+ iids.each{|iid| @db[:vocalists_instruments].insert(vid + [iid])}
1183
+ end
1184
+ {@v1=>[@h1, @h2, @h3], @v2=>[@h2]}.each do |vid, hids|
1185
+ hids.each{|hid| @db[:vocalists_hits].insert(vid + hid)}
1186
+ end
1114
1187
  end
1115
1188
  after(:all) do
1116
- @db.drop_table? :albums_tags, :tags, :albums, :artists
1117
- [:Artist, :Album, :Tag].each{|s| Object.send(:remove_const, s)}
1189
+ @db.drop_table? :albums_tags, :albums_vocalists, :vocalists_instruments, :vocalists_hits, :hits, :instruments, :vocalists, :tags, :albums, :artists
1190
+ [:Artist, :Album, :Tag, :Vocalist, :Instrument, :Hit].each{|s| Object.send(:remove_const, s)}
1118
1191
  end
1119
1192
 
1120
1193
  specify "should return correct associated pks for one_to_many associations" do
@@ -1125,6 +1198,36 @@ describe "AssociationPks plugin" do
1125
1198
  Album.order(:id).all.map{|a| a.tag_pks.sort}.should == [[@t1, @t2, @t3], [@t2], []]
1126
1199
  end
1127
1200
 
1201
+ specify "should return correct associated right-side cpks for one_to_many associations" do
1202
+ Album.one_to_many :vocalists, :order=>:first
1203
+ Album.order(:id).all.map{|a| a.vocalist_pks.sort}.should == [[@v1, @v2, @v3], [], []]
1204
+ end
1205
+
1206
+ specify "should return correct associated right-side cpks for many_to_many associations" do
1207
+ Album.many_to_many :vocalists, :join_table=>:albums_vocalists, :right_key=>[:first, :last], :order=>:first
1208
+ Album.order(:id).all.map{|a| a.vocalist_pks.sort}.should == [[@v1, @v2, @v3], [@v2], []]
1209
+ end
1210
+
1211
+ specify "should return correct associated pks for left-side cpks for one_to_many associations" do
1212
+ Vocalist.one_to_many :instruments, :key=>[:first, :last], :order=>:id
1213
+ Vocalist.order(:first, :last).all.map{|a| a.instrument_pks.sort}.should == [[@i1, @i2, @i3], [], []]
1214
+ end
1215
+
1216
+ specify "should return correct associated pks for left-side cpks for many_to_many associations" do
1217
+ Vocalist.many_to_many :instruments, :join_table=>:vocalists_instruments, :left_key=>[:first, :last], :order=>:id
1218
+ Vocalist.order(:first, :last).all.map{|a| a.instrument_pks.sort}.should == [[@i1, @i2, @i3], [@i2], []]
1219
+ end
1220
+
1221
+ specify "should return correct associated right-side cpks for left-side cpks for one_to_many associations" do
1222
+ Vocalist.one_to_many :hits, :key=>[:first, :last], :order=>:week
1223
+ Vocalist.order(:first, :last).all.map{|a| a.hit_pks.sort}.should == [[@h1, @h2, @h3], [], []]
1224
+ end
1225
+
1226
+ specify "should return correct associated right-side cpks for left-side cpks for many_to_many associations" do
1227
+ Vocalist.many_to_many :hits, :join_table=>:vocalists_hits, :left_key=>[:first, :last], :right_key=>[:year, :week], :order=>:week
1228
+ Vocalist.order(:first, :last).all.map{|a| a.hit_pks.sort}.should == [[@h1, @h2, @h3], [@h2], []]
1229
+ end
1230
+
1128
1231
  specify "should set associated pks correctly for a one_to_many association" do
1129
1232
  Artist.use_transactions = true
1130
1233
  Album.order(:id).select_map(:artist_id).should == [@ar1, @ar1, @ar1]
@@ -1162,8 +1265,130 @@ describe "AssociationPks plugin" do
1162
1265
  Album[@al3].tag_pks = []
1163
1266
  @db[:albums_tags].filter(:album_id=>@al1).select_order_map(:tag_id).should == []
1164
1267
  end
1165
- end
1166
1268
 
1269
+ specify "should set associated right-side cpks correctly for a one_to_many association" do
1270
+ Album.use_transactions = true
1271
+ Album.one_to_many :vocalists, :order=>:first
1272
+ Album.order(:id).all.map{|a| a.vocalist_pks.sort}.should == [[@v1, @v2, @v3], [], []]
1273
+
1274
+ Album[@al2].vocalist_pks = [@v1, @v3]
1275
+ Album[@al1].vocalist_pks.should == [@v2]
1276
+ Vocalist.order(:first, :last).select_map(:album_id).should == [@al2, @al1, @al2]
1277
+
1278
+ Album[@al1].vocalist_pks = [@v1]
1279
+ Album[@al2].vocalist_pks.should == [@v3]
1280
+ Vocalist.order(:first, :last).select_map(:album_id).should == [@al1, nil, @al2]
1281
+
1282
+ Album[@al1].vocalist_pks = [@v1, @v2]
1283
+ Album[@al2].vocalist_pks.should == [@v3]
1284
+ Vocalist.order(:first, :last).select_map(:album_id).should == [@al1, @al1, @al2]
1285
+ end
1286
+
1287
+ specify "should set associated right-side cpks correctly for a many_to_many association" do
1288
+ Album.use_transactions = true
1289
+ Album.many_to_many :vocalists, :join_table=>:albums_vocalists, :right_key=>[:first, :last], :order=>:first
1290
+
1291
+ @db[:albums_vocalists].filter(:album_id=>@al1).select_order_map([:first, :last]).should == [@v1, @v2, @v3]
1292
+ Album[@al1].vocalist_pks = [@v1, @v3]
1293
+ @db[:albums_vocalists].filter(:album_id=>@al1).select_order_map([:first, :last]).should == [@v1, @v3]
1294
+ Album[@al1].vocalist_pks = []
1295
+ @db[:albums_vocalists].filter(:album_id=>@al1).select_order_map([:first, :last]).should == []
1296
+
1297
+ @db[:albums_vocalists].filter(:album_id=>@al2).select_order_map([:first, :last]).should == [@v2]
1298
+ Album[@al2].vocalist_pks = [@v1, @v2]
1299
+ @db[:albums_vocalists].filter(:album_id=>@al2).select_order_map([:first, :last]).should == [@v1, @v2]
1300
+ Album[@al2].vocalist_pks = []
1301
+ @db[:albums_vocalists].filter(:album_id=>@al1).select_order_map([:first, :last]).should == []
1302
+
1303
+ @db[:albums_vocalists].filter(:album_id=>@al3).select_order_map([:first, :last]).should == []
1304
+ Album[@al3].vocalist_pks = [@v1, @v3]
1305
+ @db[:albums_vocalists].filter(:album_id=>@al3).select_order_map([:first, :last]).should == [@v1, @v3]
1306
+ Album[@al3].vocalist_pks = []
1307
+ @db[:albums_vocalists].filter(:album_id=>@al1).select_order_map([:first, :last]).should == []
1308
+ end
1309
+
1310
+ specify "should set associated pks correctly with left-side cpks for a one_to_many association" do
1311
+ Vocalist.use_transactions = true
1312
+ Vocalist.one_to_many :instruments, :key=>[:first, :last], :order=>:id
1313
+ Vocalist.order(:first, :last).all.map{|a| a.instrument_pks.sort}.should == [[@i1, @i2, @i3], [], []]
1314
+
1315
+ Vocalist[@v2].instrument_pks = [@i1, @i3]
1316
+ Vocalist[@v1].instrument_pks.should == [@i2]
1317
+ Instrument.order(:id).select_map([:first, :last]).should == [@v2, @v1, @v2]
1318
+
1319
+ Vocalist[@v1].instrument_pks = [@i1]
1320
+ Vocalist[@v2].instrument_pks.should == [@i3]
1321
+ Instrument.order(:id).select_map([:first, :last]).should == [@v1, [nil, nil], @v2]
1322
+
1323
+ Vocalist[@v1].instrument_pks = [@i1, @i2]
1324
+ Vocalist[@v2].instrument_pks.should == [@i3]
1325
+ Instrument.order(:id).select_map([:first, :last]).should == [@v1, @v1, @v2]
1326
+ end
1327
+
1328
+ specify "should set associated pks correctly with left-side cpks for a many_to_many association" do
1329
+ Vocalist.use_transactions = true
1330
+ Vocalist.many_to_many :instruments, :join_table=>:vocalists_instruments, :left_key=>[:first, :last], :order=>:id
1331
+
1332
+ @db[:vocalists_instruments].filter([:first, :last]=>[@v1]).select_order_map(:instrument_id).should == [@i1, @i2, @i3]
1333
+ Vocalist[@v1].instrument_pks = [@i1, @i3]
1334
+ @db[:vocalists_instruments].filter([:first, :last]=>[@v1]).select_order_map(:instrument_id).should == [@i1, @i3]
1335
+ Vocalist[@v1].instrument_pks = []
1336
+ @db[:vocalists_instruments].filter([:first, :last]=>[@v1]).select_order_map(:instrument_id).should == []
1337
+
1338
+ @db[:vocalists_instruments].filter([:first, :last]=>[@v2]).select_order_map(:instrument_id).should == [@i2]
1339
+ Vocalist[@v2].instrument_pks = [@i1, @i2]
1340
+ @db[:vocalists_instruments].filter([:first, :last]=>[@v2]).select_order_map(:instrument_id).should == [@i1, @i2]
1341
+ Vocalist[@v2].instrument_pks = []
1342
+ @db[:vocalists_instruments].filter([:first, :last]=>[@v1]).select_order_map(:instrument_id).should == []
1343
+
1344
+ @db[:vocalists_instruments].filter([:first, :last]=>[@v3]).select_order_map(:instrument_id).should == []
1345
+ Vocalist[@v3].instrument_pks = [@i1, @i3]
1346
+ @db[:vocalists_instruments].filter([:first, :last]=>[@v3]).select_order_map(:instrument_id).should == [@i1, @i3]
1347
+ Vocalist[@v3].instrument_pks = []
1348
+ @db[:vocalists_instruments].filter([:first, :last]=>[@v1]).select_order_map(:instrument_id).should == []
1349
+ end
1350
+
1351
+ specify "should set associated right-side cpks correctly with left-side cpks for a one_to_many association" do
1352
+ Vocalist.use_transactions = true
1353
+ Vocalist.one_to_many :hits, :key=>[:first, :last], :order=>:week
1354
+ Vocalist.order(:first, :last).all.map{|a| a.hit_pks.sort}.should == [[@h1, @h2, @h3], [], []]
1355
+
1356
+ Vocalist[@v2].hit_pks = [@h1, @h3]
1357
+ Vocalist[@v1].hit_pks.should == [@h2]
1358
+ Hit.order(:year, :week).select_map([:first, :last]).should == [@v2, @v1, @v2]
1359
+
1360
+ Vocalist[@v1].hit_pks = [@h1]
1361
+ Vocalist[@v2].hit_pks.should == [@h3]
1362
+ Hit.order(:year, :week).select_map([:first, :last]).should == [@v1, [nil, nil], @v2]
1363
+
1364
+ Vocalist[@v1].hit_pks = [@h1, @h2]
1365
+ Vocalist[@v2].hit_pks.should == [@h3]
1366
+ Hit.order(:year, :week).select_map([:first, :last]).should == [@v1, @v1, @v2]
1367
+ end
1368
+
1369
+ specify "should set associated right-side cpks correctly with left-side cpks for a many_to_many association" do
1370
+ Vocalist.use_transactions = true
1371
+ Vocalist.many_to_many :hits, :join_table=>:vocalists_hits, :left_key=>[:first, :last], :right_key=>[:year, :week], :order=>:week
1372
+
1373
+ @db[:vocalists_hits].filter([:first, :last]=>[@v1]).select_order_map([:year, :week]).should == [@h1, @h2, @h3]
1374
+ Vocalist[@v1].hit_pks = [@h1, @h3]
1375
+ @db[:vocalists_hits].filter([:first, :last]=>[@v1]).select_order_map([:year, :week]).should == [@h1, @h3]
1376
+ Vocalist[@v1].hit_pks = []
1377
+ @db[:vocalists_hits].filter([:first, :last]=>[@v1]).select_order_map([:year, :week]).should == []
1378
+
1379
+ @db[:vocalists_hits].filter([:first, :last]=>[@v2]).select_order_map([:year, :week]).should == [@h2]
1380
+ Vocalist[@v2].hit_pks = [@h1, @h2]
1381
+ @db[:vocalists_hits].filter([:first, :last]=>[@v2]).select_order_map([:year, :week]).should == [@h1, @h2]
1382
+ Vocalist[@v2].hit_pks = []
1383
+ @db[:vocalists_hits].filter([:first, :last]=>[@v1]).select_order_map([:year, :week]).should == []
1384
+
1385
+ @db[:vocalists_hits].filter([:first, :last]=>[@v3]).select_order_map([:year, :week]).should == []
1386
+ Vocalist[@v3].hit_pks = [@h1, @h3]
1387
+ @db[:vocalists_hits].filter([:first, :last]=>[@v3]).select_order_map([:year, :week]).should == [@h1, @h3]
1388
+ Vocalist[@v3].hit_pks = []
1389
+ @db[:vocalists_hits].filter([:first, :last]=>[@v1]).select_order_map([:year, :week]).should == []
1390
+ end
1391
+ end
1167
1392
 
1168
1393
  describe "List plugin without a scope" do
1169
1394
  before(:all) do
@@ -420,18 +420,14 @@ describe "Database schema modifiers" do
420
420
  end
421
421
 
422
422
  specify "should rename columns when the table is referenced by a foreign key" do
423
- begin
424
- @db.create_table!(:itemsfk){primary_key :id; Integer :a}
425
- @db.create_table!(:items){foreign_key :id, :itemsfk}
426
- @db[:itemsfk].insert(:a=>10)
427
- @ds.insert(:id=>1)
428
- @db.alter_table(:itemsfk){rename_column :a, :b}
429
- @db[:itemsfk].insert(:b=>20)
430
- @ds.insert(:id=>2)
431
- @db[:itemsfk].select_order_map([:id, :b]).should == [[1, 10], [2, 20]]
432
- ensure
433
- @db.drop_table(:items, :itemsfk)
434
- end
423
+ @db.create_table!(:items2){primary_key :id; Integer :a}
424
+ @db.create_table!(:items){Integer :id, :primary_key=>true; foreign_key :items_id, :items2}
425
+ @db[:items2].insert(:a=>10)
426
+ @ds.insert(:id=>1)
427
+ @db.alter_table(:items2){rename_column :a, :b}
428
+ @db[:items2].insert(:b=>20)
429
+ @ds.insert(:id=>2)
430
+ @db[:items2].select_order_map([:id, :b]).should == [[1, 10], [2, 20]]
435
431
  end
436
432
 
437
433
  cspecify "should set column NULL/NOT NULL correctly", [:jdbc, :db2], [:db2] do
@@ -86,7 +86,7 @@ else
86
86
  INTEGRATION_DB = Sequel.sqlite
87
87
  end
88
88
 
89
- if INTEGRATION_DB.adapter_scheme == :ibmdb
89
+ if INTEGRATION_DB.adapter_scheme == :ibmdb || (INTEGRATION_DB.adapter_scheme == :ado && INTEGRATION_DB.database_type == :access)
90
90
  def INTEGRATION_DB.drop_table(*tables)
91
91
  super
92
92
  rescue Sequel::DatabaseError
@@ -60,6 +60,12 @@ describe "Supported types" do
60
60
  ds.all.should == [{:name=>'Test User'}]
61
61
  end
62
62
 
63
+ specify "should support generic text type" do
64
+ ds = create_items_table_with_column(:name, String, :text=>true)
65
+ ds.insert(:name => 'Test User'*100)
66
+ ds.all.should == [{:name=>'Test User'*100}]
67
+ end
68
+
63
69
  cspecify "should support generic date type", [:do, :sqlite], [:jdbc, :sqlite], :mssql, :oracle do
64
70
  ds = create_items_table_with_column(:dat, Date)
65
71
  d = Date.today
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.39.0
4
+ version: 3.40.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-01 00:00:00.000000000 Z
12
+ date: 2012-09-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: The Database Toolkit for Ruby
15
15
  email: code@jeremyevans.net
@@ -101,6 +101,7 @@ extra_rdoc_files:
101
101
  - doc/release_notes/3.37.0.txt
102
102
  - doc/release_notes/3.38.0.txt
103
103
  - doc/release_notes/3.39.0.txt
104
+ - doc/release_notes/3.40.0.txt
104
105
  files:
105
106
  - MIT-LICENSE
106
107
  - CHANGELOG
@@ -177,6 +178,7 @@ files:
177
178
  - doc/release_notes/3.37.0.txt
178
179
  - doc/release_notes/3.38.0.txt
179
180
  - doc/release_notes/3.39.0.txt
181
+ - doc/release_notes/3.40.0.txt
180
182
  - doc/sharding.rdoc
181
183
  - doc/sql.rdoc
182
184
  - doc/validations.rdoc
@@ -371,6 +373,7 @@ files:
371
373
  - lib/sequel.rb
372
374
  - lib/sequel/adapters/ado.rb
373
375
  - lib/sequel/adapters/ado/mssql.rb
376
+ - lib/sequel/adapters/ado/access.rb
374
377
  - lib/sequel/adapters/amalgalite.rb
375
378
  - lib/sequel/adapters/db2.rb
376
379
  - lib/sequel/adapters/dbi.rb
@@ -397,6 +400,7 @@ files:
397
400
  - lib/sequel/adapters/jdbc/hsqldb.rb
398
401
  - lib/sequel/adapters/jdbc/derby.rb
399
402
  - lib/sequel/adapters/jdbc/progress.rb
403
+ - lib/sequel/adapters/jdbc/cubrid.rb
400
404
  - lib/sequel/adapters/mysql.rb
401
405
  - lib/sequel/adapters/odbc.rb
402
406
  - lib/sequel/adapters/odbc/mssql.rb
@@ -414,10 +418,12 @@ files:
414
418
  - lib/sequel/adapters/shared/mysql_prepared_statements.rb
415
419
  - lib/sequel/adapters/shared/db2.rb
416
420
  - lib/sequel/adapters/shared/firebird.rb
421
+ - lib/sequel/adapters/shared/cubrid.rb
417
422
  - lib/sequel/adapters/sqlite.rb
418
423
  - lib/sequel/adapters/utils/stored_procedures.rb
419
424
  - lib/sequel/adapters/utils/emulate_offset_with_row_number.rb
420
425
  - lib/sequel/adapters/utils/pg_types.rb
426
+ - lib/sequel/adapters/utils/split_alter_table.rb
421
427
  - lib/sequel/adapters/mysql2.rb
422
428
  - lib/sequel/adapters/swift.rb
423
429
  - lib/sequel/adapters/swift/mysql.rb
@@ -426,6 +432,7 @@ files:
426
432
  - lib/sequel/adapters/tinytds.rb
427
433
  - lib/sequel/adapters/ibmdb.rb
428
434
  - lib/sequel/adapters/mock.rb
435
+ - lib/sequel/adapters/cubrid.rb
429
436
  - lib/sequel/connection_pool.rb
430
437
  - lib/sequel/connection_pool/sharded_single.rb
431
438
  - lib/sequel/connection_pool/sharded_threaded.rb