sequel 5.20.0 → 5.21.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -254,6 +254,12 @@ describe Sequel::Model, "rcte_tree" do
254
254
  @db.sqls.must_equal ["SELECT * FROM nodes",
255
255
  'WITH t AS (SELECT parent_id AS x_root_x, nodes.* FROM nodes WHERE ((parent_id IN (2, 6, 7)) AND (i = 1)) UNION ALL SELECT t.x_root_x, nodes.* FROM nodes INNER JOIN t ON (t.id = nodes.parent_id) WHERE (i = 1)) SELECT * FROM t AS nodes WHERE (i = 1)']
256
256
  end
257
+
258
+ it "should disallow eager graphing of ancestors and descendants" do
259
+ @c.plugin :rcte_tree
260
+ proc{@c.eager_graph(:ancestors)}.must_raise Sequel::Error
261
+ proc{@c.eager_graph(:descendants)}.must_raise Sequel::Error
262
+ end
257
263
  end
258
264
 
259
265
  describe Sequel::Model, "rcte_tree with composite keys" do
@@ -95,3 +95,41 @@ describe "Database#with_server multi threaded" do
95
95
  end
96
96
  end
97
97
 
98
+ describe "Database#with_server with invalid servers" do
99
+ def sqls(server)
100
+ @db.with_server(server) do
101
+ @db[:t].all
102
+ @db[:t].insert
103
+ @db[:t].update(:a=>1)
104
+ @db[:t].delete
105
+ end
106
+ @db.sqls
107
+ end
108
+
109
+ it "when single threaded and no servers_hash" do
110
+ @db = Sequel.mock(:single_threaded=>true, :servers=>{:a=>{}}).extension(:server_block)
111
+ sqls(:a).must_equal ["SELECT * FROM t -- a", "INSERT INTO t DEFAULT VALUES -- a", "UPDATE t SET a = 1 -- a", "DELETE FROM t -- a"]
112
+ sqls(:c).must_equal ["SELECT * FROM t", "INSERT INTO t DEFAULT VALUES", "UPDATE t SET a = 1", "DELETE FROM t"]
113
+ end
114
+
115
+ it "when multi-threaded and no servers_hash" do
116
+ @db = Sequel.mock(:servers=>{:a=>{}}).extension(:server_block)
117
+ sqls(:a).must_equal ["SELECT * FROM t -- a", "INSERT INTO t DEFAULT VALUES -- a", "UPDATE t SET a = 1 -- a", "DELETE FROM t -- a"]
118
+ sqls(:c).must_equal ["SELECT * FROM t", "INSERT INTO t DEFAULT VALUES", "UPDATE t SET a = 1", "DELETE FROM t"]
119
+ end
120
+
121
+ it "when single threaded and servers_hash" do
122
+ @db = Sequel.mock(:single_threaded=>true, :servers=>{:a=>{}, :b=>{}}, :servers_hash=>Hash.new{|_,k| raise}.merge!(:c=>:b)).extension(:server_block)
123
+ sqls(:a).must_equal ["SELECT * FROM t -- a", "INSERT INTO t DEFAULT VALUES -- a", "UPDATE t SET a = 1 -- a", "DELETE FROM t -- a"]
124
+ sqls(:c).must_equal ["SELECT * FROM t -- b", "INSERT INTO t DEFAULT VALUES -- b", "UPDATE t SET a = 1 -- b", "DELETE FROM t -- b"]
125
+ proc{sqls(:d)}.must_raise(RuntimeError)
126
+ end
127
+
128
+ it "when multi-threaded and servers_hash" do
129
+ @db = Sequel.mock(:servers=>{:a=>{}, :b=>{}}, :servers_hash=>Hash.new{|_,k| raise}.merge!(:c=>:b)).extension(:server_block)
130
+ sqls(:a).must_equal ["SELECT * FROM t -- a", "INSERT INTO t DEFAULT VALUES -- a", "UPDATE t SET a = 1 -- a", "DELETE FROM t -- a"]
131
+ sqls(:c).must_equal ["SELECT * FROM t -- b", "INSERT INTO t DEFAULT VALUES -- b", "UPDATE t SET a = 1 -- b", "DELETE FROM t -- b"]
132
+ proc{sqls(:d)}.must_raise(RuntimeError)
133
+ end
134
+ end
135
+
@@ -957,7 +957,7 @@ if DB.dataset.supports_window_functions?
957
957
  must_equal [{:sum=>110, :id=>1}, {:sum=>1100, :id=>2}, {:sum=>11000, :id=>3}, {:sum=>110000, :id=>4}, {:sum=>100000, :id=>5}, {:sum=>nil, :id=>6}]
958
958
  end
959
959
 
960
- cspecify "should give correct results for aggregate window functions with offsets for RANGES", :mssql, :sqlite, [proc{DB.server_version < 110000}, :postgres] do
960
+ cspecify "should give correct results for aggregate window functions with offsets for RANGES", :mssql, [proc{DB.sqlite_version < 32800}, :sqlite], [proc{DB.server_version < 110000}, :postgres] do
961
961
  @ds.select(:id){sum(:amount).over(:order=>:group_id, :frame=>{:type=>:range, :start=>1}).as(:sum)}.all.
962
962
  must_equal [{:sum=>111, :id=>1}, {:sum=>111, :id=>2}, {:sum=>111, :id=>3}, {:sum=>111111, :id=>4}, {:sum=>111111, :id=>5}, {:sum=>111111, :id=>6}]
963
963
  @ds.select(:id){sum(:amount).over(:order=>:group_id, :frame=>{:type=>:range, :start=>0, :end=>1}).as(:sum)}.all.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.20.0
4
+ version: 5.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-01 00:00:00.000000000 Z
11
+ date: 2019-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -204,6 +204,7 @@ extra_rdoc_files:
204
204
  - doc/release_notes/5.18.0.txt
205
205
  - doc/release_notes/5.19.0.txt
206
206
  - doc/release_notes/5.20.0.txt
207
+ - doc/release_notes/5.21.0.txt
207
208
  files:
208
209
  - CHANGELOG
209
210
  - MIT-LICENSE
@@ -295,6 +296,7 @@ files:
295
296
  - doc/release_notes/5.19.0.txt
296
297
  - doc/release_notes/5.2.0.txt
297
298
  - doc/release_notes/5.20.0.txt
299
+ - doc/release_notes/5.21.0.txt
298
300
  - doc/release_notes/5.3.0.txt
299
301
  - doc/release_notes/5.4.0.txt
300
302
  - doc/release_notes/5.5.0.txt