sequel_core 2.2.0 → 3.8.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 (66) hide show
  1. metadata +30 -101
  2. data/CHANGELOG +0 -1519
  3. data/COPYING +0 -19
  4. data/README +0 -313
  5. data/Rakefile +0 -158
  6. data/bin/sequel +0 -117
  7. data/doc/cheat_sheet.rdoc +0 -225
  8. data/doc/dataset_filtering.rdoc +0 -182
  9. data/lib/sequel_core.rb +0 -136
  10. data/lib/sequel_core/adapters/adapter_skeleton.rb +0 -68
  11. data/lib/sequel_core/adapters/ado.rb +0 -90
  12. data/lib/sequel_core/adapters/db2.rb +0 -160
  13. data/lib/sequel_core/adapters/dbi.rb +0 -127
  14. data/lib/sequel_core/adapters/informix.rb +0 -89
  15. data/lib/sequel_core/adapters/jdbc.rb +0 -110
  16. data/lib/sequel_core/adapters/mysql.rb +0 -486
  17. data/lib/sequel_core/adapters/odbc.rb +0 -167
  18. data/lib/sequel_core/adapters/odbc_mssql.rb +0 -106
  19. data/lib/sequel_core/adapters/openbase.rb +0 -76
  20. data/lib/sequel_core/adapters/oracle.rb +0 -182
  21. data/lib/sequel_core/adapters/postgres.rb +0 -560
  22. data/lib/sequel_core/adapters/sqlite.rb +0 -270
  23. data/lib/sequel_core/connection_pool.rb +0 -194
  24. data/lib/sequel_core/core_ext.rb +0 -197
  25. data/lib/sequel_core/core_sql.rb +0 -184
  26. data/lib/sequel_core/database.rb +0 -462
  27. data/lib/sequel_core/database/schema.rb +0 -156
  28. data/lib/sequel_core/dataset.rb +0 -457
  29. data/lib/sequel_core/dataset/callback.rb +0 -13
  30. data/lib/sequel_core/dataset/convenience.rb +0 -245
  31. data/lib/sequel_core/dataset/pagination.rb +0 -96
  32. data/lib/sequel_core/dataset/query.rb +0 -41
  33. data/lib/sequel_core/dataset/schema.rb +0 -15
  34. data/lib/sequel_core/dataset/sql.rb +0 -889
  35. data/lib/sequel_core/deprecated.rb +0 -26
  36. data/lib/sequel_core/exceptions.rb +0 -42
  37. data/lib/sequel_core/migration.rb +0 -187
  38. data/lib/sequel_core/object_graph.rb +0 -216
  39. data/lib/sequel_core/pretty_table.rb +0 -71
  40. data/lib/sequel_core/schema.rb +0 -2
  41. data/lib/sequel_core/schema/generator.rb +0 -239
  42. data/lib/sequel_core/schema/sql.rb +0 -326
  43. data/lib/sequel_core/sql.rb +0 -812
  44. data/lib/sequel_core/worker.rb +0 -68
  45. data/spec/adapters/informix_spec.rb +0 -96
  46. data/spec/adapters/mysql_spec.rb +0 -765
  47. data/spec/adapters/oracle_spec.rb +0 -222
  48. data/spec/adapters/postgres_spec.rb +0 -441
  49. data/spec/adapters/sqlite_spec.rb +0 -413
  50. data/spec/connection_pool_spec.rb +0 -363
  51. data/spec/core_ext_spec.rb +0 -156
  52. data/spec/core_sql_spec.rb +0 -427
  53. data/spec/database_spec.rb +0 -963
  54. data/spec/dataset_spec.rb +0 -2933
  55. data/spec/expression_filters_spec.rb +0 -316
  56. data/spec/migration_spec.rb +0 -261
  57. data/spec/object_graph_spec.rb +0 -230
  58. data/spec/pretty_table_spec.rb +0 -58
  59. data/spec/rcov.opts +0 -6
  60. data/spec/schema_generator_spec.rb +0 -122
  61. data/spec/schema_spec.rb +0 -422
  62. data/spec/spec.opts +0 -0
  63. data/spec/spec_config.rb +0 -7
  64. data/spec/spec_config.rb.example +0 -8
  65. data/spec/spec_helper.rb +0 -55
  66. data/spec/worker_spec.rb +0 -96
@@ -1,156 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'spec_helper')
2
-
3
- context "Array#extract_options!" do
4
- specify "should pop the last item if it is a hash" do
5
- a = [1,2,{1=>2}]
6
- a.extract_options!.should == {1=>2}
7
- a.should == [1,2]
8
- end
9
-
10
- specify "should return an empty hash if the last item is not a hash" do
11
- a = [1,2]
12
- a.extract_options!.should == {}
13
- a.should == [1,2]
14
- end
15
- end
16
-
17
- context "Enumerable#send_each" do
18
- specify "should send the supplied method to each item" do
19
- a = ['abbc', 'bbccdd', 'hebtre']
20
- a.send_each(:gsub!, 'b', '_')
21
- a.should == ['a__c', '__ccdd', 'he_tre']
22
- end
23
- end
24
-
25
- context "Range#interval" do
26
- specify "should return the interval between the beginning and end for an inclusive range" do
27
- (1..10).interval.should == 9
28
-
29
- r = rand(100000) + 10
30
- t1 = Time.now; t2 = t1 + r
31
- (t1..t2).interval.should == r
32
- end
33
-
34
- specify "should return the interval between the beginning and end for an exclusive range" do
35
- (1...10).interval.should == 8
36
-
37
- r = rand(100000) + 10
38
- t1 = Time.now; t2 = t1 + r
39
- (t1...t2).interval.should == r - 1
40
- end
41
- end
42
-
43
- context "Module#class_attr_reader" do
44
- specify "it should create instance methods that call class methods of the same name" do
45
- @c = Class.new do
46
- def self.x; 1; end
47
- class_attr_reader :x
48
- end
49
- @c.new.x.should == 1
50
- def @c.x; 2; end
51
- @c.new.x.should == 2
52
- end
53
- end
54
-
55
- context "Module#metaalias" do
56
- specify "it should create aliases of singleton/class methods" do
57
- @c = Class.new do
58
- def self.x; 1; end
59
- metaalias :y, :x
60
- end
61
- @c.y.should == 1
62
- def @c.x; 2; end
63
- @c.y.should == 1
64
- end
65
- end
66
-
67
- context "Module#metaattr_reader" do
68
- specify "it should create attr_readers of singleton/class methods" do
69
- @c = Class.new do
70
- @y = 1
71
- @x = 2
72
- metaattr_reader :y, :x
73
- end
74
- @c.y.should == 1
75
- @c.x.should == 2
76
- end
77
- end
78
-
79
- context "Object#is_one_of?" do
80
- specify "it should be true if the object is one of the classes" do
81
- 1.is_one_of?(Numeric, Array).should == true
82
- [].is_one_of?(Numeric, Array).should == true
83
- {}.is_one_of?(Numeric, Enumerable).should == true
84
- end
85
-
86
- specify "it should be false if the object is not one of the classes" do
87
- 'a'.is_one_of?(Numeric, Array).should == false
88
- Object.new.is_one_of?(Numeric, Array).should == false
89
- end
90
- end
91
-
92
- context "Object#blank?" do
93
- specify "it should be true if the object responds true to empty?" do
94
- [].blank?.should == true
95
- {}.blank?.should == true
96
- o = Object.new
97
- def o.empty?; true; end
98
- o.blank?.should == true
99
- end
100
-
101
- specify "it should be false if the object doesn't respond true to empty?" do
102
- [2].blank?.should == false
103
- {1=>2}.blank?.should == false
104
- Object.new.blank?.should == false
105
- end
106
- end
107
-
108
- context "Numeric#blank?" do
109
- specify "it should always be false" do
110
- 1.blank?.should == false
111
- 0.blank?.should == false
112
- -1.blank?.should == false
113
- 1.0.blank?.should == false
114
- 0.0.blank?.should == false
115
- -1.0.blank?.should == false
116
- 10000000000000000.blank?.should == false
117
- -10000000000000000.blank?.should == false
118
- 10000000000000000.0.blank?.should == false
119
- -10000000000000000.0.blank?.should == false
120
- end
121
- end
122
-
123
- context "NilClass#blank?" do
124
- specify "it should always be true" do
125
- nil.blank?.should == true
126
- end
127
- end
128
-
129
- context "TrueClass#blank?" do
130
- specify "it should always be false" do
131
- true.blank?.should == false
132
- end
133
- end
134
-
135
- context "FalseClass#blank?" do
136
- specify "it should always be true" do
137
- false.blank?.should == true
138
- end
139
- end
140
-
141
- context "FalseClass#blank?" do
142
- specify "it should be true if the string is empty" do
143
- ''.blank?.should == true
144
- end
145
- specify "it should be true if the string is composed of just whitespace" do
146
- ' '.blank?.should == true
147
- "\r\n\t".blank?.should == true
148
- (' '*4000).blank?.should == true
149
- ("\r\n\t"*4000).blank?.should == true
150
- end
151
- specify "it should be false if the string has any non whitespace characters" do
152
- '1'.blank?.should == false
153
- ("\r\n\t"*4000 + 'a').blank?.should == false
154
- ("\r\na\t"*4000).blank?.should == false
155
- end
156
- end
@@ -1,427 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'spec_helper')
2
-
3
- context "Array#all_two_pairs?" do
4
- specify "should return false if empty" do
5
- [].all_two_pairs?.should == false
6
- end
7
-
8
- specify "should return false if any of the elements is not an array" do
9
- [1].all_two_pairs?.should == false
10
- [[1,2],1].all_two_pairs?.should == false
11
- end
12
-
13
- specify "should return false if any of the elements has a length other than two" do
14
- [[1,2],[]].all_two_pairs?.should == false
15
- [[1,2],[1]].all_two_pairs?.should == false
16
- [[1,2],[1,2,3]].all_two_pairs?.should == false
17
- end
18
-
19
- specify "should return true if all of the elements are arrays with a length of two" do
20
- [[1,2]].all_two_pairs?.should == true
21
- [[1,2],[1,2]].all_two_pairs?.should == true
22
- [[1,2],[1,2],[1,2]].all_two_pairs?.should == true
23
- end
24
- end
25
-
26
- context "Array#case and Hash#case" do
27
- setup do
28
- @d = Sequel::Dataset.new(nil)
29
- end
30
-
31
- specify "should return SQL CASE expression" do
32
- @d.literal({:x=>:y}.case(:z)).should == '(CASE WHEN x THEN y ELSE z END)'
33
- ['(CASE WHEN x THEN y WHEN a THEN b ELSE z END)',
34
- '(CASE WHEN a THEN b WHEN x THEN y ELSE z END)'].should(include(@d.literal({:x=>:y, :a=>:b}.case(:z))))
35
- @d.literal([[:x, :y]].case(:z)).should == '(CASE WHEN x THEN y ELSE z END)'
36
- @d.literal([[:x, :y], [:a, :b]].case(:z)).should == '(CASE WHEN x THEN y WHEN a THEN b ELSE z END)'
37
- end
38
-
39
- specify "should raise an error if an array that isn't all two pairs is used" do
40
- proc{[:b].case(:a)}.should raise_error(Sequel::Error)
41
- proc{[:b, :c].case(:a)}.should raise_error(Sequel::Error)
42
- proc{[[:b, :c], :d].case(:a)}.should raise_error(Sequel::Error)
43
- end
44
-
45
- specify "should raise an error if an empty array/hash is used" do
46
- proc{[].case(:a)}.should raise_error(Sequel::Error)
47
- proc{{}.case(:a)}.should raise_error(Sequel::Error)
48
- end
49
- end
50
-
51
- context "Array#to_sql" do
52
- specify "should concatenate multiple lines into a single string" do
53
- "SELECT * \r\nFROM items\r\n WHERE a = 1".split.to_sql. \
54
- should == 'SELECT * FROM items WHERE a = 1'
55
- end
56
-
57
- specify "should remove superfluous white space and line breaks" do
58
- "\tSELECT * \n FROM items ".split.to_sql. \
59
- should == 'SELECT * FROM items'
60
- end
61
-
62
- specify "should remove ANSI SQL comments" do
63
- "SELECT * --comment\r\n FROM items\r\n --comment".split.to_sql. \
64
- should == 'SELECT * FROM items'
65
- end
66
-
67
- specify "should remove C-style comments" do
68
- "SELECT * \r\n /* comment comment\r\n comment\r\n FROM items */\r\n FROM items\r\n--comment".split.to_sql. \
69
- should == 'SELECT * FROM items'
70
- end
71
- end
72
-
73
- context "String#to_sql" do
74
- specify "should concatenate multiple lines into a single string" do
75
- "SELECT * \r\nFROM items\r\nWHERE a = 1".to_sql. \
76
- should == 'SELECT * FROM items WHERE a = 1'
77
- end
78
-
79
- specify "should remove superfluous white space and line breaks" do
80
- "\tSELECT * \r\n FROM items ".to_sql. \
81
- should == 'SELECT * FROM items'
82
- end
83
-
84
- specify "should remove ANSI SQL comments" do
85
- "SELECT * --comment \r\n FROM items\r\n --comment".to_sql. \
86
- should == 'SELECT * FROM items'
87
- end
88
-
89
- specify "should remove C-style comments" do
90
- "SELECT * \r\n/* comment comment\r\ncomment\r\nFROM items */\r\nFROM items\r\n--comment".to_sql. \
91
- should == 'SELECT * FROM items'
92
- end
93
- end
94
-
95
- context "String#lit" do
96
- specify "should return an LiteralString object" do
97
- 'xyz'.lit.should be_a_kind_of(Sequel::LiteralString)
98
- 'xyz'.lit.to_s.should == 'xyz'
99
- end
100
-
101
- specify "should inhibit string literalization" do
102
- Sequel::Database.new[:t].update_sql(:stamp => "NOW()".expr).should == \
103
- "UPDATE t SET stamp = NOW()"
104
- end
105
-
106
- specify "should be aliased as expr" do
107
- 'xyz'.expr.should be_a_kind_of(Sequel::LiteralString)
108
- 'xyz'.expr.to_s.should == 'xyz'
109
- Sequel::Database.new[:t].update_sql(:stamp => "NOW()".expr).should == \
110
- "UPDATE t SET stamp = NOW()"
111
- end
112
- end
113
-
114
- context "String#to_blob" do
115
- specify "should return a Blob object" do
116
- 'xyz'.to_blob.should be_a_kind_of(::Sequel::SQL::Blob)
117
- 'xyz'.to_blob.should == 'xyz'
118
- end
119
-
120
- specify "should retain binary data" do
121
- "\1\2\3\4".to_blob.should == "\1\2\3\4"
122
- end
123
- end
124
-
125
- context "String#split_sql" do
126
- specify "should split a string containing multiple statements" do
127
- "DROP TABLE a; DROP TABLE c".split_sql.should == \
128
- ['DROP TABLE a', 'DROP TABLE c']
129
- end
130
-
131
- specify "should remove comments from the string" do
132
- "DROP TABLE a;/* DROP TABLE b; DROP TABLE c;*/DROP TABLE d".split_sql.should == \
133
- ['DROP TABLE a', 'DROP TABLE d']
134
- end
135
- end
136
-
137
- context "#desc" do
138
- setup do
139
- @ds = Sequel::Dataset.new(nil)
140
- end
141
-
142
- specify "should format a DESC clause for a column ref" do
143
- :test.desc.to_s(@ds).should == 'test DESC'
144
-
145
- :items__price.desc.to_s(@ds).should == 'items.price DESC'
146
- end
147
-
148
- specify "should format a DESC clause for a function" do
149
- :avg[:test].desc.to_s(@ds).should == 'avg(test) DESC'
150
- end
151
- end
152
-
153
- context "#asc" do
154
- setup do
155
- @ds = Sequel::Dataset.new(nil)
156
- end
157
-
158
- specify "should format a ASC clause for a column ref" do
159
- :test.asc.to_s(@ds).should == 'test ASC'
160
-
161
- :items__price.asc.to_s(@ds).should == 'items.price ASC'
162
- end
163
-
164
- specify "should format a ASC clause for a function" do
165
- :avg[:test].asc.to_s(@ds).should == 'avg(test) ASC'
166
- end
167
- end
168
-
169
- context "#as" do
170
- setup do
171
- @ds = Sequel::Dataset.new(nil)
172
- end
173
-
174
- specify "should format a AS clause for a column ref" do
175
- :test.as(:t).to_s(@ds).should == 'test AS t'
176
-
177
- :items__price.as(:p).to_s(@ds).should == 'items.price AS p'
178
- end
179
-
180
- specify "should format a AS clause for a function" do
181
- :avg[:test].as(:avg).to_s(@ds).should == 'avg(test) AS avg'
182
- end
183
-
184
- specify "should format a AS clause for a literal value" do
185
- 'abc'.as(:abc).to_s(@ds).should == "'abc' AS abc"
186
- end
187
- end
188
-
189
- context "Column references" do
190
- setup do
191
- @c = Class.new(Sequel::Dataset) do
192
- def quoted_identifier(c); "`#{c}`"; end
193
- end
194
- @ds = @c.new(nil)
195
- @ds.quote_identifiers = true
196
- end
197
-
198
- specify "should be quoted properly" do
199
- @ds.literal(:xyz).should == "`xyz`"
200
- @ds.literal(:xyz__abc).should == "`xyz`.`abc`"
201
-
202
- @ds.literal(:xyz.as(:x)).should == "`xyz` AS `x`"
203
- @ds.literal(:xyz__abc.as(:x)).should == "`xyz`.`abc` AS `x`"
204
-
205
- @ds.literal(:xyz___x).should == "`xyz` AS `x`"
206
- @ds.literal(:xyz__abc___x).should == "`xyz`.`abc` AS `x`"
207
- end
208
-
209
- specify "should be quoted properly in SQL functions" do
210
- @ds.literal(:avg[:xyz]).should == "avg(`xyz`)"
211
- @ds.literal(:avg[:xyz, 1]).should == "avg(`xyz`, 1)"
212
- @ds.literal(:avg[:xyz].as(:a)).should == "avg(`xyz`) AS `a`"
213
- end
214
-
215
- specify "should be quoted properly in ASC/DESC clauses" do
216
- @ds.literal(:xyz.asc).should == "`xyz` ASC"
217
- @ds.literal(:avg[:xyz, 1].desc).should == "avg(`xyz`, 1) DESC"
218
- end
219
-
220
- specify "should be quoted properly in a cast function" do
221
- @ds.literal(:x.cast_as(:integer)).should == "cast(`x` AS integer)"
222
- @ds.literal(:x__y.cast_as('varchar(20)')).should == "cast(`x`.`y` AS varchar(20))"
223
- end
224
- end
225
-
226
- context "Blob" do
227
- specify "#to_blob should return self" do
228
- blob = "x".to_blob
229
- blob.to_blob.object_id.should == blob.object_id
230
- end
231
- end
232
-
233
- context "Symbol#*" do
234
- setup do
235
- @ds = Sequel::Dataset.new(nil)
236
- end
237
-
238
- specify "should format a qualified wildcard if no argument" do
239
- :xyz.*.to_s(@ds).should == 'xyz.*'
240
- :abc.*.to_s(@ds).should == 'abc.*'
241
- end
242
-
243
- specify "should format a filter expression if an argument" do
244
- :xyz.*(3).to_s(@ds).should == '(xyz * 3)'
245
- :abc.*(5).to_s(@ds).should == '(abc * 5)'
246
- end
247
- end
248
-
249
- context "Symbol" do
250
- before do
251
- @ds = Sequel::Dataset.new(nil)
252
- @ds.quote_identifiers = true
253
- end
254
-
255
- specify "#identifier should format an identifier" do
256
- @ds.literal(:xyz__abc.identifier).should == '"XYZ__ABC"'
257
- end
258
-
259
- specify "#qualify should format a qualified column" do
260
- @ds.literal(:xyz.qualify(:abc)).should == '"ABC"."XYZ"'
261
- end
262
-
263
- specify "should be able to qualify an identifier" do
264
- @ds.literal(:xyz.identifier.qualify(:xyz__abc)).should == '"XYZ__ABC"."XYZ"'
265
- end
266
-
267
- specify "should be able to specify a schema.table.column" do
268
- @ds.literal(:column.qualify(:table__name.qualify(:schema))).should == '"SCHEMA"."TABLE__NAME"."COLUMN"'
269
- end
270
- end
271
-
272
- context "Symbol#to_column_ref" do
273
- setup do
274
- @ds = MockDataset.new(nil)
275
- end
276
-
277
- specify "should convert qualified symbol notation into dot notation" do
278
- :abc__def.to_column_ref(@ds).should == 'abc.def'
279
- end
280
-
281
- specify "should convert AS symbol notation into SQL AS notation" do
282
- :xyz___x.to_column_ref(@ds).should == 'xyz AS x'
283
- :abc__def___x.to_column_ref(@ds).should == 'abc.def AS x'
284
- end
285
-
286
- specify "should support names with digits" do
287
- :abc2.to_column_ref(@ds).should == 'abc2'
288
- :xx__yy3.to_column_ref(@ds).should == 'xx.yy3'
289
- :ab34__temp3_4ax.to_column_ref(@ds).should == 'ab34.temp3_4ax'
290
- :x1___y2.to_column_ref(@ds).should == 'x1 AS y2'
291
- :abc2__def3___ggg4.to_column_ref(@ds).should == 'abc2.def3 AS ggg4'
292
- end
293
-
294
- specify "should support upper case and lower case" do
295
- :ABC.to_column_ref(@ds).should == 'ABC'
296
- :Zvashtoy__aBcD.to_column_ref(@ds).should == 'Zvashtoy.aBcD'
297
- end
298
-
299
- specify "should support spaces inside column names" do
300
- @ds.quote_identifiers = true
301
- :"AB C".to_column_ref(@ds).should == '"AB C"'
302
- :"Zvas htoy__aB cD".to_column_ref(@ds).should == '"Zvas htoy"."aB cD"'
303
- :"aB cD___XX XX".to_column_ref(@ds).should == '"aB cD" AS "XX XX"'
304
- :"Zva shtoy__aB cD___XX XX".to_column_ref(@ds).should == '"Zva shtoy"."aB cD" AS "XX XX"'
305
- end
306
- end
307
-
308
- context "Symbol" do
309
- setup do
310
- @ds = Sequel::Dataset.new(nil)
311
- end
312
-
313
- specify "should support upper case outer functions" do
314
- :COUNT['1'].to_s(@ds).should == "COUNT('1')"
315
- end
316
-
317
- specify "should inhibit string literalization" do
318
- db = Sequel::Database.new
319
- ds = db[:t]
320
- ds.select(:COUNT['1']).sql.should == "SELECT COUNT('1') FROM t"
321
- end
322
-
323
- specify "should support cast method and its cast_as alias" do
324
- :abc.cast_as(:integer).to_s(@ds).should == "cast(abc AS integer)"
325
- :abc.cast(:integer).to_s(@ds).should == "cast(abc AS integer)"
326
- end
327
-
328
- specify "should support cast_numeric and cast_string" do
329
- x = :abc.cast_numeric
330
- x.should be_a_kind_of(Sequel::SQL::NumericExpression)
331
- x.to_s(@ds).should == "cast(abc AS integer)"
332
-
333
- x = :abc.cast_numeric(:real)
334
- x.should be_a_kind_of(Sequel::SQL::NumericExpression)
335
- x.to_s(@ds).should == "cast(abc AS real)"
336
-
337
- x = :abc.cast_string
338
- x.should be_a_kind_of(Sequel::SQL::StringExpression)
339
- x.to_s(@ds).should == "cast(abc AS text)"
340
-
341
- x = :abc.cast_string(:varchar)
342
- x.should be_a_kind_of(Sequel::SQL::StringExpression)
343
- x.to_s(@ds).should == "cast(abc AS varchar)"
344
- end
345
-
346
- specify "should support subscript access using | operator" do
347
- (:abc|1).to_s(@ds).should == 'abc[1]'
348
- (:abc|[1]).to_s(@ds).should == 'abc[1]'
349
- (:abc|[1, 2]).to_s(@ds).should == 'abc[1, 2]'
350
- (:abc|1|2).to_s(@ds).should == 'abc[1, 2]'
351
- end
352
-
353
- specify "should support SQL EXTRACT function via #extract " do
354
- :abc.extract(:year).to_s(@ds).should == "extract(year FROM abc)"
355
- end
356
- end
357
-
358
- context "String#to_time" do
359
- specify "should convert the string into a Time object" do
360
- "2007-07-11".to_time.should == Time.parse("2007-07-11")
361
- "06:30".to_time.should == Time.parse("06:30")
362
- end
363
-
364
- specify "should raise Error::InvalidValue for an invalid time" do
365
- proc {'0000-00-00'.to_time}.should raise_error(Sequel::Error::InvalidValue)
366
- end
367
- end
368
-
369
- context "String#to_date" do
370
- specify "should convert the string into a Date object" do
371
- "2007-07-11".to_date.should == Date.parse("2007-07-11")
372
- end
373
-
374
- specify "should raise Error::InvalidValue for an invalid date" do
375
- proc {'0000-00-00'.to_date}.should raise_error(Sequel::Error::InvalidValue)
376
- end
377
- end
378
-
379
- context "String#to_datetime" do
380
- specify "should convert the string into a DateTime object" do
381
- "2007-07-11 10:11:12a".to_datetime.should == DateTime.parse("2007-07-11 10:11:12a")
382
- end
383
-
384
- specify "should raise Error::InvalidValue for an invalid date" do
385
- proc {'0000-00-00'.to_datetime}.should raise_error(Sequel::Error::InvalidValue)
386
- end
387
- end
388
-
389
- context "String#to_sequel_time" do
390
- after do
391
- Sequel.datetime_class = Time
392
- end
393
-
394
- specify "should convert the string into a Time object by default" do
395
- "2007-07-11 10:11:12a".to_sequel_time.class.should == Time
396
- "2007-07-11 10:11:12a".to_sequel_time.should == Time.parse("2007-07-11 10:11:12a")
397
- end
398
-
399
- specify "should convert the string into a DateTime object if that is set" do
400
- Sequel.datetime_class = DateTime
401
- "2007-07-11 10:11:12a".to_sequel_time.class.should == DateTime
402
- "2007-07-11 10:11:12a".to_sequel_time.should == DateTime.parse("2007-07-11 10:11:12a")
403
- end
404
-
405
- specify "should raise Error::InvalidValue for an invalid time" do
406
- proc {'0000-00-00'.to_sequel_time}.should raise_error(Sequel::Error::InvalidValue)
407
- Sequel.datetime_class = DateTime
408
- proc {'0000-00-00'.to_sequel_time}.should raise_error(Sequel::Error::InvalidValue)
409
- end
410
- end
411
-
412
- context "Sequel::SQL::Function#==" do
413
- specify "should be true for functions with the same name and arguments, false otherwise" do
414
- a = :date[:t]
415
- b = :date[:t]
416
- a.should == b
417
- (a == b).should == true
418
- c = :date[:c]
419
- a.should_not == c
420
- (a == c).should == false
421
- d = :time[:c]
422
- a.should_not == d
423
- c.should_not == d
424
- (a == d).should == false
425
- (c == d).should == false
426
- end
427
- end