sequel 4.5.0 → 4.6.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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +14 -0
  3. data/README.rdoc +0 -1
  4. data/doc/mssql_stored_procedures.rdoc +43 -0
  5. data/doc/release_notes/3.18.0.txt +2 -3
  6. data/doc/release_notes/3.9.0.txt +1 -1
  7. data/doc/release_notes/4.6.0.txt +30 -0
  8. data/doc/security.rdoc +7 -0
  9. data/lib/sequel/adapters/jdbc/h2.rb +4 -4
  10. data/lib/sequel/adapters/jdbc/postgresql.rb +4 -0
  11. data/lib/sequel/adapters/oracle.rb +1 -0
  12. data/lib/sequel/adapters/shared/mssql.rb +94 -1
  13. data/lib/sequel/adapters/shared/mysql.rb +4 -4
  14. data/lib/sequel/adapters/shared/postgres.rb +4 -4
  15. data/lib/sequel/adapters/tinytds.rb +22 -4
  16. data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +8 -2
  17. data/lib/sequel/database/dataset_defaults.rb +1 -1
  18. data/lib/sequel/model/associations.rb +1 -1
  19. data/lib/sequel/version.rb +1 -1
  20. data/spec/adapters/mssql_spec.rb +35 -0
  21. data/spec/adapters/oracle_spec.rb +4 -4
  22. data/spec/adapters/postgres_spec.rb +93 -93
  23. data/spec/adapters/spec_helper.rb +3 -1
  24. data/spec/bin_spec.rb +2 -0
  25. data/spec/core/database_spec.rb +22 -22
  26. data/spec/core/dataset_spec.rb +8 -8
  27. data/spec/core/expression_filters_spec.rb +1 -1
  28. data/spec/core/mock_adapter_spec.rb +2 -2
  29. data/spec/core/schema_generator_spec.rb +3 -3
  30. data/spec/core/spec_helper.rb +3 -1
  31. data/spec/core_extensions_spec.rb +3 -1
  32. data/spec/extensions/auto_validations_spec.rb +17 -17
  33. data/spec/extensions/caching_spec.rb +4 -4
  34. data/spec/extensions/error_splitter_spec.rb +1 -1
  35. data/spec/extensions/hook_class_methods_spec.rb +6 -6
  36. data/spec/extensions/migration_spec.rb +53 -53
  37. data/spec/extensions/pagination_spec.rb +9 -9
  38. data/spec/extensions/pg_array_associations_spec.rb +2 -2
  39. data/spec/extensions/pg_array_spec.rb +2 -2
  40. data/spec/extensions/pg_hstore_spec.rb +15 -15
  41. data/spec/extensions/pg_interval_spec.rb +3 -3
  42. data/spec/extensions/pg_range_spec.rb +20 -20
  43. data/spec/extensions/pg_row_spec.rb +1 -1
  44. data/spec/extensions/schema_caching_spec.rb +3 -3
  45. data/spec/extensions/spec_helper.rb +3 -1
  46. data/spec/extensions/static_cache_spec.rb +16 -16
  47. data/spec/extensions/tree_spec.rb +8 -8
  48. data/spec/extensions/validation_class_methods_spec.rb +10 -10
  49. data/spec/integration/database_test.rb +3 -3
  50. data/spec/integration/dataset_test.rb +6 -0
  51. data/spec/integration/migrator_test.rb +67 -67
  52. data/spec/integration/model_test.rb +2 -2
  53. data/spec/integration/schema_test.rb +1 -1
  54. data/spec/integration/spec_helper.rb +3 -1
  55. data/spec/integration/transaction_test.rb +2 -2
  56. data/spec/model/association_reflection_spec.rb +4 -4
  57. data/spec/model/associations_spec.rb +1 -1
  58. data/spec/model/class_dataset_methods_spec.rb +1 -1
  59. data/spec/model/eager_loading_spec.rb +7 -0
  60. data/spec/model/model_spec.rb +4 -4
  61. data/spec/model/record_spec.rb +20 -20
  62. data/spec/model/spec_helper.rb +2 -1
  63. data/spec/model/validations_spec.rb +1 -1
  64. data/spec/rspec_helper.rb +18 -0
  65. metadata +8 -3
@@ -195,6 +195,12 @@ describe "Simple Dataset operations" do
195
195
  @ds.limit(2, 1).all.should == []
196
196
  end
197
197
 
198
+ specify "should be orderable by column number" do
199
+ @ds.insert(:number=>20)
200
+ @ds.insert(:number=>10)
201
+ @ds.order(2, 1).select_map([:id, :number]).should == [[1, 10], [3, 10], [2, 20]]
202
+ end
203
+
198
204
  specify "should fetch correctly with a limit in an IN subselect" do
199
205
  @ds.where(:id=>@ds.select(:id).order(:id).limit(2)).all.should == [{:id=>1, :number=>10}]
200
206
  @ds.insert(:number=>20)
@@ -13,66 +13,66 @@ describe Sequel::Migrator do
13
13
  specify "should be able to migrate up and down all the way successfully" do
14
14
  @dir = 'spec/files/integer_migrations'
15
15
  @m.apply(@db, @dir)
16
- [:schema_info, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_true}
16
+ [:schema_info, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == true}
17
17
  @db[:schema_info].get(:version).should == 3
18
18
  @m.apply(@db, @dir, 0)
19
- [:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_false}
19
+ [:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == false}
20
20
  @db[:schema_info].get(:version).should == 0
21
21
  end
22
22
 
23
23
  specify "should be able to migrate up and down to specific versions successfully" do
24
24
  @dir = 'spec/files/integer_migrations'
25
25
  @m.apply(@db, @dir, 2)
26
- [:schema_info, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should be_true}
27
- @db.table_exists?(:sm3333).should be_false
26
+ [:schema_info, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should == true}
27
+ @db.table_exists?(:sm3333).should == false
28
28
  @db[:schema_info].get(:version).should == 2
29
29
  @m.apply(@db, @dir, 1)
30
- [:sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_false}
31
- @db.table_exists?(:sm1111).should be_true
30
+ [:sm2222, :sm3333].each{|n| @db.table_exists?(n).should == false}
31
+ @db.table_exists?(:sm1111).should == true
32
32
  @db[:schema_info].get(:version).should == 1
33
33
  end
34
34
 
35
35
  specify "should correctly set migration version to the last successful migration if the migration raises an error when migrating up" do
36
36
  @dir = 'spec/files/bad_up_migration'
37
37
  proc{@m.apply(@db, @dir)}.should raise_error
38
- [:schema_info, :sm11111].each{|n| @db.table_exists?(n).should be_true}
39
- @db.table_exists?(:sm22222).should be_false
38
+ [:schema_info, :sm11111].each{|n| @db.table_exists?(n).should == true}
39
+ @db.table_exists?(:sm22222).should == false
40
40
  @db[:schema_info].get(:version).should == 1
41
41
  @m.apply(@db, @dir, 0)
42
- [:sm11111, :sm22222].each{|n| @db.table_exists?(n).should be_false}
42
+ [:sm11111, :sm22222].each{|n| @db.table_exists?(n).should == false}
43
43
  @db[:schema_info].get(:version).should == 0
44
44
  end
45
45
 
46
46
  specify "should correctly set migration version to the last successful migration if the migration raises an error when migrating down" do
47
47
  @dir = 'spec/files/bad_down_migration'
48
48
  @m.apply(@db, @dir)
49
- [:schema_info, :sm11111, :sm22222].each{|n| @db.table_exists?(n).should be_true}
49
+ [:schema_info, :sm11111, :sm22222].each{|n| @db.table_exists?(n).should == true}
50
50
  @db[:schema_info].get(:version).should == 2
51
51
  proc{@m.apply(@db, @dir, 0)}.should raise_error
52
- [:sm22222].each{|n| @db.table_exists?(n).should be_false}
53
- @db.table_exists?(:sm11111).should be_true
52
+ [:sm22222].each{|n| @db.table_exists?(n).should == false}
53
+ @db.table_exists?(:sm11111).should == true
54
54
  @db[:schema_info].get(:version).should == 1
55
55
  end
56
56
 
57
57
  specify "should handle migrating up or down all the way with timestamped migrations" do
58
58
  @dir = 'spec/files/timestamped_migrations'
59
59
  @m.apply(@db, @dir)
60
- [:schema_migrations, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_true}
60
+ [:schema_migrations, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == true}
61
61
  @db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb 1273253851_create_nodes.rb 1273253853_3_create_users.rb'
62
62
  @m.apply(@db, @dir, 0)
63
- [:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_false}
63
+ [:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == false}
64
64
  @db[:schema_migrations].select_order_map(:filename).should == []
65
65
  end
66
66
 
67
67
  specify "should handle migrating up or down to specific timestamps with timestamped migrations" do
68
68
  @dir = 'spec/files/timestamped_migrations'
69
69
  @m.apply(@db, @dir, 1273253851)
70
- [:schema_migrations, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should be_true}
71
- @db.table_exists?(:sm3333).should be_false
70
+ [:schema_migrations, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should == true}
71
+ @db.table_exists?(:sm3333).should == false
72
72
  @db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb 1273253851_create_nodes.rb'
73
73
  @m.apply(@db, @dir, 1273253849)
74
- [:sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_false}
75
- @db.table_exists?(:sm1111).should be_true
74
+ [:sm2222, :sm3333].each{|n| @db.table_exists?(n).should == false}
75
+ @db.table_exists?(:sm1111).should == true
76
76
  @db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb'
77
77
  end
78
78
 
@@ -81,7 +81,7 @@ describe Sequel::Migrator do
81
81
  @m.apply(@db, @dir)
82
82
  @dir = 'spec/files/interleaved_timestamped_migrations'
83
83
  @m.apply(@db, @dir)
84
- [:schema_migrations, :sm1111, :sm1122, :sm2222, :sm2233, :sm3333].each{|n| @db.table_exists?(n).should be_true}
84
+ [:schema_migrations, :sm1111, :sm1122, :sm2222, :sm2233, :sm3333].each{|n| @db.table_exists?(n).should == true}
85
85
  @db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb 1273253850_create_artists.rb 1273253851_create_nodes.rb 1273253852_create_albums.rb 1273253853_3_create_users.rb'
86
86
  end
87
87
 
@@ -90,7 +90,7 @@ describe Sequel::Migrator do
90
90
  @m.apply(@db, @dir)
91
91
  @dir = 'spec/files/interleaved_timestamped_migrations'
92
92
  @m.apply(@db, @dir, 0)
93
- [:sm1111, :sm1122, :sm2222, :sm2233, :sm3333].each{|n| @db.table_exists?(n).should be_false}
93
+ [:sm1111, :sm1122, :sm2222, :sm2233, :sm3333].each{|n| @db.table_exists?(n).should == false}
94
94
  @db[:schema_migrations].select_order_map(:filename).should == []
95
95
  end
96
96
 
@@ -99,89 +99,89 @@ describe Sequel::Migrator do
99
99
  @m.apply(@db, @dir)
100
100
  @dir = 'spec/files/interleaved_timestamped_migrations'
101
101
  @m.apply(@db, @dir, 1273253851)
102
- [:schema_migrations, :sm1111, :sm1122, :sm2222].each{|n| @db.table_exists?(n).should be_true}
103
- [:sm2233, :sm3333].each{|n| @db.table_exists?(n).should be_false}
102
+ [:schema_migrations, :sm1111, :sm1122, :sm2222].each{|n| @db.table_exists?(n).should == true}
103
+ [:sm2233, :sm3333].each{|n| @db.table_exists?(n).should == false}
104
104
  @db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb 1273253850_create_artists.rb 1273253851_create_nodes.rb'
105
105
  end
106
106
 
107
107
  specify "should correctly update schema_migrations table when an error occurs when migrating up or down using timestamped migrations" do
108
108
  @dir = 'spec/files/bad_timestamped_migrations'
109
109
  proc{@m.apply(@db, @dir)}.should raise_error
110
- [:schema_migrations, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should be_true}
111
- @db.table_exists?(:sm3333).should be_false
110
+ [:schema_migrations, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should == true}
111
+ @db.table_exists?(:sm3333).should == false
112
112
  @db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb 1273253851_create_nodes.rb'
113
113
  proc{@m.apply(@db, @dir, 0)}.should raise_error
114
- [:sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_false}
115
- @db.table_exists?(:sm1111).should be_true
114
+ [:sm2222, :sm3333].each{|n| @db.table_exists?(n).should == false}
115
+ @db.table_exists?(:sm1111).should == true
116
116
  @db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb'
117
117
  end
118
118
 
119
119
  specify "should handle multiple migrations with the same timestamp correctly" do
120
120
  @dir = 'spec/files/duplicate_timestamped_migrations'
121
121
  @m.apply(@db, @dir)
122
- [:schema_migrations, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_true}
122
+ [:schema_migrations, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == true}
123
123
  @db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb 1273253853_create_nodes.rb 1273253853_create_users.rb'
124
124
  @m.apply(@db, @dir, 1273253853)
125
- [:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_true}
125
+ [:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == true}
126
126
  @db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb 1273253853_create_nodes.rb 1273253853_create_users.rb'
127
127
  @m.apply(@db, @dir, 1273253849)
128
- [:sm1111].each{|n| @db.table_exists?(n).should be_true}
129
- [:sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_false}
128
+ [:sm1111].each{|n| @db.table_exists?(n).should == true}
129
+ [:sm2222, :sm3333].each{|n| @db.table_exists?(n).should == false}
130
130
  @db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb'
131
131
  @m.apply(@db, @dir, 1273253848)
132
- [:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_false}
132
+ [:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == false}
133
133
  @db[:schema_migrations].select_order_map(:filename).should == []
134
134
  end
135
135
 
136
136
  specify "should convert schema_info table to schema_migrations table" do
137
137
  @dir = 'spec/files/integer_migrations'
138
138
  @m.apply(@db, @dir)
139
- [:schema_info, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_true}
140
- [:schema_migrations, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should be_false}
139
+ [:schema_info, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == true}
140
+ [:schema_migrations, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should == false}
141
141
 
142
142
  @dir = 'spec/files/convert_to_timestamp_migrations'
143
143
  @m.apply(@db, @dir)
144
- [:schema_info, :sm1111, :sm2222, :sm3333, :schema_migrations, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should be_true}
144
+ [:schema_info, :sm1111, :sm2222, :sm3333, :schema_migrations, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should == true}
145
145
  @db[:schema_migrations].select_order_map(:filename).should == %w'001_create_sessions.rb 002_create_nodes.rb 003_3_create_users.rb 1273253850_create_artists.rb 1273253852_create_albums.rb'
146
146
 
147
147
  @m.apply(@db, @dir, 4)
148
- [:schema_info, :schema_migrations, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_true}
149
- [:sm1122, :sm2233].each{|n| @db.table_exists?(n).should be_false}
148
+ [:schema_info, :schema_migrations, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == true}
149
+ [:sm1122, :sm2233].each{|n| @db.table_exists?(n).should == false}
150
150
  @db[:schema_migrations].select_order_map(:filename).should == %w'001_create_sessions.rb 002_create_nodes.rb 003_3_create_users.rb'
151
151
 
152
152
  @m.apply(@db, @dir, 0)
153
- [:schema_info, :schema_migrations].each{|n| @db.table_exists?(n).should be_true}
154
- [:sm1111, :sm2222, :sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should be_false}
153
+ [:schema_info, :schema_migrations].each{|n| @db.table_exists?(n).should == true}
154
+ [:sm1111, :sm2222, :sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should == false}
155
155
  @db[:schema_migrations].select_order_map(:filename).should == []
156
156
  end
157
157
 
158
158
  specify "should handle unapplied migrations when migrating schema_info table to schema_migrations table" do
159
159
  @dir = 'spec/files/integer_migrations'
160
160
  @m.apply(@db, @dir, 2)
161
- [:schema_info, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should be_true}
162
- [:schema_migrations, :sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should be_false}
161
+ [:schema_info, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should == true}
162
+ [:schema_migrations, :sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should == false}
163
163
 
164
164
  @dir = 'spec/files/convert_to_timestamp_migrations'
165
165
  @m.apply(@db, @dir, 1273253850)
166
- [:schema_info, :sm1111, :sm2222, :sm3333, :schema_migrations, :sm1122].each{|n| @db.table_exists?(n).should be_true}
167
- [:sm2233].each{|n| @db.table_exists?(n).should be_false}
166
+ [:schema_info, :sm1111, :sm2222, :sm3333, :schema_migrations, :sm1122].each{|n| @db.table_exists?(n).should == true}
167
+ [:sm2233].each{|n| @db.table_exists?(n).should == false}
168
168
  @db[:schema_migrations].select_order_map(:filename).should == %w'001_create_sessions.rb 002_create_nodes.rb 003_3_create_users.rb 1273253850_create_artists.rb'
169
169
  end
170
170
 
171
171
  specify "should handle unapplied migrations when migrating schema_info table to schema_migrations table and target is less than last integer migration version" do
172
172
  @dir = 'spec/files/integer_migrations'
173
173
  @m.apply(@db, @dir, 1)
174
- [:schema_info, :sm1111].each{|n| @db.table_exists?(n).should be_true}
175
- [:schema_migrations, :sm2222, :sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should be_false}
174
+ [:schema_info, :sm1111].each{|n| @db.table_exists?(n).should == true}
175
+ [:schema_migrations, :sm2222, :sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should == false}
176
176
 
177
177
  @dir = 'spec/files/convert_to_timestamp_migrations'
178
178
  @m.apply(@db, @dir, 2)
179
- [:schema_info, :sm1111, :sm2222, :schema_migrations].each{|n| @db.table_exists?(n).should be_true}
180
- [:sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should be_false}
179
+ [:schema_info, :sm1111, :sm2222, :schema_migrations].each{|n| @db.table_exists?(n).should == true}
180
+ [:sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should == false}
181
181
  @db[:schema_migrations].select_order_map(:filename).should == %w'001_create_sessions.rb 002_create_nodes.rb'
182
182
 
183
183
  @m.apply(@db, @dir)
184
- [:schema_info, :sm1111, :sm2222, :schema_migrations, :sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should be_true}
184
+ [:schema_info, :sm1111, :sm2222, :schema_migrations, :sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should == true}
185
185
  @db[:schema_migrations].select_order_map(:filename).should == %w'001_create_sessions.rb 002_create_nodes.rb 003_3_create_users.rb 1273253850_create_artists.rb 1273253852_create_albums.rb'
186
186
  end
187
187
 
@@ -189,52 +189,52 @@ describe Sequel::Migrator do
189
189
  @dir = 'spec/files/reversible_migrations'
190
190
  @db.drop_table?(:a, :b)
191
191
  @m.apply(@db, @dir, 1)
192
- [:schema_info, :a].each{|n| @db.table_exists?(n).should be_true}
193
- [:schema_migrations, :b].each{|n| @db.table_exists?(n).should be_false}
192
+ [:schema_info, :a].each{|n| @db.table_exists?(n).should == true}
193
+ [:schema_migrations, :b].each{|n| @db.table_exists?(n).should == false}
194
194
  @db[:a].columns.should == [:a]
195
195
 
196
196
  @m.apply(@db, @dir, 2)
197
- [:schema_info, :a].each{|n| @db.table_exists?(n).should be_true}
198
- [:schema_migrations, :b].each{|n| @db.table_exists?(n).should be_false}
197
+ [:schema_info, :a].each{|n| @db.table_exists?(n).should == true}
198
+ [:schema_migrations, :b].each{|n| @db.table_exists?(n).should == false}
199
199
  @db[:a].columns.should == [:a, :b]
200
200
 
201
201
  @m.apply(@db, @dir, 3)
202
- [:schema_info, :a].each{|n| @db.table_exists?(n).should be_true}
203
- [:schema_migrations, :b].each{|n| @db.table_exists?(n).should be_false}
202
+ [:schema_info, :a].each{|n| @db.table_exists?(n).should == true}
203
+ [:schema_migrations, :b].each{|n| @db.table_exists?(n).should == false}
204
204
  @db[:a].columns.should == [:a, :c]
205
205
 
206
206
  @m.apply(@db, @dir, 4)
207
- [:schema_info, :b].each{|n| @db.table_exists?(n).should be_true}
208
- [:schema_migrations, :a].each{|n| @db.table_exists?(n).should be_false}
207
+ [:schema_info, :b].each{|n| @db.table_exists?(n).should == true}
208
+ [:schema_migrations, :a].each{|n| @db.table_exists?(n).should == false}
209
209
  @db[:b].columns.should == [:a, :c]
210
210
 
211
211
  @m.apply(@db, @dir, 5)
212
- [:schema_info, :b].each{|n| @db.table_exists?(n).should be_true}
213
- [:schema_migrations, :a].each{|n| @db.table_exists?(n).should be_false}
212
+ [:schema_info, :b].each{|n| @db.table_exists?(n).should == true}
213
+ [:schema_migrations, :a].each{|n| @db.table_exists?(n).should == false}
214
214
  @db[:b].columns.should == [:a, :c, :e]
215
215
 
216
216
  @m.apply(@db, @dir, 4)
217
- [:schema_info, :b].each{|n| @db.table_exists?(n).should be_true}
218
- [:schema_migrations, :a].each{|n| @db.table_exists?(n).should be_false}
217
+ [:schema_info, :b].each{|n| @db.table_exists?(n).should == true}
218
+ [:schema_migrations, :a].each{|n| @db.table_exists?(n).should == false}
219
219
  @db[:b].columns.should == [:a, :c]
220
220
 
221
221
  @m.apply(@db, @dir, 3)
222
- [:schema_info, :a].each{|n| @db.table_exists?(n).should be_true}
223
- [:schema_migrations, :b].each{|n| @db.table_exists?(n).should be_false}
222
+ [:schema_info, :a].each{|n| @db.table_exists?(n).should == true}
223
+ [:schema_migrations, :b].each{|n| @db.table_exists?(n).should == false}
224
224
  @db[:a].columns.should == [:a, :c]
225
225
 
226
226
  @m.apply(@db, @dir, 2)
227
- [:schema_info, :a].each{|n| @db.table_exists?(n).should be_true}
228
- [:schema_migrations, :b].each{|n| @db.table_exists?(n).should be_false}
227
+ [:schema_info, :a].each{|n| @db.table_exists?(n).should == true}
228
+ [:schema_migrations, :b].each{|n| @db.table_exists?(n).should == false}
229
229
  @db[:a].columns.should == [:a, :b]
230
230
 
231
231
  @m.apply(@db, @dir, 1)
232
- [:schema_info, :a].each{|n| @db.table_exists?(n).should be_true}
233
- [:schema_migrations, :b].each{|n| @db.table_exists?(n).should be_false}
232
+ [:schema_info, :a].each{|n| @db.table_exists?(n).should == true}
233
+ [:schema_migrations, :b].each{|n| @db.table_exists?(n).should == false}
234
234
  @db[:a].columns.should == [:a]
235
235
 
236
236
  @m.apply(@db, @dir, 0)
237
- [:schema_info].each{|n| @db.table_exists?(n).should be_true}
238
- [:schema_migrations, :a, :b].each{|n| @db.table_exists?(n).should be_false}
237
+ [:schema_info].each{|n| @db.table_exists?(n).should == true}
238
+ [:schema_migrations, :a, :b].each{|n| @db.table_exists?(n).should == false}
239
239
  end
240
240
  end
@@ -107,7 +107,7 @@ describe "Sequel::Model basic support" do
107
107
 
108
108
  i.rb = true
109
109
  i.destroy.should be_nil
110
- i.exists?.should be_true
110
+ i.exists?.should == true
111
111
  i.hooks.should == [:ad, :adr]
112
112
 
113
113
  i.name = 'K'
@@ -118,7 +118,7 @@ describe "Sequel::Model basic support" do
118
118
 
119
119
  i.rb = false
120
120
  i.destroy.should_not be_nil
121
- i.exists?.should be_false
121
+ i.exists?.should == false
122
122
  i.hooks.should == [:ad, :adc]
123
123
  end
124
124
 
@@ -298,7 +298,7 @@ describe "Database schema modifiers" do
298
298
  specify "should handle create table in a rolled back transaction" do
299
299
  @db.drop_table?(:items)
300
300
  @db.transaction(:rollback=>:always){@db.create_table(:items){Integer :number}}
301
- @db.table_exists?(:items).should be_false
301
+ @db.table_exists?(:items).should == false
302
302
  end if DB.supports_transactional_ddl?
303
303
 
304
304
  describe "join tables" do
@@ -60,7 +60,9 @@ def Sequel.guarded?(*checked)
60
60
  false
61
61
  end
62
62
 
63
- (defined?(RSpec) ? RSpec::Core::ExampleGroup : Spec::Example::ExampleGroup).class_eval do
63
+ require File.join(File.dirname(File.expand_path(__FILE__)), "../rspec_helper.rb")
64
+
65
+ RSPEC_EXAMPLE_GROUP.class_eval do
64
66
  def log
65
67
  begin
66
68
  DB.loggers << Logger.new(STDOUT)
@@ -23,10 +23,10 @@ describe "Database transactions" do
23
23
  end
24
24
 
25
25
  specify "should have #in_transaction? work correctly" do
26
- @db.in_transaction?.should be_false
26
+ @db.in_transaction?.should == false
27
27
  c = nil
28
28
  @db.transaction{c = @db.in_transaction?}
29
- c.should be_true
29
+ c.should == true
30
30
  end
31
31
 
32
32
  specify "should correctly rollback transactions" do
@@ -269,16 +269,16 @@ describe Sequel::Model::Associations::AssociationReflection, "#remove_before_des
269
269
 
270
270
  it "should be true for many_to_one and many_to_many associations" do
271
271
  @c.many_to_one :c, :class=>@c
272
- @c.association_reflection(:c).remove_before_destroy?.should be_true
272
+ @c.association_reflection(:c).remove_before_destroy?.should == true
273
273
  @c.many_to_many :cs, :class=>@c
274
- @c.association_reflection(:cs).remove_before_destroy?.should be_true
274
+ @c.association_reflection(:cs).remove_before_destroy?.should == true
275
275
  end
276
276
 
277
277
  it "should be false for one_to_one and one_to_many associations" do
278
278
  @c.one_to_one :c, :class=>@c
279
- @c.association_reflection(:c).remove_before_destroy?.should be_false
279
+ @c.association_reflection(:c).remove_before_destroy?.should == false
280
280
  @c.one_to_many :cs, :class=>@c
281
- @c.association_reflection(:cs).remove_before_destroy?.should be_false
281
+ @c.association_reflection(:cs).remove_before_destroy?.should == false
282
282
  end
283
283
  end
284
284
 
@@ -3736,7 +3736,7 @@ describe "Model#freeze" do
3736
3736
  end
3737
3737
 
3738
3738
  it "should freeze the object's associations" do
3739
- @o.associations.frozen?.should be_true
3739
+ @o.associations.frozen?.should == true
3740
3740
  end
3741
3741
 
3742
3742
  it "should not break associations getters" do
@@ -25,7 +25,7 @@ describe Sequel::Model, "class dataset methods" do
25
25
  @c.each{|r| r.should == @c.load(:id=>1)}.should == @d
26
26
  @db.sqls.should == ["SELECT * FROM items"]
27
27
  @c.each_server{|r| r.opts[:server].should == :default}
28
- @c.empty?.should be_false
28
+ @c.empty?.should == false
29
29
  @db.sqls.should == ["SELECT 1 AS one FROM items LIMIT 1"]
30
30
  @c.except(@d, :from_self=>false).sql.should == "SELECT * FROM items EXCEPT SELECT * FROM items"
31
31
  @c.exclude(:a).sql.should == "SELECT * FROM items WHERE NOT a"
@@ -149,6 +149,13 @@ describe Sequel::Model, "#eager" do
149
149
  DB.sqls.should == []
150
150
  end
151
151
 
152
+ it "should not break if the dataset does not have a row proc" do
153
+ EagerAlbum.one_to_one :track, :class=>'EagerTrack', :key=>:album_id
154
+ a = EagerAlbum.eager(:track).naked.all
155
+ a.should == [{:id => 1, :band_id => 2}]
156
+ DB.sqls.should == ['SELECT * FROM albums']
157
+ end
158
+
152
159
  it "should use first matching entry when eager loading one_to_one association" do
153
160
  EagerAlbum.one_to_one :track, :class=>'EagerTrack', :key=>:album_id
154
161
  EagerTrack.dataset._fetch = [{:id => 3, :album_id=>1}, {:id => 4, :album_id=>1}]
@@ -303,7 +303,7 @@ describe Sequel::Model, "constructors" do
303
303
  block_called = false
304
304
  m = @m.new {|i| block_called = true; i.should be_a_kind_of(@m); i.values[:a] = 1}
305
305
 
306
- block_called.should be_true
306
+ block_called.should == true
307
307
  m.values[:a].should == 1
308
308
  end
309
309
 
@@ -312,21 +312,21 @@ describe Sequel::Model, "constructors" do
312
312
  o = @m.dataset.row_proc.call(:a=>1)
313
313
  o.should be_a_kind_of(@m)
314
314
  o.values.should == {:a=>1}
315
- o.new?.should be_false
315
+ o.new?.should == false
316
316
  end
317
317
 
318
318
  it "should have .call create an existing object" do
319
319
  o = @m.call(:a=>1)
320
320
  o.should be_a_kind_of(@m)
321
321
  o.values.should == {:a=>1}
322
- o.new?.should be_false
322
+ o.new?.should == false
323
323
  end
324
324
 
325
325
  it "should have .load create an existing object" do
326
326
  o = @m.load(:a=>1)
327
327
  o.should be_a_kind_of(@m)
328
328
  o.values.should == {:a=>1}
329
- o.new?.should be_false
329
+ o.new?.should == false
330
330
  end
331
331
  end
332
332