sequel 4.9.0 → 4.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +79 -1
- data/MIT-LICENSE +1 -1
- data/README.rdoc +1 -1
- data/Rakefile +2 -12
- data/bin/sequel +1 -0
- data/doc/advanced_associations.rdoc +82 -25
- data/doc/association_basics.rdoc +21 -22
- data/doc/core_extensions.rdoc +1 -1
- data/doc/opening_databases.rdoc +7 -0
- data/doc/release_notes/4.10.0.txt +226 -0
- data/doc/security.rdoc +1 -0
- data/doc/testing.rdoc +7 -7
- data/doc/transactions.rdoc +8 -0
- data/lib/sequel/adapters/jdbc.rb +160 -168
- data/lib/sequel/adapters/jdbc/db2.rb +17 -18
- data/lib/sequel/adapters/jdbc/derby.rb +5 -28
- data/lib/sequel/adapters/jdbc/h2.rb +11 -22
- data/lib/sequel/adapters/jdbc/hsqldb.rb +31 -18
- data/lib/sequel/adapters/jdbc/jtds.rb +0 -15
- data/lib/sequel/adapters/jdbc/oracle.rb +36 -35
- data/lib/sequel/adapters/jdbc/postgresql.rb +72 -90
- data/lib/sequel/adapters/jdbc/sqlanywhere.rb +18 -16
- data/lib/sequel/adapters/jdbc/sqlite.rb +7 -0
- data/lib/sequel/adapters/jdbc/sqlserver.rb +10 -30
- data/lib/sequel/adapters/jdbc/transactions.rb +5 -6
- data/lib/sequel/adapters/openbase.rb +1 -7
- data/lib/sequel/adapters/postgres.rb +1 -1
- data/lib/sequel/adapters/shared/access.rb +3 -6
- data/lib/sequel/adapters/shared/cubrid.rb +24 -9
- data/lib/sequel/adapters/shared/db2.rb +13 -5
- data/lib/sequel/adapters/shared/firebird.rb +16 -16
- data/lib/sequel/adapters/shared/informix.rb +2 -5
- data/lib/sequel/adapters/shared/mssql.rb +72 -63
- data/lib/sequel/adapters/shared/mysql.rb +72 -40
- data/lib/sequel/adapters/shared/oracle.rb +27 -15
- data/lib/sequel/adapters/shared/postgres.rb +24 -44
- data/lib/sequel/adapters/shared/progress.rb +1 -5
- data/lib/sequel/adapters/shared/sqlanywhere.rb +26 -18
- data/lib/sequel/adapters/shared/sqlite.rb +21 -6
- data/lib/sequel/adapters/utils/emulate_offset_with_reverse_and_count.rb +8 -1
- data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +8 -2
- data/lib/sequel/adapters/utils/split_alter_table.rb +8 -0
- data/lib/sequel/core.rb +14 -9
- data/lib/sequel/database/dataset_defaults.rb +1 -0
- data/lib/sequel/database/misc.rb +12 -0
- data/lib/sequel/database/query.rb +4 -1
- data/lib/sequel/database/schema_methods.rb +3 -2
- data/lib/sequel/database/transactions.rb +47 -17
- data/lib/sequel/dataset/features.rb +12 -2
- data/lib/sequel/dataset/mutation.rb +2 -0
- data/lib/sequel/dataset/placeholder_literalizer.rb +12 -4
- data/lib/sequel/dataset/prepared_statements.rb +6 -0
- data/lib/sequel/dataset/query.rb +1 -1
- data/lib/sequel/dataset/sql.rb +132 -70
- data/lib/sequel/extensions/columns_introspection.rb +1 -1
- data/lib/sequel/extensions/null_dataset.rb +8 -4
- data/lib/sequel/extensions/pg_array.rb +4 -4
- data/lib/sequel/extensions/pg_row.rb +1 -0
- data/lib/sequel/model/associations.rb +468 -188
- data/lib/sequel/model/base.rb +88 -13
- data/lib/sequel/plugins/association_pks.rb +23 -64
- data/lib/sequel/plugins/auto_validations.rb +3 -2
- data/lib/sequel/plugins/dataset_associations.rb +1 -3
- data/lib/sequel/plugins/many_through_many.rb +18 -65
- data/lib/sequel/plugins/pg_array_associations.rb +97 -86
- data/lib/sequel/plugins/prepared_statements.rb +2 -1
- data/lib/sequel/plugins/prepared_statements_associations.rb +36 -27
- data/lib/sequel/plugins/rcte_tree.rb +12 -16
- data/lib/sequel/plugins/sharding.rb +21 -3
- data/lib/sequel/plugins/single_table_inheritance.rb +2 -1
- data/lib/sequel/plugins/subclasses.rb +1 -9
- data/lib/sequel/plugins/tactical_eager_loading.rb +9 -0
- data/lib/sequel/plugins/tree.rb +2 -2
- data/lib/sequel/plugins/validation_class_methods.rb +1 -1
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/mssql_spec.rb +57 -15
- data/spec/adapters/mysql_spec.rb +11 -0
- data/spec/bin_spec.rb +2 -2
- data/spec/core/database_spec.rb +38 -4
- data/spec/core/dataset_spec.rb +45 -7
- data/spec/core/placeholder_literalizer_spec.rb +17 -0
- data/spec/core/schema_spec.rb +6 -1
- data/spec/extensions/active_model_spec.rb +18 -9
- data/spec/extensions/association_pks_spec.rb +20 -18
- data/spec/extensions/association_proxies_spec.rb +9 -9
- data/spec/extensions/auto_validations_spec.rb +6 -0
- data/spec/extensions/columns_introspection_spec.rb +1 -0
- data/spec/extensions/constraint_validations_spec.rb +3 -1
- data/spec/extensions/many_through_many_spec.rb +191 -111
- data/spec/extensions/pg_array_associations_spec.rb +133 -103
- data/spec/extensions/prepared_statements_associations_spec.rb +23 -4
- data/spec/extensions/rcte_tree_spec.rb +35 -27
- data/spec/extensions/sequel_3_dataset_methods_spec.rb +0 -1
- data/spec/extensions/sharding_spec.rb +2 -2
- data/spec/extensions/tactical_eager_loading_spec.rb +4 -0
- data/spec/extensions/to_dot_spec.rb +1 -0
- data/spec/extensions/touch_spec.rb +2 -2
- data/spec/integration/associations_test.rb +130 -37
- data/spec/integration/dataset_test.rb +17 -0
- data/spec/integration/model_test.rb +17 -0
- data/spec/integration/schema_test.rb +14 -0
- data/spec/integration/transaction_test.rb +25 -1
- data/spec/model/association_reflection_spec.rb +63 -24
- data/spec/model/associations_spec.rb +104 -57
- data/spec/model/base_spec.rb +14 -1
- data/spec/model/class_dataset_methods_spec.rb +1 -0
- data/spec/model/eager_loading_spec.rb +221 -74
- data/spec/model/model_spec.rb +119 -1
- metadata +4 -2
data/spec/model/model_spec.rb
CHANGED
@@ -521,7 +521,125 @@ describe Sequel::Model, ".finder" do
|
|
521
521
|
@db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 LIMIT 1"]
|
522
522
|
end
|
523
523
|
|
524
|
-
specify "should raise error when
|
524
|
+
specify "should raise error when calling with the wrong arity" do
|
525
|
+
@c.finder :foo
|
526
|
+
proc{@c.first_foo(1)}.should raise_error
|
527
|
+
proc{@c.first_foo(1,2,3)}.should raise_error
|
528
|
+
end
|
529
|
+
end
|
530
|
+
|
531
|
+
describe Sequel::Model, ".prepared_finder" do
|
532
|
+
before do
|
533
|
+
@h = {:id=>1}
|
534
|
+
@db = Sequel.mock(:fetch=>@h)
|
535
|
+
@db.extend_datasets do
|
536
|
+
def select_sql
|
537
|
+
sql = super
|
538
|
+
sql << ' -- prepared' if is_a?(Sequel::Dataset::PreparedStatementMethods)
|
539
|
+
sql
|
540
|
+
end
|
541
|
+
end
|
542
|
+
@c = Class.new(Sequel::Model(@db[:items]))
|
543
|
+
@c.instance_eval do
|
544
|
+
def foo(a, b)
|
545
|
+
where(:bar=>a).order(b)
|
546
|
+
end
|
547
|
+
end
|
548
|
+
@o = @c.load(@h)
|
549
|
+
@db.sqls
|
550
|
+
end
|
551
|
+
|
552
|
+
specify "should create a method that calls the method given and returns the first instance" do
|
553
|
+
@c.prepared_finder :foo
|
554
|
+
@c.first_foo(1, 2).should == @o
|
555
|
+
@c.first_foo(3, 4).should == @o
|
556
|
+
@db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 LIMIT 1 -- prepared"]
|
557
|
+
end
|
558
|
+
|
559
|
+
specify "should work correctly when subclassing" do
|
560
|
+
@c.prepared_finder(:foo)
|
561
|
+
@sc = Class.new(@c)
|
562
|
+
@sc.set_dataset :foos
|
563
|
+
@db.sqls
|
564
|
+
@sc.first_foo(1, 2).should == @sc.load(@h)
|
565
|
+
@sc.first_foo(3, 4).should == @sc.load(@h)
|
566
|
+
@db.sqls.should == ["SELECT * FROM foos WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared", "SELECT * FROM foos WHERE (bar = 3) ORDER BY 4 LIMIT 1 -- prepared"]
|
567
|
+
end
|
568
|
+
|
569
|
+
specify "should work correctly when dataset is modified" do
|
570
|
+
@c.prepared_finder(:foo)
|
571
|
+
@c.first_foo(1, 2).should == @o
|
572
|
+
@c.set_dataset :foos
|
573
|
+
@c.first_foo(3, 4).should == @o
|
574
|
+
@db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared", "SELECT * FROM foos LIMIT 1", "SELECT * FROM foos WHERE (bar = 3) ORDER BY 4 LIMIT 1 -- prepared"]
|
575
|
+
end
|
576
|
+
|
577
|
+
specify "should create a method based on the given block if no method symbol provided" do
|
578
|
+
@c.prepared_finder(:name=>:first_foo){|a1| where(:id=>a1).limit(1)}
|
579
|
+
@c.first_foo(1).should == @o
|
580
|
+
@db.sqls.should == ["SELECT * FROM items WHERE (id = 1) LIMIT 1 -- prepared"]
|
581
|
+
end
|
582
|
+
|
583
|
+
specify "should raise an error if both a block and method symbol given" do
|
584
|
+
proc{@c.prepared_finder(:foo, :name=>:first_foo){|pl, ds| ds.where(pl.arg)}}.should raise_error(Sequel::Error)
|
585
|
+
end
|
586
|
+
|
587
|
+
specify "should raise an error if two option hashes are provided" do
|
588
|
+
proc{@c.prepared_finder({:name2=>:foo}, :name=>:first_foo){|pl, ds| ds.where(pl.arg)}}.should raise_error(Sequel::Error)
|
589
|
+
end
|
590
|
+
|
591
|
+
specify "should support :type option" do
|
592
|
+
@c.prepared_finder :foo, :type=>:all
|
593
|
+
@c.prepared_finder :foo, :type=>:each
|
594
|
+
|
595
|
+
a = []
|
596
|
+
@c.all_foo(1, 2){|r| a << r}.should == [@o]
|
597
|
+
a.should == [@o]
|
598
|
+
|
599
|
+
a = []
|
600
|
+
@c.each_foo(3, 4){|r| a << r}
|
601
|
+
a.should == [@o]
|
602
|
+
|
603
|
+
@db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 -- prepared", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 -- prepared"]
|
604
|
+
end
|
605
|
+
|
606
|
+
specify "should support :name option" do
|
607
|
+
@c.prepared_finder :foo, :name=>:find_foo
|
608
|
+
@c.find_foo(1, 2).should == @o
|
609
|
+
@c.find_foo(3, 4).should == @o
|
610
|
+
@db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 LIMIT 1 -- prepared"]
|
611
|
+
end
|
612
|
+
|
613
|
+
specify "should support :arity option" do
|
614
|
+
def @c.foobar(*b)
|
615
|
+
ds = dataset
|
616
|
+
b.each_with_index do |a, i|
|
617
|
+
ds = ds.where(i=>a)
|
618
|
+
end
|
619
|
+
ds
|
620
|
+
end
|
621
|
+
@c.prepared_finder :foobar, :arity=>1, :name=>:find_foobar_1
|
622
|
+
@c.prepared_finder :foobar, :arity=>2, :name=>:find_foobar_2
|
623
|
+
@c.find_foobar_1(:a)
|
624
|
+
@c.find_foobar_2(:a, :b)
|
625
|
+
@db.sqls.should == ["SELECT * FROM items WHERE (0 = a) LIMIT 1 -- prepared", "SELECT * FROM items WHERE ((0 = a) AND (1 = b)) LIMIT 1 -- prepared"]
|
626
|
+
end
|
627
|
+
|
628
|
+
specify "should support :mod option" do
|
629
|
+
m = Module.new
|
630
|
+
@c.prepared_finder :foo, :mod=>m
|
631
|
+
proc{@c.first_foo}.should raise_error
|
632
|
+
@c.extend m
|
633
|
+
@c.first_foo(1, 2).should == @o
|
634
|
+
@c.first_foo(3, 4).should == @o
|
635
|
+
@db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 LIMIT 1 -- prepared"]
|
636
|
+
end
|
637
|
+
|
638
|
+
specify "should handle models with names" do
|
639
|
+
def @c.name; 'foobar' end
|
640
|
+
@c.prepared_finder :foo
|
641
|
+
@c.first_foo(1, 2).should == @o
|
642
|
+
@db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared"]
|
525
643
|
end
|
526
644
|
end
|
527
645
|
|
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: 4.
|
4
|
+
version: 4.10.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: 2014-
|
11
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The Database Toolkit for Ruby
|
14
14
|
email: code@jeremyevans.net
|
@@ -126,6 +126,7 @@ extra_rdoc_files:
|
|
126
126
|
- doc/release_notes/4.7.0.txt
|
127
127
|
- doc/release_notes/4.8.0.txt
|
128
128
|
- doc/release_notes/4.9.0.txt
|
129
|
+
- doc/release_notes/4.10.0.txt
|
129
130
|
files:
|
130
131
|
- CHANGELOG
|
131
132
|
- MIT-LICENSE
|
@@ -222,6 +223,7 @@ files:
|
|
222
223
|
- doc/release_notes/3.9.0.txt
|
223
224
|
- doc/release_notes/4.0.0.txt
|
224
225
|
- doc/release_notes/4.1.0.txt
|
226
|
+
- doc/release_notes/4.10.0.txt
|
225
227
|
- doc/release_notes/4.2.0.txt
|
226
228
|
- doc/release_notes/4.3.0.txt
|
227
229
|
- doc/release_notes/4.4.0.txt
|