sequel 3.44.0 → 3.45.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/CHANGELOG +44 -0
  2. data/Rakefile +12 -4
  3. data/doc/reflection.rdoc +3 -3
  4. data/doc/release_notes/3.45.0.txt +179 -0
  5. data/doc/schema_modification.rdoc +1 -1
  6. data/doc/transactions.rdoc +23 -0
  7. data/lib/sequel/adapters/db2.rb +1 -0
  8. data/lib/sequel/adapters/ibmdb.rb +19 -3
  9. data/lib/sequel/adapters/jdbc.rb +15 -0
  10. data/lib/sequel/adapters/jdbc/derby.rb +1 -5
  11. data/lib/sequel/adapters/jdbc/h2.rb +1 -0
  12. data/lib/sequel/adapters/jdbc/hsqldb.rb +2 -1
  13. data/lib/sequel/adapters/jdbc/jtds.rb +5 -0
  14. data/lib/sequel/adapters/jdbc/mysql.rb +5 -0
  15. data/lib/sequel/adapters/jdbc/oracle.rb +7 -1
  16. data/lib/sequel/adapters/jdbc/sqlite.rb +1 -1
  17. data/lib/sequel/adapters/jdbc/transactions.rb +28 -1
  18. data/lib/sequel/adapters/mysql.rb +4 -0
  19. data/lib/sequel/adapters/mysql2.rb +5 -1
  20. data/lib/sequel/adapters/oracle.rb +18 -0
  21. data/lib/sequel/adapters/postgres.rb +11 -1
  22. data/lib/sequel/adapters/shared/access.rb +14 -2
  23. data/lib/sequel/adapters/shared/cubrid.rb +1 -11
  24. data/lib/sequel/adapters/shared/db2.rb +11 -6
  25. data/lib/sequel/adapters/shared/mssql.rb +10 -10
  26. data/lib/sequel/adapters/shared/mysql.rb +11 -1
  27. data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +17 -1
  28. data/lib/sequel/adapters/shared/oracle.rb +16 -15
  29. data/lib/sequel/adapters/shared/postgres.rb +91 -59
  30. data/lib/sequel/adapters/shared/sqlite.rb +1 -4
  31. data/lib/sequel/adapters/tinytds.rb +15 -0
  32. data/lib/sequel/connection_pool/threaded.rb +1 -1
  33. data/lib/sequel/core.rb +10 -0
  34. data/lib/sequel/database/connecting.rb +2 -0
  35. data/lib/sequel/database/misc.rb +46 -4
  36. data/lib/sequel/database/query.rb +33 -14
  37. data/lib/sequel/database/schema_methods.rb +0 -5
  38. data/lib/sequel/dataset/misc.rb +9 -0
  39. data/lib/sequel/dataset/mutation.rb +9 -7
  40. data/lib/sequel/dataset/sql.rb +13 -0
  41. data/lib/sequel/exceptions.rb +3 -0
  42. data/lib/sequel/extensions/connection_validator.rb +1 -1
  43. data/lib/sequel/extensions/date_arithmetic.rb +0 -8
  44. data/lib/sequel/extensions/eval_inspect.rb +2 -0
  45. data/lib/sequel/extensions/named_timezones.rb +18 -2
  46. data/lib/sequel/extensions/pg_array.rb +5 -1
  47. data/lib/sequel/extensions/pg_array_ops.rb +2 -0
  48. data/lib/sequel/extensions/pg_hstore.rb +2 -0
  49. data/lib/sequel/extensions/pg_hstore_ops.rb +2 -0
  50. data/lib/sequel/extensions/pg_json.rb +3 -1
  51. data/lib/sequel/extensions/pg_range.rb +2 -0
  52. data/lib/sequel/extensions/pg_range_ops.rb +2 -0
  53. data/lib/sequel/extensions/pg_row.rb +2 -0
  54. data/lib/sequel/extensions/pg_row_ops.rb +2 -0
  55. data/lib/sequel/extensions/query.rb +18 -22
  56. data/lib/sequel/model/associations.rb +3 -4
  57. data/lib/sequel/model/base.rb +2 -0
  58. data/lib/sequel/plugins/force_encoding.rb +2 -0
  59. data/lib/sequel/plugins/json_serializer.rb +155 -39
  60. data/lib/sequel/plugins/serialization.rb +14 -2
  61. data/lib/sequel/plugins/unlimited_update.rb +31 -0
  62. data/lib/sequel/plugins/validation_class_methods.rb +6 -4
  63. data/lib/sequel/plugins/xml_serializer.rb +133 -30
  64. data/lib/sequel/sql.rb +2 -0
  65. data/lib/sequel/timezones.rb +4 -0
  66. data/lib/sequel/version.rb +1 -1
  67. data/spec/adapters/mysql_spec.rb +0 -11
  68. data/spec/adapters/postgres_spec.rb +86 -54
  69. data/spec/adapters/spec_helper.rb +6 -0
  70. data/spec/core/connection_pool_spec.rb +16 -0
  71. data/spec/core/database_spec.rb +77 -1
  72. data/spec/core/dataset_spec.rb +30 -15
  73. data/spec/core/expression_filters_spec.rb +55 -13
  74. data/spec/core/mock_adapter_spec.rb +4 -0
  75. data/spec/core/schema_spec.rb +0 -2
  76. data/spec/core/spec_helper.rb +5 -0
  77. data/spec/core_extensions_spec.rb +33 -28
  78. data/spec/extensions/constraint_validations_spec.rb +2 -2
  79. data/spec/extensions/core_refinements_spec.rb +12 -12
  80. data/spec/extensions/json_serializer_spec.rb +137 -31
  81. data/spec/extensions/named_timezones_spec.rb +10 -0
  82. data/spec/extensions/pg_auto_parameterize_spec.rb +5 -0
  83. data/spec/extensions/pg_json_spec.rb +14 -0
  84. data/spec/extensions/pg_row_spec.rb +11 -0
  85. data/spec/extensions/pretty_table_spec.rb +2 -2
  86. data/spec/extensions/query_spec.rb +11 -8
  87. data/spec/extensions/serialization_spec.rb +20 -0
  88. data/spec/extensions/spec_helper.rb +8 -2
  89. data/spec/extensions/sql_expr_spec.rb +1 -1
  90. data/spec/extensions/unlimited_update_spec.rb +20 -0
  91. data/spec/extensions/xml_serializer_spec.rb +68 -16
  92. data/spec/integration/dataset_test.rb +28 -0
  93. data/spec/integration/spec_helper.rb +6 -0
  94. data/spec/integration/transaction_test.rb +39 -0
  95. data/spec/model/model_spec.rb +1 -1
  96. data/spec/sequel_coverage.rb +15 -0
  97. metadata +8 -3
@@ -8,14 +8,20 @@ if defined?(RSpec)
8
8
  end
9
9
  end
10
10
 
11
+ if ENV['COVERAGE']
12
+ require File.join(File.dirname(File.expand_path(__FILE__)), "../sequel_coverage")
13
+ SimpleCov.sequel_coverage(:filter=>%r{lib/sequel/(extensions|plugins)/\w+\.rb\z})
14
+ end
15
+
11
16
  unless Object.const_defined?('Sequel') && Sequel.const_defined?('Model')
12
17
  $:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/"))
13
18
  require 'sequel/no_core_ext'
14
19
  end
15
20
 
16
21
  begin
17
- # Attempt to load ActiveSupport inflector first, so Sequel inflector
18
- # can override it.
22
+ # Attempt to load ActiveSupport blank extension and inflector first, so Sequel
23
+ # can override them.
24
+ require 'active_support/core_ext/object/blank'
19
25
  require 'active_support/inflector'
20
26
  require 'active_support/core_ext/string/inflections'
21
27
  rescue LoadError
@@ -14,7 +14,7 @@ describe "Sequel sql_expr extension" do
14
14
  @ds.literal(s & true).should == "(foo AND 't')"
15
15
  @ds.literal(s < 1).should == "(foo < 1)"
16
16
  @ds.literal(s.sql_subscript(1)).should == "foo[1]"
17
- @ds.literal(s.like('a')).should == "(foo LIKE 'a')"
17
+ @ds.literal(s.like('a')).should == "(foo LIKE 'a' ESCAPE '\\')"
18
18
  @ds.literal(s.as(:a)).should == "foo AS a"
19
19
  @ds.literal(s.cast(Integer)).should == "CAST(foo AS integer)"
20
20
  @ds.literal(s.desc).should == "foo DESC"
@@ -0,0 +1,20 @@
1
+ require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper")
2
+
3
+ describe "Sequel::Plugins::UnlimitedUpdate" do
4
+ before do
5
+ @db = Sequel.mock(:host=>'mysql', :numrows=>1)
6
+ @c = Class.new(Sequel::Model(@db[:test]))
7
+ @c.columns :id, :name
8
+ @o = @c.load(:id=>1, :name=>'a')
9
+ @db.sqls
10
+ end
11
+
12
+ it "should remove limit from update dataset" do
13
+ @o.save
14
+ @db.sqls.should == ["UPDATE test SET name = 'a' WHERE (id = 1) LIMIT 1"]
15
+
16
+ @c.plugin :unlimited_update
17
+ @o.save
18
+ @db.sqls.should == ["UPDATE test SET name = 'a' WHERE (id = 1)"]
19
+ end
20
+ end
@@ -8,12 +8,14 @@ else
8
8
  describe "Sequel::Plugins::XmlSerializer" do
9
9
  before do
10
10
  class ::Artist < Sequel::Model
11
+ unrestrict_primary_key
11
12
  plugin :xml_serializer
12
13
  columns :id, :name
13
14
  @db_schema = {:id=>{:type=>:integer}, :name=>{:type=>:string}}
14
15
  one_to_many :albums
15
16
  end
16
17
  class ::Album < Sequel::Model
18
+ unrestrict_primary_key
17
19
  attr_accessor :blah
18
20
  plugin :xml_serializer
19
21
  columns :id, :name, :artist_id
@@ -39,9 +41,10 @@ describe "Sequel::Plugins::XmlSerializer" do
39
41
  it "should round trip successfully for namespaced models" do
40
42
  module XmlSerializerTest
41
43
  class Artist < Sequel::Model
42
- plugin :xml_serializer
43
- columns :id, :name
44
- @db_schema = {:id=>{:type=>:integer}, :name=>{:type=>:string}}
44
+ unrestrict_primary_key
45
+ plugin :xml_serializer
46
+ columns :id, :name
47
+ @db_schema = {:id=>{:type=>:integer}, :name=>{:type=>:string}}
45
48
  end
46
49
  end
47
50
  artist = XmlSerializerTest::Artist.load(:id=>2, :name=>'YJM')
@@ -69,8 +72,8 @@ describe "Sequel::Plugins::XmlSerializer" do
69
72
  end
70
73
 
71
74
  it "should handle the :include option for associations" do
72
- Artist.from_xml(@artist.to_xml(:include=>:albums)).albums.should == [@album]
73
- Album.from_xml(@album.to_xml(:include=>:artist)).artist.should == @artist
75
+ Artist.from_xml(@artist.to_xml(:include=>:albums), :associations=>:albums).albums.should == [@album]
76
+ Album.from_xml(@album.to_xml(:include=>:artist), :associations=>:artist).artist.should == @artist
74
77
  end
75
78
 
76
79
  it "should handle the :include option for arbitrary attributes" do
@@ -78,24 +81,28 @@ describe "Sequel::Plugins::XmlSerializer" do
78
81
  end
79
82
 
80
83
  it "should handle multiple inclusions using an array for the :include option" do
81
- a = Album.from_xml(@album.to_xml(:include=>[:blah, :artist]))
84
+ a = Album.from_xml(@album.to_xml(:include=>[:blah, :artist]), :associations=>:artist)
82
85
  a.blah.should == @album.blah
83
86
  a.artist.should == @artist
84
87
  end
85
88
 
86
89
  it "should handle cascading using a hash for the :include option" do
87
- Artist.from_xml(@artist.to_xml(:include=>{:albums=>{:include=>:artist}})).albums.map{|a| a.artist}.should == [@artist]
88
- Album.from_xml(@album.to_xml(:include=>{:artist=>{:include=>:albums}})).artist.albums.should == [@album]
90
+ Artist.from_xml(@artist.to_xml(:include=>{:albums=>{:include=>:artist}}), :associations=>{:albums=>{:associations=>:artist}}).albums.map{|a| a.artist}.should == [@artist]
91
+ Album.from_xml(@album.to_xml(:include=>{:artist=>{:include=>:albums}}), :associations=>{:artist=>{:associations=>:albums}}).artist.albums.should == [@album]
89
92
 
90
- Artist.from_xml(@artist.to_xml(:include=>{:albums=>{:only=>:name}})).albums.should == [Album.load(:name=>@album.name)]
91
- Album.from_xml(@album.to_xml(:include=>{:artist=>{:except=>:name}})).artist.should == Artist.load(:id=>@artist.id)
93
+ Artist.from_xml(@artist.to_xml(:include=>{:albums=>{:only=>:name}}), :associations=>{:albums=>{:fields=>%w'name'}}).albums.should == [Album.load(:name=>@album.name)]
94
+ Album.from_xml(@album.to_xml(:include=>{:artist=>{:except=>:name}}), :associations=>:artist).artist.should == Artist.load(:id=>@artist.id)
92
95
 
93
- Artist.from_xml(@artist.to_xml(:include=>{:albums=>{:include=>{:artist=>{:include=>:albums}}}})).albums.map{|a| a.artist.albums}.should == [[@album]]
94
- Album.from_xml(@album.to_xml(:include=>{:artist=>{:include=>{:albums=>{:only=>:name}}}})).artist.albums.should == [Album.load(:name=>@album.name)]
96
+ Artist.from_xml(@artist.to_xml(:include=>{:albums=>{:include=>{:artist=>{:include=>:albums}}}}), :associations=>{:albums=>{:associations=>{:artist=>{:associations=>:albums}}}}).albums.map{|a| a.artist.albums}.should == [[@album]]
97
+ Album.from_xml(@album.to_xml(:include=>{:artist=>{:include=>{:albums=>{:only=>:name}}}}), :associations=>{:artist=>{:associations=>{:albums=>{:fields=>%w'name'}}}}).artist.albums.should == [Album.load(:name=>@album.name)]
95
98
  end
96
99
 
100
+ it "should automatically cascade parsing for all associations if :all_associations is used" do
101
+ Artist.from_xml(@artist.to_xml(:include=>{:albums=>{:include=>:artist}}), :all_associations=>true).albums.map{|a| a.artist}.should == [@artist]
102
+ end
103
+
97
104
  it "should handle the :include option cascading with an empty hash" do
98
- Album.from_xml(@album.to_xml(:include=>{:artist=>{}})).artist.should == @artist
105
+ Album.from_xml(@album.to_xml(:include=>{:artist=>{}}), :associations=>:artist).artist.should == @artist
99
106
  Album.from_xml(@album.to_xml(:include=>{:blah=>{}})).blah.should == @album.blah
100
107
  end
101
108
 
@@ -153,7 +160,7 @@ describe "Sequel::Plugins::XmlSerializer" do
153
160
  album = @album
154
161
  Album.dataset.meta_def(:all){[album]}
155
162
  Album.array_from_xml(Album.to_xml).should == [@album]
156
- Album.array_from_xml(Album.to_xml(:include=>:artist)).map{|x| x.artist}.should == [@artist]
163
+ Album.array_from_xml(Album.to_xml(:include=>:artist), :associations=>:artist).map{|x| x.artist}.should == [@artist]
157
164
  Album.array_from_xml(Album.dataset.to_xml(:only=>:name)).should == [Album.load(:name=>@album.name)]
158
165
  end
159
166
 
@@ -162,10 +169,10 @@ describe "Sequel::Plugins::XmlSerializer" do
162
169
  Album.array_from_xml(Album.to_xml(:array=>[a])).should == [a]
163
170
 
164
171
  a.associations[:artist] = artist = Artist.load(:id=>3, :name=>'YJM')
165
- Album.array_from_xml(Album.to_xml(:array=>[a], :include=>:artist)).first.artist.should == artist
172
+ Album.array_from_xml(Album.to_xml(:array=>[a], :include=>:artist), :associations=>:artist).first.artist.should == artist
166
173
 
167
174
  artist.associations[:albums] = [a]
168
- x = Artist.array_from_xml(Artist.to_xml(:array=>[artist], :include=>:albums))
175
+ x = Artist.array_from_xml(Artist.to_xml(:array=>[artist], :include=>:albums), :associations=>:albums)
169
176
  x.should == [artist]
170
177
  x.first.albums.should == [a]
171
178
  end
@@ -173,5 +180,50 @@ describe "Sequel::Plugins::XmlSerializer" do
173
180
  it "should raise an error if the dataset does not have a row_proc" do
174
181
  proc{Album.dataset.naked.to_xml}.should raise_error(Sequel::Error)
175
182
  end
183
+
184
+ it "should have :associations option take precedence over :all_assocations" do
185
+ Artist.from_xml(@artist.to_xml(:include=>:albums), :associations=>[], :all_associations=>true, :fields=>[]).associations.should == {}
186
+ end
187
+
188
+ it "should allow overriding of :all_columns options in associated objects" do
189
+ Album.restrict_primary_key
190
+ Artist.from_xml(@artist.to_xml(:include=>:albums), :associations=>{:albums=>{:fields=>[:id, :name, :artist_id], :missing=>:raise}}, :all_columns=>true).albums
191
+ end
192
+
193
+ it "should allow setting columns that are restricted if :all_columns is used" do
194
+ Artist.restrict_primary_key
195
+ Artist.from_xml(@artist.to_xml, :all_columns=>true).should == @artist
196
+ end
197
+
198
+ it "should raise an error if using parsing empty xml" do
199
+ proc{Artist.from_xml("<?xml version=\"1.0\"?>\n")}.should raise_error(Sequel::Error)
200
+ proc{Artist.array_from_xml("<?xml version=\"1.0\"?>\n")}.should raise_error(Sequel::Error)
201
+ end
202
+
203
+ it "should raise an error if using :all_columns and non-column is in the XML" do
204
+ proc{Artist.from_xml("<?xml version=\"1.0\"?>\n<artist>\n <foo>bar</foo>\n <id>2</id>\n</artist>\n", :all_columns=>true)}.should raise_error(Sequel::Error)
205
+ end
206
+
207
+ it "should raise an error if attempting to set a restricted column and :all_columns is not used" do
208
+ Artist.restrict_primary_key
209
+ proc{Artist.from_xml(@artist.to_xml)}.should raise_error(Sequel::Error)
210
+ end
211
+
212
+ it "should raise an error if an unsupported association is passed in the :associations option" do
213
+ Artist.association_reflections.delete(:albums)
214
+ proc{Artist.from_xml(@artist.to_xml(:include=>:albums), :associations=>:albums)}.should raise_error(Sequel::Error)
215
+ end
216
+
217
+ it "should raise an error if using from_xml and XML represents an array" do
218
+ proc{Artist.from_xml(Artist.to_xml(:array=>[@artist]))}.should raise_error(Sequel::Error)
219
+ end
220
+
221
+ it "should raise an error if using array_from_xml and XML does not represent an array" do
222
+ proc{Artist.array_from_xml(@artist.to_xml)}.should raise_error(Sequel::Error)
223
+ end
224
+
225
+ it "should raise an error if using an unsupported :associations option" do
226
+ proc{Artist.from_xml(@artist.to_xml, :associations=>'')}.should raise_error(Sequel::Error)
227
+ end
176
228
  end
177
229
  end
@@ -1464,6 +1464,34 @@ describe "Dataset string methods" do
1464
1464
  @ds.exclude(Sequel.expr(:a).ilike('FOO', 'BAR')).all.should == []
1465
1465
  end
1466
1466
 
1467
+ it "#escape_like should escape any metacharacters" do
1468
+ @ds.insert('foo', 'bar')
1469
+ @ds.insert('foo.', 'bar..')
1470
+ @ds.insert('foo\\..', 'bar\\..')
1471
+ @ds.insert('foo\\_', 'bar\\%')
1472
+ @ds.insert('foo_', 'bar%')
1473
+ @ds.insert('foo_.', 'bar%.')
1474
+ @ds.insert('foo_..', 'bar%..')
1475
+ @ds.insert('[f#*?oo_]', '[bar%]')
1476
+ @ds.filter(Sequel.expr(:a).like(@ds.escape_like('foo_'))).select_order_map(:a).should == ['foo_']
1477
+ @ds.filter(Sequel.expr(:b).like(@ds.escape_like('bar%'))).select_order_map(:b).should == ['bar%']
1478
+ @ds.filter(Sequel.expr(:a).like(@ds.escape_like('foo\\_'))).select_order_map(:a).should == ['foo\\_']
1479
+ @ds.filter(Sequel.expr(:b).like(@ds.escape_like('bar\\%'))).select_order_map(:b).should == ['bar\\%']
1480
+ @ds.filter(Sequel.expr(:a).like(@ds.escape_like('[f#*?oo_]'))).select_order_map(:a).should == ['[f#*?oo_]']
1481
+ @ds.filter(Sequel.expr(:b).like(@ds.escape_like('[bar%]'))).select_order_map(:b).should == ['[bar%]']
1482
+ @ds.filter(Sequel.expr(:b).like("#{@ds.escape_like('bar%')}_")).select_order_map(:b).should == ['bar%.']
1483
+ @ds.filter(Sequel.expr(:b).like("#{@ds.escape_like('bar%')}%")).select_order_map(:b).should == ['bar%', 'bar%.', 'bar%..']
1484
+
1485
+ @ds.filter(Sequel.expr(:a).ilike(@ds.escape_like('Foo_'))).select_order_map(:a).should == ['foo_']
1486
+ @ds.filter(Sequel.expr(:b).ilike(@ds.escape_like('Bar%'))).select_order_map(:b).should == ['bar%']
1487
+ @ds.filter(Sequel.expr(:a).ilike(@ds.escape_like('Foo\\_'))).select_order_map(:a).should == ['foo\\_']
1488
+ @ds.filter(Sequel.expr(:b).ilike(@ds.escape_like('Bar\\%'))).select_order_map(:b).should == ['bar\\%']
1489
+ @ds.filter(Sequel.expr(:a).ilike(@ds.escape_like('[F#*?oo_]'))).select_order_map(:a).should == ['[f#*?oo_]']
1490
+ @ds.filter(Sequel.expr(:b).ilike(@ds.escape_like('[Bar%]'))).select_order_map(:b).should == ['[bar%]']
1491
+ @ds.filter(Sequel.expr(:b).ilike("#{@ds.escape_like('Bar%')}_")).select_order_map(:b).should == ['bar%.']
1492
+ @ds.filter(Sequel.expr(:b).ilike("#{@ds.escape_like('Bar%')}%")).select_order_map(:b).should == ['bar%', 'bar%.', 'bar%..']
1493
+ end
1494
+
1467
1495
  if INTEGRATION_DB.dataset.supports_regexp?
1468
1496
  it "#like with regexp return matching rows" do
1469
1497
  @ds.insert('foo', 'bar')
@@ -1,5 +1,11 @@
1
1
  require 'rubygems'
2
2
  require 'logger'
3
+
4
+ if ENV['COVERAGE']
5
+ require File.join(File.dirname(File.expand_path(__FILE__)), "../sequel_coverage")
6
+ SimpleCov.sequel_coverage(:group=>%r{lib/sequel/adapters})
7
+ end
8
+
3
9
  unless Object.const_defined?('Sequel')
4
10
  $:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/"))
5
11
  require 'sequel/no_core_ext'
@@ -310,3 +310,42 @@ if (! defined?(RUBY_ENGINE) or RUBY_ENGINE == 'ruby' or (RUBY_ENGINE == 'rbx' &&
310
310
  end
311
311
  end
312
312
  end
313
+
314
+ describe "Database transaction retrying" do
315
+ before(:all) do
316
+ @db = INTEGRATION_DB
317
+ @db.create_table!(:items, :engine=>'InnoDB'){String :a, :unique=>true, :null=>false}
318
+ @d = @db[:items]
319
+ end
320
+ before do
321
+ @d.delete
322
+ end
323
+ after(:all) do
324
+ @db.drop_table?(:items)
325
+ end
326
+
327
+ cspecify "should be supported using the :retry_on option", [:db2] do
328
+ @d.insert('b')
329
+ @d.insert('c')
330
+ s = 'a'
331
+ @db.transaction(:retry_on=>Sequel::ConstraintViolation) do
332
+ s = s.succ
333
+ @d.insert(s)
334
+ end
335
+ @d.select_order_map(:a).should == %w'b c d'
336
+ end
337
+
338
+ cspecify "should limit number of retries via the :num_retries option", [:db2] do
339
+ @d.insert('b')
340
+ @d.insert('c')
341
+ s = 'a'
342
+ lambda do
343
+ @db.transaction(:num_retries=>1, :retry_on=>Sequel::ConstraintViolation) do
344
+ s = s.succ
345
+ @d.insert(s)
346
+ end
347
+ end.should raise_error(Sequel::ConstraintViolation)
348
+ @d.select_order_map(:a).should == %w'b c'
349
+ end
350
+ end
351
+
@@ -394,7 +394,7 @@ describe Sequel::Model, ".find" do
394
394
  MODEL_DB.sqls.should == ["SELECT * FROM items WHERE (name = 'sharon') LIMIT 1"]
395
395
 
396
396
  @c.find(Sequel.expr(:name).like('abc%')).should be_a_kind_of(@c)
397
- MODEL_DB.sqls.should == ["SELECT * FROM items WHERE (name LIKE 'abc%') LIMIT 1"]
397
+ MODEL_DB.sqls.should == ["SELECT * FROM items WHERE (name LIKE 'abc%' ESCAPE '\\') LIMIT 1"]
398
398
  end
399
399
 
400
400
  specify "should accept filter blocks" do
@@ -0,0 +1,15 @@
1
+ require 'coverage'
2
+ require 'simplecov'
3
+
4
+ def SimpleCov.sequel_coverage(opts = {})
5
+ start do
6
+ add_filter "/spec/"
7
+ add_group('Missing-Revelent'){|src| src.filename =~ opts[:group] && src.covered_percent < 100} if opts[:group]
8
+ add_group('Missing'){|src| src.covered_percent < 100}
9
+ add_group('Covered'){|src| src.covered_percent == 100}
10
+ add_filter{|src| src.filename !~ opts[:filter]} if opts[:filter]
11
+ yield self if block_given?
12
+ end
13
+ end
14
+
15
+ ENV.delete('COVERAGE')
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.44.0
4
+ version: 3.45.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: 2013-02-04 00:00:00.000000000 Z
12
+ date: 2013-03-01 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: The Database Toolkit for Ruby
15
15
  email: code@jeremyevans.net
@@ -107,6 +107,7 @@ extra_rdoc_files:
107
107
  - doc/release_notes/3.42.0.txt
108
108
  - doc/release_notes/3.43.0.txt
109
109
  - doc/release_notes/3.44.0.txt
110
+ - doc/release_notes/3.45.0.txt
110
111
  files:
111
112
  - MIT-LICENSE
112
113
  - CHANGELOG
@@ -188,6 +189,7 @@ files:
188
189
  - doc/release_notes/3.42.0.txt
189
190
  - doc/release_notes/3.43.0.txt
190
191
  - doc/release_notes/3.44.0.txt
192
+ - doc/release_notes/3.45.0.txt
191
193
  - doc/sharding.rdoc
192
194
  - doc/sql.rdoc
193
195
  - doc/validations.rdoc
@@ -265,6 +267,7 @@ files:
265
267
  - spec/extensions/association_pks_spec.rb
266
268
  - spec/extensions/json_serializer_spec.rb
267
269
  - spec/extensions/eager_each_spec.rb
270
+ - spec/extensions/pg_json_spec.rb
268
271
  - spec/extensions/list_spec.rb
269
272
  - spec/extensions/tree_spec.rb
270
273
  - spec/extensions/xml_serializer_spec.rb
@@ -293,7 +296,6 @@ files:
293
296
  - spec/extensions/static_cache_spec.rb
294
297
  - spec/extensions/query_literals_spec.rb
295
298
  - spec/extensions/dirty_spec.rb
296
- - spec/extensions/pg_json_spec.rb
297
299
  - spec/extensions/pg_inet_spec.rb
298
300
  - spec/extensions/eval_inspect_spec.rb
299
301
  - spec/extensions/pg_range_spec.rb
@@ -311,6 +313,7 @@ files:
311
313
  - spec/extensions/validation_class_methods_spec.rb
312
314
  - spec/extensions/meta_def_spec.rb
313
315
  - spec/extensions/core_refinements_spec.rb
316
+ - spec/extensions/unlimited_update_spec.rb
314
317
  - spec/integration/associations_test.rb
315
318
  - spec/integration/database_test.rb
316
319
  - spec/integration/dataset_test.rb
@@ -384,6 +387,7 @@ files:
384
387
  - spec/files/transaction_unspecified_migrations/001_create_alt_basic.rb
385
388
  - spec/files/transaction_unspecified_migrations/002_create_basic.rb
386
389
  - spec/core_extensions_spec.rb
390
+ - spec/sequel_coverage.rb
387
391
  - lib/sequel.rb
388
392
  - lib/sequel/adapters/ado.rb
389
393
  - lib/sequel/adapters/ado/mssql.rb
@@ -576,6 +580,7 @@ files:
576
580
  - lib/sequel/plugins/pg_row.rb
577
581
  - lib/sequel/plugins/pg_typecast_on_load.rb
578
582
  - lib/sequel/plugins/constraint_validations.rb
583
+ - lib/sequel/plugins/unlimited_update.rb
579
584
  - lib/sequel/timezones.rb
580
585
  - lib/sequel/ast_transformer.rb
581
586
  - lib/sequel/no_core_ext.rb