sequel-impala 1.0.1 → 1.1.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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -0
  3. data/lib/impala.rb +14 -6
  4. data/lib/impala/connection.rb +46 -23
  5. data/lib/impala/cursor.rb +48 -4
  6. data/lib/impala/progress_reporter.rb +40 -0
  7. data/lib/impala/protocol/beeswax_constants.rb +1 -1
  8. data/lib/impala/protocol/beeswax_service.rb +1 -20
  9. data/lib/impala/protocol/beeswax_types.rb +1 -1
  10. data/lib/impala/protocol/exec_stats_constants.rb +13 -0
  11. data/lib/impala/protocol/exec_stats_types.rb +133 -0
  12. data/lib/impala/protocol/facebook_service.rb +3 -3
  13. data/lib/impala/protocol/fb303_constants.rb +1 -1
  14. data/lib/impala/protocol/fb303_types.rb +1 -1
  15. data/lib/impala/protocol/hive_metastore_constants.rb +1 -1
  16. data/lib/impala/protocol/hive_metastore_types.rb +1 -1
  17. data/lib/impala/protocol/impala_hive_server2_service.rb +111 -3
  18. data/lib/impala/protocol/impala_service.rb +67 -1
  19. data/lib/impala/protocol/impala_service_constants.rb +1 -1
  20. data/lib/impala/protocol/impala_service_types.rb +109 -7
  21. data/lib/impala/protocol/status_constants.rb +1 -1
  22. data/lib/impala/protocol/status_types.rb +1 -1
  23. data/lib/impala/protocol/t_c_l_i_service.rb +884 -724
  24. data/lib/impala/protocol/t_c_l_i_service_constants.rb +72 -0
  25. data/lib/impala/protocol/t_c_l_i_service_types.rb +1799 -0
  26. data/lib/impala/protocol/thrift_hive_metastore.rb +1 -1
  27. data/lib/impala/protocol/types_constants.rb +13 -0
  28. data/lib/impala/protocol/types_types.rb +332 -0
  29. data/lib/impala/sasl_transport.rb +117 -0
  30. data/lib/impala/thrift_patch.rb +42 -0
  31. data/lib/rbhive/connection.rb +25 -25
  32. data/lib/rbhive/explain_result.rb +9 -9
  33. data/lib/rbhive/schema_definition.rb +12 -12
  34. data/lib/rbhive/t_c_l_i_connection.rb +28 -26
  35. data/lib/rbhive/t_c_l_i_schema_definition.rb +1 -1
  36. data/lib/rbhive/table_schema.rb +1 -1
  37. data/lib/sequel/adapters/impala.rb +63 -6
  38. data/lib/sequel/adapters/jdbc/hive2.rb +1 -1
  39. data/lib/sequel/adapters/rbhive.rb +3 -2
  40. data/lib/sequel/adapters/shared/impala.rb +133 -25
  41. data/lib/thrift/sasl_client_transport.rb +2 -2
  42. data/lib/thrift/thrift_hive.rb +2 -2
  43. data/lib/thrift/thrift_hive_metastore.rb +2 -2
  44. data/spec/dataset_test.rb +85 -85
  45. data/spec/files/bad_timestamped_migrations/1273253849_create_sessions.rb +1 -1
  46. data/spec/files/bad_timestamped_migrations/1273253851_create_nodes.rb +1 -1
  47. data/spec/files/convert_to_timestamp_migrations/001_create_sessions.rb +1 -1
  48. data/spec/files/convert_to_timestamp_migrations/002_create_nodes.rb +1 -1
  49. data/spec/files/convert_to_timestamp_migrations/1273253850_create_artists.rb +1 -1
  50. data/spec/files/convert_to_timestamp_migrations/1273253852_create_albums.rb +1 -1
  51. data/spec/files/duplicate_timestamped_migrations/1273253849_create_sessions.rb +1 -1
  52. data/spec/files/duplicate_timestamped_migrations/1273253853_create_nodes.rb +1 -1
  53. data/spec/files/integer_migrations/001_create_sessions.rb +1 -1
  54. data/spec/files/integer_migrations/002_create_nodes.rb +1 -1
  55. data/spec/files/interleaved_timestamped_migrations/1273253849_create_sessions.rb +1 -1
  56. data/spec/files/interleaved_timestamped_migrations/1273253850_create_artists.rb +1 -1
  57. data/spec/files/interleaved_timestamped_migrations/1273253851_create_nodes.rb +1 -1
  58. data/spec/files/interleaved_timestamped_migrations/1273253852_create_albums.rb +1 -1
  59. data/spec/files/timestamped_migrations/1273253849_create_sessions.rb +1 -1
  60. data/spec/files/timestamped_migrations/1273253851_create_nodes.rb +1 -1
  61. data/spec/migrator_test.rb +2 -2
  62. data/spec/prepared_statement_test.rb +12 -12
  63. data/spec/schema_test.rb +6 -6
  64. data/spec/type_test.rb +8 -8
  65. metadata +30 -11
  66. data/CHANGELOG +0 -19
  67. data/lib/impala/protocol/cli_service_constants.rb +0 -60
  68. data/lib/impala/protocol/cli_service_types.rb +0 -1452
@@ -11,7 +11,7 @@ require_relative 'hive_service_types'
11
11
  module Hive
12
12
  module Thrift
13
13
  module ThriftHive
14
- class Client < ::ThriftHiveMetastore::Client
14
+ class Client < ::ThriftHiveMetastore::Client
15
15
  include ::Thrift::Client
16
16
 
17
17
  def execute(query)
@@ -143,7 +143,7 @@ module Hive
143
143
 
144
144
  end
145
145
 
146
- class Processor < ::ThriftHiveMetastore::Processor
146
+ class Processor < ::ThriftHiveMetastore::Processor
147
147
  include ::Thrift::Processor
148
148
 
149
149
  def process_execute(seqid, iprot, oprot)
@@ -9,7 +9,7 @@ require_relative 'facebook_service'
9
9
  require_relative 'hive_metastore_types'
10
10
 
11
11
  module ThriftHiveMetastore
12
- class Client < ::FacebookService::Client
12
+ class Client < ::FacebookService::Client
13
13
  include ::Thrift::Client
14
14
 
15
15
  def create_database(database)
@@ -959,7 +959,7 @@ module ThriftHiveMetastore
959
959
 
960
960
  end
961
961
 
962
- class Processor < ::FacebookService::Processor
962
+ class Processor < ::FacebookService::Processor
963
963
  include ::Thrift::Processor
964
964
 
965
965
  def process_create_database(seqid, iprot, oprot)
@@ -16,8 +16,8 @@ describe "Simple Dataset operations" do
16
16
  end
17
17
  @ds << {:id=>1, :number=>20}
18
18
  @ds << {:id=>2, :number=>30}
19
- @ds.order(:number).all.must_equal [{:id => 1, :number=>20}, {:id => 2, :number=>30}]
20
- end
19
+ @ds.order(:number).all.must_equal [{:id => 1, :number=>20}, {:id => 2, :number=>30}]
20
+ end
21
21
 
22
22
  it "should have insert work correctly with static SQL" do
23
23
  @db.create_table!(:items) do
@@ -25,7 +25,7 @@ describe "Simple Dataset operations" do
25
25
  Integer :number
26
26
  end
27
27
  @db["INSERT INTO #{@ds.literal(:items)} (id, number) VALUES (2, 30)"].insert
28
- @ds.all.must_equal [{:id => 2, :number=>30}]
28
+ @ds.all.must_equal [{:id => 2, :number=>30}]
29
29
  end
30
30
 
31
31
  it "should have insert work correctly when inserting a row with all NULL values" do
@@ -108,7 +108,7 @@ describe "Simple Dataset operations" do
108
108
  @ds.cross_join(:items2___i).cross_join(@db[:items2].select(:id2___id3, :number2___number3)).order(:id).limit(2, 1).all.must_equal []
109
109
  @db.drop_table(:items2)
110
110
  end
111
-
111
+
112
112
  end
113
113
 
114
114
  describe "Simple Dataset operations" do
@@ -165,26 +165,26 @@ describe "Simple Dataset operations" do
165
165
  @ds.single_record.must_equal(:id=>1, :number=>10)
166
166
  @ds.single_record!.must_equal(:id=>1, :number=>10)
167
167
  end
168
-
168
+
169
169
  it "should work correctly when returning from each without iterating over the whole result set" do
170
170
  @ds.order(:id).each{|v| break v}.must_equal(:id=>1, :number=>10)
171
171
  @ds.reverse(:id).each{|v| break v}.must_equal(:id=>1, :number=>10)
172
172
  end
173
-
173
+
174
174
  it "should fetch a single value correctly" do
175
175
  @ds.get(:id).must_equal 1
176
176
  @ds.select(:id).single_value.must_equal 1
177
177
  @ds.select(:id).single_value!.must_equal 1
178
178
  end
179
-
179
+
180
180
  it "should have distinct work with limit" do
181
181
  @ds.limit(1).distinct.all.must_equal [{:id=>1, :number=>10}]
182
182
  end
183
-
183
+
184
184
  it "should fetch correctly with a limit" do
185
185
  @ds.order(:id).limit(1).all.must_equal [{:id=>1, :number=>10}]
186
186
  end
187
-
187
+
188
188
  it "should fetch correctly with a limit and offset" do
189
189
  @ds.order(:id).limit(1, 0).all.must_equal [{:id=>1, :number=>10}]
190
190
  @ds.order(:id).limit(1, 1).all.must_equal []
@@ -199,7 +199,7 @@ describe "Simple Dataset operations" do
199
199
  @ds.order(:id).limit(1).offset(0).all.must_equal [{:id=>1, :number=>10}]
200
200
  @ds.order(:id).limit(1).offset(1).all.must_equal []
201
201
  end
202
-
202
+
203
203
  it "should provide correct columns when using a limit and offset" do
204
204
  ds = @ds.order(:id).limit(1, 1)
205
205
  ds.all
@@ -223,12 +223,12 @@ describe "Simple Dataset operations" do
223
223
  it "should fetch correctly with a limit in an IN subselect" do
224
224
  @ds.where(:id=>@ds.select(:id).order(:id).limit(1)).all.must_equal [{:id=>1, :number=>10}]
225
225
  end
226
-
226
+
227
227
  it "should fetch correctly with a limit and offset in an IN subselect" do
228
228
  @ds.where(:id=>@ds.select(:id).order(:id).limit(2, 0)).all.must_equal [{:id=>1, :number=>10}]
229
229
  @ds.where(:id=>@ds.select(:id).order(:id).limit(2, 1)).all.must_equal []
230
230
  end
231
-
231
+
232
232
  it "should fetch correctly when using limit and offset in a from_self" do
233
233
  ds = @ds.order(:id).limit(1, 1).from_self
234
234
  ds.all.must_equal []
@@ -274,19 +274,19 @@ describe Sequel::Dataset do
274
274
 
275
275
  it "should correctly return avg" do
276
276
  @d.avg(:value).to_i.must_equal 456
277
- end
278
-
277
+ end
278
+
279
279
  it "should correctly return sum" do
280
280
  @d.sum(:value).to_i.must_equal 1368
281
- end
282
-
281
+ end
282
+
283
283
  it "should correctly return max" do
284
- @d.max(:value).to_i.must_equal 789
285
- end
286
-
284
+ @d.max(:value).to_i.must_equal 789
285
+ end
286
+
287
287
  it "should correctly return min" do
288
- @d.min(:value).to_i.must_equal 123
289
- end
288
+ @d.min(:value).to_i.must_equal 123
289
+ end
290
290
 
291
291
  it "should return the correct record count" do
292
292
  @d.count.must_equal 3
@@ -318,7 +318,7 @@ describe Sequel::Database do
318
318
  "\\\\\n",
319
319
  "\\\r\n",
320
320
  "\\\\\r\n",
321
- "\\\\\n\n",
321
+ "\\\\\n\n",
322
322
  "\\\\\r\n\r\n",
323
323
  "\b\a'\0\3",
324
324
  #"\t\b\a'\0\3",
@@ -395,11 +395,11 @@ describe "Dataset UNION, EXCEPT, and INTERSECT" do
395
395
  after(:all) do
396
396
  DB.drop_table?(:i1, :i2, :i3)
397
397
  end
398
-
398
+
399
399
  it "should give the correct results for simple UNION" do
400
400
  @ds1.union(@ds2).order(:number).map{|x| x[:number].to_s}.must_equal %w'8 9 10 20 30 38 39'
401
401
  end
402
-
402
+
403
403
  it "should give the correct results for UNION when used with ordering and limits" do
404
404
 
405
405
  @ds1.reverse_order(:number).union(@ds2).order(:number).map{|x| x[:number].to_s}.must_equal %w'8 9 10 20 30 38 39'
@@ -439,11 +439,11 @@ describe "Common Table Expressions" do
439
439
  after(:all) do
440
440
  @db.drop_table?(:i1)
441
441
  end
442
-
442
+
443
443
  it "should give correct results for WITH" do
444
444
  @db[:t].with(:t, @ds.filter(:parent_id=>nil).select(:id)).order(:id).map(:id).must_equal [1, 2]
445
445
  end
446
-
446
+
447
447
  it "should support joining a dataset with a CTE" do
448
448
  @ds.inner_join(@db[:t].with(:t, @ds.filter(:parent_id=>nil)), :id => :id).select(:i1__id).order(:i1__id).map(:id).must_equal [1,2]
449
449
  @db[:t].with(:t, @ds).inner_join(@db[:s].with(:s, @ds.filter(:parent_id=>nil)), :id => :id).select(:t__id).order(:t__id).map(:id).must_equal [1,2]
@@ -483,34 +483,34 @@ describe "Window Functions" do
483
483
  after(:all) do
484
484
  @db.drop_table?(:i1)
485
485
  end
486
-
486
+
487
487
  it "should give correct results for aggregate window functions" do
488
488
  @ds.select(:id){sum(:amount).over(:partition=>:group_id).as(:sum)}.all.
489
489
  must_equal [{:sum=>111, :id=>1}, {:sum=>111, :id=>2}, {:sum=>111, :id=>3}, {:sum=>111000, :id=>4}, {:sum=>111000, :id=>5}, {:sum=>111000, :id=>6}]
490
490
  @ds.select(:id){sum(:amount).over.as(:sum)}.all.
491
491
  must_equal [{:sum=>111111, :id=>1}, {:sum=>111111, :id=>2}, {:sum=>111111, :id=>3}, {:sum=>111111, :id=>4}, {:sum=>111111, :id=>5}, {:sum=>111111, :id=>6}]
492
492
  end
493
-
493
+
494
494
  it "should give correct results for ranking window functions with orders" do
495
495
  @ds.select(:id){rank{}.over(:partition=>:group_id, :order=>:id).as(:rank)}.all.
496
496
  must_equal [{:rank=>1, :id=>1}, {:rank=>2, :id=>2}, {:rank=>3, :id=>3}, {:rank=>1, :id=>4}, {:rank=>2, :id=>5}, {:rank=>3, :id=>6}]
497
497
  @ds.select(:id){rank{}.over(:order=>id).as(:rank)}.all.
498
498
  must_equal [{:rank=>1, :id=>1}, {:rank=>2, :id=>2}, {:rank=>3, :id=>3}, {:rank=>4, :id=>4}, {:rank=>5, :id=>5}, {:rank=>6, :id=>6}]
499
499
  end
500
-
500
+
501
501
  it "should give correct results for aggregate window functions with orders" do
502
502
  @ds.select(:id){sum(:amount).over(:partition=>:group_id, :order=>:id).as(:sum)}.all.
503
503
  must_equal [{:sum=>1, :id=>1}, {:sum=>11, :id=>2}, {:sum=>111, :id=>3}, {:sum=>1000, :id=>4}, {:sum=>11000, :id=>5}, {:sum=>111000, :id=>6}]
504
504
  @ds.select(:id){sum(:amount).over(:order=>:id).as(:sum)}.all.
505
505
  must_equal [{:sum=>1, :id=>1}, {:sum=>11, :id=>2}, {:sum=>111, :id=>3}, {:sum=>1111, :id=>4}, {:sum=>11111, :id=>5}, {:sum=>111111, :id=>6}]
506
506
  end
507
-
507
+
508
508
  it "should give correct results for aggregate window functions with frames" do
509
509
  @ds.select(:id){sum(:amount).over(:partition=>:group_id, :order=>:id, :frame=>:all).as(:sum)}.all.
510
510
  must_equal [{:sum=>111, :id=>1}, {:sum=>111, :id=>2}, {:sum=>111, :id=>3}, {:sum=>111000, :id=>4}, {:sum=>111000, :id=>5}, {:sum=>111000, :id=>6}]
511
511
  @ds.select(:id){sum(:amount).over(:order=>:id, :frame=>:all).as(:sum)}.all.
512
512
  must_equal [{:sum=>111111, :id=>1}, {:sum=>111111, :id=>2}, {:sum=>111111, :id=>3}, {:sum=>111111, :id=>4}, {:sum=>111111, :id=>5}, {:sum=>111111, :id=>6}]
513
-
513
+
514
514
  @ds.select(:id){sum(:amount).over(:partition=>:group_id, :order=>:id, :frame=>:rows).as(:sum)}.all.
515
515
  must_equal [{:sum=>1, :id=>1}, {:sum=>11, :id=>2}, {:sum=>111, :id=>3}, {:sum=>1000, :id=>4}, {:sum=>11000, :id=>5}, {:sum=>111000, :id=>6}]
516
516
  @ds.select(:id){sum(:amount).over(:order=>:id, :frame=>:rows).as(:sum)}.all.
@@ -537,7 +537,7 @@ describe Sequel::SQL::Constants do
537
537
  after do
538
538
  @db.drop_table?(:constants)
539
539
  end
540
-
540
+
541
541
  it "should have working CURRENT_TIMESTAMP" do
542
542
  @db.create_table!(:constants){DateTime :ts}
543
543
  @ds.insert(:ts=>Sequel::CURRENT_TIMESTAMP)
@@ -572,7 +572,7 @@ describe "Sequel::Dataset#import and #multi_insert" do
572
572
  @ids.all.must_equal [{:i=>10}, {:i=>20}]
573
573
  @db.drop_table(:exp2)
574
574
  end
575
-
575
+
576
576
  it "should have import work with the :slice_size option" do
577
577
  @ids.import([:i], [[10], [20], [30]], :slice_size=>1)
578
578
  @ids.all.must_equal [{:i=>10}, {:i=>20}, {:i=>30}]
@@ -593,20 +593,20 @@ describe "Sequel::Dataset convenience methods" do
593
593
  after do
594
594
  @db.drop_table?(:a)
595
595
  end
596
-
596
+
597
597
  it "#empty? should return whether the dataset returns no rows" do
598
598
  @ds.empty?.must_equal true
599
599
  @ds.insert(20, 10)
600
600
  @ds.empty?.must_equal false
601
601
  end
602
-
602
+
603
603
  it "#empty? should work correctly for datasets with limits" do
604
604
  ds = @ds.limit(1)
605
605
  ds.empty?.must_equal true
606
606
  ds.insert(20, 10)
607
607
  ds.empty?.must_equal false
608
608
  end
609
-
609
+
610
610
  it "#empty? should work correctly for datasets with limits and offsets" do
611
611
  ds = @ds.order(:a).limit(1, 1)
612
612
  ds.empty?.must_equal true
@@ -615,7 +615,7 @@ describe "Sequel::Dataset convenience methods" do
615
615
  ds.insert(20, 10)
616
616
  ds.empty?.must_equal false
617
617
  end
618
-
618
+
619
619
  it "#group_and_count should return a grouping by count" do
620
620
  @ds.group_and_count(:a).order{count(:a)}.all.must_equal []
621
621
  @ds.insert(20, 10)
@@ -625,7 +625,7 @@ describe "Sequel::Dataset convenience methods" do
625
625
  @ds.insert(30, 30)
626
626
  @ds.group_and_count(:a).order{count(:a)}.all.each{|h| h[:count] = h[:count].to_i}.must_equal [{:a=>30, :count=>1}, {:a=>20, :count=>2}]
627
627
  end
628
-
628
+
629
629
  it "#group_and_count should support column aliases" do
630
630
  @ds.group_and_count(:a___c).order{count(:a)}.all.must_equal []
631
631
  @ds.insert(20, 10)
@@ -635,7 +635,7 @@ describe "Sequel::Dataset convenience methods" do
635
635
  @ds.insert(30, 30)
636
636
  @ds.group_and_count(:a___c).order{count(:a)}.all.each{|h| h[:count] = h[:count].to_i}.must_equal [{:c=>30, :count=>1}, {:c=>20, :count=>2}]
637
637
  end
638
-
638
+
639
639
  it "#range should return the range between the maximum and minimum values" do
640
640
  @ds = @ds.unordered
641
641
  @ds.insert(20, 10)
@@ -643,7 +643,7 @@ describe "Sequel::Dataset convenience methods" do
643
643
  @ds.range(:a).must_equal(20..30)
644
644
  @ds.range(:b).must_equal(10..10)
645
645
  end
646
-
646
+
647
647
  it "#interval should return the different between the maximum and minimum values" do
648
648
  @ds = @ds.unordered
649
649
  @ds.insert(20, 10)
@@ -652,7 +652,7 @@ describe "Sequel::Dataset convenience methods" do
652
652
  @ds.interval(:b).to_i.must_equal 0
653
653
  end
654
654
  end
655
-
655
+
656
656
  describe "Sequel::Dataset main SQL methods" do
657
657
  before do
658
658
  @db = DB
@@ -662,21 +662,21 @@ describe "Sequel::Dataset main SQL methods" do
662
662
  after do
663
663
  @db.drop_table?(:d)
664
664
  end
665
-
665
+
666
666
  it "#exists should return a usable exists clause" do
667
667
  @ds.filter(@db[:d___c].filter(:c__a=>:d__b).exists).all.must_equal []
668
668
  @ds.insert(20, 30)
669
669
  @ds.insert(10, 20)
670
670
  @ds.filter(@db[:d___c].filter(:c__a=>:d__b).exists).all.must_equal [{:a=>10, :b=>20}]
671
671
  end
672
-
672
+
673
673
  it "#filter and #exclude should work with placeholder strings" do
674
674
  @ds.insert(20, 30)
675
675
  @ds.filter("a > ?", 15).all.must_equal [{:a=>20, :b=>30}]
676
676
  @ds.exclude("b < ?", 15).all.must_equal [{:a=>20, :b=>30}]
677
677
  @ds.filter("b < ?", 15).invert.all.must_equal [{:a=>20, :b=>30}]
678
678
  end
679
-
679
+
680
680
  it "#and and #or should work correctly" do
681
681
  @ds.insert(20, 30)
682
682
  @ds.filter(:a=>20).and(:b=>30).all.must_equal [{:a=>20, :b=>30}]
@@ -701,7 +701,7 @@ describe "Sequel::Dataset main SQL methods" do
701
701
  @ds.insert(20, 30)
702
702
  @ds.select_group(:b___c).all.must_equal [{:c=>30}]
703
703
  end
704
-
704
+
705
705
  it "#having should work correctly" do
706
706
  @ds.unordered!
707
707
  @ds.select{[b, max(a).as(c)]}.group(:b).having{max(a) > 30}.all.must_equal []
@@ -710,7 +710,7 @@ describe "Sequel::Dataset main SQL methods" do
710
710
  @ds.insert(40, 20)
711
711
  @ds.select{[b, max(a).as(c)]}.group(:b).having{max(a) > 30}.all.each{|h| h[:c] = h[:c].to_i}.must_equal [{:b=>20, :c=>40}]
712
712
  end
713
-
713
+
714
714
  it "#having should work without a previous group" do
715
715
  @ds.unordered!
716
716
  @ds.select{max(a).as(c)}.having{max(a) > 30}.all.must_equal []
@@ -732,13 +732,13 @@ describe "Sequel::Dataset convenience methods" do
732
732
  after do
733
733
  @db.drop_table?(:a)
734
734
  end
735
-
735
+
736
736
  it "should have working #map" do
737
737
  @ds.map(:a).must_equal [1, 5]
738
738
  @ds.map(:b).must_equal [2, 6]
739
739
  @ds.map([:a, :b]).must_equal [[1, 2], [5, 6]]
740
740
  end
741
-
741
+
742
742
  it "should have working #to_hash" do
743
743
  @ds.to_hash(:a).must_equal(1=>{:a=>1, :b=>2, :c=>3, :d=>4}, 5=>{:a=>5, :b=>6, :c=>7, :d=>8})
744
744
  @ds.to_hash(:b).must_equal(2=>{:a=>1, :b=>2, :c=>3, :d=>4}, 6=>{:a=>5, :b=>6, :c=>7, :d=>8})
@@ -777,7 +777,7 @@ describe "Sequel::Dataset convenience methods" do
777
777
  @ds.select_map([Sequel.qualify(:a, :a).as(:e), Sequel.qualify(:a, :b).as(:f)]).must_equal [[1, 2], [5, 6]]
778
778
  @ds.select_map([Sequel.identifier(:a).qualify(:a).as(:e), Sequel.qualify(:a, :b).as(:f)]).must_equal [[1, 2], [5, 6]]
779
779
  end
780
-
780
+
781
781
  it "should have working #select_order_map" do
782
782
  @ds.select_order_map(:a).must_equal [1, 5]
783
783
  @ds.select_order_map(Sequel.desc(:a__b)).must_equal [6, 2]
@@ -829,7 +829,7 @@ describe "Sequel::Dataset DSL support" do
829
829
  after do
830
830
  @db.drop_table?(:a)
831
831
  end
832
-
832
+
833
833
  it "should work with standard mathematical operators" do
834
834
  @ds.insert(20, 10)
835
835
  @ds.get{a + b}.to_i.must_equal 30
@@ -837,7 +837,7 @@ describe "Sequel::Dataset DSL support" do
837
837
  @ds.get{a * b}.to_i.must_equal 200
838
838
  @ds.get{a / b}.to_i.must_equal 2
839
839
  end
840
-
840
+
841
841
  it "should work with bitwise AND and OR operators" do
842
842
  @ds.insert(3, 5)
843
843
  @ds.get{a.sql_number | b}.to_i.must_equal 7
@@ -845,26 +845,26 @@ describe "Sequel::Dataset DSL support" do
845
845
  @ds.get{a.sql_number | b | 8}.to_i.must_equal 15
846
846
  @ds.get{a.sql_number & b & 8}.to_i.must_equal 0
847
847
  end
848
-
848
+
849
849
  it "should work with the bitwise compliment operator" do
850
850
  @ds.insert(-3, 3)
851
851
  @ds.get{~a.sql_number}.to_i.must_equal 2
852
852
  @ds.get{~b.sql_number}.to_i.must_equal(-4)
853
853
  end
854
-
854
+
855
855
  it "should work with the bitwise xor operator" do
856
856
  @ds.insert(3, 5)
857
857
  @ds.get{a.sql_number ^ b}.to_i.must_equal 6
858
858
  @ds.get{a.sql_number ^ b ^ 1}.to_i.must_equal 7
859
859
  end
860
-
860
+
861
861
  it "should work with the modulus operator" do
862
862
  @ds.insert(3, 5)
863
863
  @ds.get{a.sql_number % 4}.to_i.must_equal 3
864
864
  @ds.get{b.sql_number % 4}.to_i.must_equal 1
865
865
  @ds.get{a.sql_number % 4 % 2}.to_i.must_equal 1
866
866
  end
867
-
867
+
868
868
  it "should work with inequality operators" do
869
869
  @ds.insert(10, 11)
870
870
  @ds.insert(11, 11)
@@ -875,12 +875,12 @@ describe "Sequel::Dataset DSL support" do
875
875
  @ds.filter{a < b}.select_order_map(:a).must_equal [10]
876
876
  @ds.filter{a <= b}.select_order_map(:a).must_equal [10, 11, 20]
877
877
  end
878
-
878
+
879
879
  it "should work with casting and string concatentation" do
880
880
  @ds.insert(20, 20)
881
881
  @ds.get{Sequel.cast(a, String).sql_string + Sequel.cast(b, String)}.must_equal '2020'
882
882
  end
883
-
883
+
884
884
  it "should work with ordering" do
885
885
  @ds.insert(10, 20)
886
886
  @ds.insert(20, 10)
@@ -888,14 +888,14 @@ describe "Sequel::Dataset DSL support" do
888
888
  @ds.order(Sequel.asc(:a), Sequel.asc(:b)).all.must_equal [{:a=>10, :b=>20}, {:a=>20, :b=>10}]
889
889
  @ds.order(Sequel.desc(:a), Sequel.desc(:b)).all.must_equal [{:a=>20, :b=>10}, {:a=>10, :b=>20}]
890
890
  end
891
-
891
+
892
892
  it "should work with qualifying" do
893
893
  @ds.insert(10, 20)
894
894
  @ds.get(:a__b).must_equal 20
895
895
  @ds.get{a__b}.must_equal 20
896
896
  @ds.get(Sequel.qualify(:a, :b)).must_equal 20
897
897
  end
898
-
898
+
899
899
  it "should work with aliasing" do
900
900
  @ds.insert(10, 20)
901
901
  @ds.get(:a__b___c).must_equal 20
@@ -903,12 +903,12 @@ describe "Sequel::Dataset DSL support" do
903
903
  @ds.get(Sequel.qualify(:a, :b).as(:c)).must_equal 20
904
904
  @ds.get(Sequel.as(:b, :c)).must_equal 20
905
905
  end
906
-
906
+
907
907
  it "should work with selecting all columns of a table" do
908
908
  @ds.insert(20, 10)
909
909
  @ds.select_all(:a).all.must_equal [{:a=>20, :b=>10}]
910
910
  end
911
-
911
+
912
912
  it "should work with ranges as hash values" do
913
913
  @ds.insert(20, 10)
914
914
  @ds.filter(:a=>(10..30)).all.must_equal [{:a=>20, :b=>10}]
@@ -918,7 +918,7 @@ describe "Sequel::Dataset DSL support" do
918
918
  @ds.exclude(:a=>(25..30)).all.must_equal [{:a=>20, :b=>10}]
919
919
  @ds.exclude(:a=>(10..15)).all.must_equal [{:a=>20, :b=>10}]
920
920
  end
921
-
921
+
922
922
  it "should work with nil as hash value" do
923
923
  @ds.insert(20, nil)
924
924
  @ds.filter(:a=>nil).all.must_equal []
@@ -926,7 +926,7 @@ describe "Sequel::Dataset DSL support" do
926
926
  @ds.exclude(:b=>nil).all.must_equal []
927
927
  @ds.exclude(:a=>nil).all.must_equal [{:a=>20, :b=>nil}]
928
928
  end
929
-
929
+
930
930
  it "should work with arrays as hash values" do
931
931
  @ds.insert(20, 10)
932
932
  @ds.filter(:a=>[10]).all.must_equal []
@@ -934,7 +934,7 @@ describe "Sequel::Dataset DSL support" do
934
934
  @ds.exclude(:a=>[10]).all.must_equal [{:a=>20, :b=>10}]
935
935
  @ds.exclude(:a=>[20, 10]).all.must_equal []
936
936
  end
937
-
937
+
938
938
  it "should work with ranges as hash values" do
939
939
  @ds.insert(20, 10)
940
940
  @ds.filter(:a=>(10..30)).all.must_equal [{:a=>20, :b=>10}]
@@ -944,7 +944,7 @@ describe "Sequel::Dataset DSL support" do
944
944
  @ds.exclude(:a=>(25..30)).all.must_equal [{:a=>20, :b=>10}]
945
945
  @ds.exclude(:a=>(10..15)).all.must_equal [{:a=>20, :b=>10}]
946
946
  end
947
-
947
+
948
948
  it "should work with CASE statements" do
949
949
  @ds.insert(20, 10)
950
950
  @ds.filter(Sequel.case({{:a=>20}=>20}, 0) > 0).all.must_equal [{:a=>20, :b=>10}]
@@ -952,7 +952,7 @@ describe "Sequel::Dataset DSL support" do
952
952
  @ds.filter(Sequel.case({20=>20}, 0, :a) > 0).all.must_equal [{:a=>20, :b=>10}]
953
953
  @ds.filter(Sequel.case({15=>20}, 0, :a) > 0).all.must_equal []
954
954
  end
955
-
955
+
956
956
  it "should work with multiple value arrays" do
957
957
  @ds.insert(20, 10)
958
958
  @ds.quote_identifiers = false
@@ -960,7 +960,7 @@ describe "Sequel::Dataset DSL support" do
960
960
  @ds.filter([:a, :b]=>[[10, 20]]).all.must_equal []
961
961
  @ds.filter([:a, :b]=>[[20, 10], [1, 2]]).all.must_equal [{:a=>20, :b=>10}]
962
962
  @ds.filter([:a, :b]=>[[10, 10], [20, 20]]).all.must_equal []
963
-
963
+
964
964
  @ds.exclude([:a, :b]=>[[20, 10]]).all.must_equal []
965
965
  @ds.exclude([:a, :b]=>[[10, 20]]).all.must_equal [{:a=>20, :b=>10}]
966
966
  @ds.exclude([:a, :b]=>[[20, 10], [1, 2]]).all.must_equal []
@@ -993,7 +993,7 @@ describe "Sequel::Dataset DSL support" do
993
993
  @ds.filter([:a, :b]=>[]).all.must_equal []
994
994
  @ds.exclude([:a, :b]=>[]).all.must_equal [{:a=>20, :b=>10}]
995
995
  end
996
-
996
+
997
997
  it "should work empty arrays with nulls" do
998
998
  @ds = @ds.extension(:empty_array_consider_nulls)
999
999
  @ds.insert(nil, nil)
@@ -1008,7 +1008,7 @@ describe "Sequel::Dataset DSL support" do
1008
1008
  pr[@ds.get(Sequel.expr([:a, :b]=>[]))].must_equal nil
1009
1009
  pr[@ds.get(~Sequel.expr([:a, :b]=>[]))].must_equal nil
1010
1010
  end
1011
-
1011
+
1012
1012
  it "should work empty arrays with nulls and the empty_array_ignore_nulls extension" do
1013
1013
  ds = @ds
1014
1014
  ds.insert(nil, nil)
@@ -1043,7 +1043,7 @@ describe "SQL Extract Function" do
1043
1043
  after do
1044
1044
  @db.drop_table?(:a)
1045
1045
  end
1046
-
1046
+
1047
1047
  it "should return the part of the datetime asked for" do
1048
1048
  t = Time.now
1049
1049
  def @ds.supports_timestamp_timezones?() false end
@@ -1069,7 +1069,7 @@ describe "Dataset string methods" do
1069
1069
  after do
1070
1070
  @db.drop_table?(:a)
1071
1071
  end
1072
-
1072
+
1073
1073
  it "#grep should return matching rows" do
1074
1074
  @ds.insert('foo', 'bar')
1075
1075
  @ds.grep(:a, 'foo').all.must_equal [{:a=>'foo', :b=>'bar'}]
@@ -1079,7 +1079,7 @@ describe "Dataset string methods" do
1079
1079
  @ds.grep([:a, :b], %w'foo bar').all.must_equal [{:a=>'foo', :b=>'bar'}]
1080
1080
  @ds.grep([:a, :b], %w'boo far').all.must_equal []
1081
1081
  end
1082
-
1082
+
1083
1083
  it "#grep should work with :all_patterns and :all_columns options" do
1084
1084
  @ds.insert('foo bar', ' ')
1085
1085
  @ds.insert('foo d', 'bar')
@@ -1098,7 +1098,7 @@ describe "Dataset string methods" do
1098
1098
  @ds.grep([:a, :b], %w'%baz% %foo%', :all_columns=>true, :all_patterns=>true).all.must_equal []
1099
1099
  @ds.grep([:a, :b], %w'%boo% %foo%', :all_columns=>true, :all_patterns=>true).all.must_equal [{:a=>'foo boo', :b=>'boo foo'}]
1100
1100
  end
1101
-
1101
+
1102
1102
  it "#like should return matching rows" do
1103
1103
  @ds.insert('foo', 'bar')
1104
1104
  @ds.filter(Sequel.expr(:a).like('foo')).all.must_equal [{:a=>'foo', :b=>'bar'}]
@@ -1108,7 +1108,7 @@ describe "Dataset string methods" do
1108
1108
  @ds.exclude(Sequel.expr(:a).like('bar')).all.must_equal [{:a=>'foo', :b=>'bar'}]
1109
1109
  @ds.exclude(Sequel.expr(:a).like('foo', 'bar')).all.must_equal []
1110
1110
  end
1111
-
1111
+
1112
1112
  it "#like should be case sensitive" do
1113
1113
  @ds.insert('foo', 'bar')
1114
1114
  @ds.filter(Sequel.expr(:a).like('Foo')).all.must_equal []
@@ -1118,7 +1118,7 @@ describe "Dataset string methods" do
1118
1118
  @ds.exclude(Sequel.expr(:b).like('baR')).all.must_equal [{:a=>'foo', :b=>'bar'}]
1119
1119
  @ds.exclude(Sequel.expr(:a).like('FOO', 'BAR')).all.must_equal [{:a=>'foo', :b=>'bar'}]
1120
1120
  end
1121
-
1121
+
1122
1122
  it "#ilike should return matching rows, in a case insensitive manner" do
1123
1123
  @ds.insert('foo', 'bar')
1124
1124
  @ds.filter(Sequel.expr(:a).ilike('Foo')).all.must_equal [{:a=>'foo', :b=>'bar'}]
@@ -1128,7 +1128,7 @@ describe "Dataset string methods" do
1128
1128
  @ds.exclude(Sequel.expr(:a).ilike('baR')).all.must_equal [{:a=>'foo', :b=>'bar'}]
1129
1129
  @ds.exclude(Sequel.expr(:a).ilike('FOO', 'BAR')).all.must_equal []
1130
1130
  end
1131
-
1131
+
1132
1132
  it "#like with regexp return matching rows" do
1133
1133
  @ds.insert('foo', 'bar')
1134
1134
  @ds.filter(Sequel.expr(:a).like(/fo/)).all.must_equal [{:a=>'foo', :b=>'bar'}]
@@ -1138,7 +1138,7 @@ describe "Dataset string methods" do
1138
1138
  @ds.exclude(Sequel.expr(:a).like(/fo$/)).all.must_equal [{:a=>'foo', :b=>'bar'}]
1139
1139
  @ds.exclude(Sequel.expr(:a).like(/fo/, /ar/)).all.must_equal []
1140
1140
  end
1141
-
1141
+
1142
1142
  it "#like with regexp should be case sensitive if regexp is case sensitive" do
1143
1143
  @ds.insert('foo', 'bar')
1144
1144
  @ds.filter(Sequel.expr(:a).like(/Fo/)).all.must_equal []
@@ -1155,7 +1155,7 @@ describe "Dataset string methods" do
1155
1155
  @ds.exclude(Sequel.expr(:b).like(/baR/i)).all.must_equal []
1156
1156
  @ds.exclude(Sequel.expr(:a).like(/FOO/i, /BAR/i)).all.must_equal []
1157
1157
  end
1158
-
1158
+
1159
1159
  it "#ilike with regexp should return matching rows, in a case insensitive manner" do
1160
1160
  @ds.insert('foo', 'bar')
1161
1161
  @ds.filter(Sequel.expr(:a).ilike(/Fo/)).all.must_equal [{:a=>'foo', :b=>'bar'}]
@@ -1165,7 +1165,7 @@ describe "Dataset string methods" do
1165
1165
  @ds.exclude(Sequel.expr(:b).ilike(/baR/)).all.must_equal []
1166
1166
  @ds.exclude(Sequel.expr(:a).ilike(/FOO/, /BAR/)).all.must_equal []
1167
1167
  end
1168
-
1168
+
1169
1169
  it "should work with strings created with Sequel.join" do
1170
1170
  @ds.insert('foo', 'bar')
1171
1171
  @ds.get(Sequel.join([:a, "bar"])).must_equal 'foobar'
@@ -1190,14 +1190,14 @@ describe "Dataset identifier methods" do
1190
1190
  after(:all) do
1191
1191
  @db.drop_table?(:a)
1192
1192
  end
1193
-
1193
+
1194
1194
  it "#identifier_output_method should change how identifiers are output" do
1195
1195
  @ds.identifier_output_method = :upcase
1196
1196
  @ds.first.must_equal(:AB=>1)
1197
1197
  @ds.identifier_output_method = :uprev
1198
1198
  @ds.first.must_equal(:BA=>1)
1199
1199
  end
1200
-
1200
+
1201
1201
  it "should work with a nil identifier_output_method" do
1202
1202
  @ds.identifier_output_method = nil
1203
1203
  [{:ab=>1}, {:AB=>1}].must_include(@ds.first)
@@ -1218,14 +1218,14 @@ describe "Dataset defaults and overrides" do
1218
1218
  after do
1219
1219
  @db.drop_table?(:a)
1220
1220
  end
1221
-
1221
+
1222
1222
  it "#set_defaults should set defaults that can be overridden" do
1223
1223
  @ds = @ds.set_defaults(:a=>10)
1224
1224
  @ds.insert
1225
1225
  @ds.insert(:a=>20)
1226
1226
  @ds.all.must_equal [{:a=>10}, {:a=>20}]
1227
1227
  end
1228
-
1228
+
1229
1229
  it "#set_overrides should set defaults that cannot be overridden" do
1230
1230
  @ds = @ds.set_overrides(:a=>10)
1231
1231
  @ds.insert
@@ -1243,7 +1243,7 @@ describe "Emulated functions" do
1243
1243
  after do
1244
1244
  @db.drop_table?(:a)
1245
1245
  end
1246
-
1246
+
1247
1247
  it "Sequel.char_length should return the length of characters in the string" do
1248
1248
  @ds.get(Sequel.char_length(:a)).must_equal nil
1249
1249
  @ds.insert(:a=>'foo')
@@ -1254,7 +1254,7 @@ describe "Emulated functions" do
1254
1254
  @ds.insert(:a=>' foo22 ')
1255
1255
  @ds.get(Sequel.char_length(:a)).must_equal 7
1256
1256
  end
1257
-
1257
+
1258
1258
  it "Sequel.trim should return the string with spaces trimmed from both sides" do
1259
1259
  @ds.get(Sequel.trim(:a)).must_equal nil
1260
1260
  @ds.insert(:a=>'foo')