sequel 4.34.0 → 4.35.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +30 -0
  3. data/Rakefile +14 -17
  4. data/doc/object_model.rdoc +4 -4
  5. data/doc/release_notes/4.35.0.txt +130 -0
  6. data/doc/schema_modification.rdoc +8 -3
  7. data/doc/security.rdoc +3 -3
  8. data/lib/sequel/adapters/ado.rb +2 -2
  9. data/lib/sequel/adapters/ado/access.rb +6 -6
  10. data/lib/sequel/adapters/ado/mssql.rb +2 -2
  11. data/lib/sequel/adapters/amalgalite.rb +6 -6
  12. data/lib/sequel/adapters/cubrid.rb +4 -4
  13. data/lib/sequel/adapters/do.rb +2 -2
  14. data/lib/sequel/adapters/do/mysql.rb +1 -1
  15. data/lib/sequel/adapters/do/postgres.rb +1 -1
  16. data/lib/sequel/adapters/do/sqlite3.rb +1 -1
  17. data/lib/sequel/adapters/ibmdb.rb +6 -6
  18. data/lib/sequel/adapters/jdbc.rb +15 -15
  19. data/lib/sequel/adapters/jdbc/db2.rb +1 -1
  20. data/lib/sequel/adapters/jdbc/derby.rb +3 -3
  21. data/lib/sequel/adapters/jdbc/h2.rb +3 -3
  22. data/lib/sequel/adapters/jdbc/hsqldb.rb +2 -2
  23. data/lib/sequel/adapters/jdbc/mssql.rb +1 -1
  24. data/lib/sequel/adapters/jdbc/mysql.rb +1 -1
  25. data/lib/sequel/adapters/jdbc/oracle.rb +1 -1
  26. data/lib/sequel/adapters/jdbc/postgresql.rb +2 -2
  27. data/lib/sequel/adapters/jdbc/sqlanywhere.rb +1 -1
  28. data/lib/sequel/adapters/jdbc/sqlite.rb +1 -1
  29. data/lib/sequel/adapters/jdbc/transactions.rb +10 -10
  30. data/lib/sequel/adapters/mock.rb +1 -1
  31. data/lib/sequel/adapters/mysql.rb +2 -2
  32. data/lib/sequel/adapters/mysql2.rb +2 -2
  33. data/lib/sequel/adapters/odbc.rb +2 -2
  34. data/lib/sequel/adapters/odbc/mssql.rb +2 -2
  35. data/lib/sequel/adapters/oracle.rb +9 -9
  36. data/lib/sequel/adapters/postgres.rb +3 -3
  37. data/lib/sequel/adapters/shared/mssql.rb +36 -8
  38. data/lib/sequel/adapters/shared/oracle.rb +15 -0
  39. data/lib/sequel/adapters/shared/postgres.rb +22 -1
  40. data/lib/sequel/adapters/sqlanywhere.rb +1 -1
  41. data/lib/sequel/adapters/sqlite.rb +7 -7
  42. data/lib/sequel/adapters/swift.rb +3 -3
  43. data/lib/sequel/adapters/swift/mysql.rb +1 -1
  44. data/lib/sequel/adapters/swift/postgres.rb +1 -1
  45. data/lib/sequel/adapters/swift/sqlite.rb +1 -1
  46. data/lib/sequel/adapters/tinytds.rb +5 -7
  47. data/lib/sequel/database/logging.rb +18 -3
  48. data/lib/sequel/database/misc.rb +19 -8
  49. data/lib/sequel/database/schema_generator.rb +7 -2
  50. data/lib/sequel/database/schema_methods.rb +9 -2
  51. data/lib/sequel/database/transactions.rb +52 -18
  52. data/lib/sequel/dataset/actions.rb +24 -19
  53. data/lib/sequel/dataset/features.rb +5 -0
  54. data/lib/sequel/dataset/query.rb +6 -0
  55. data/lib/sequel/extensions/_pretty_table.rb +1 -1
  56. data/lib/sequel/extensions/error_sql.rb +3 -3
  57. data/lib/sequel/extensions/pg_range.rb +10 -1
  58. data/lib/sequel/extensions/schema_dumper.rb +8 -5
  59. data/lib/sequel/extensions/server_logging.rb +61 -0
  60. data/lib/sequel/extensions/sql_comments.rb +91 -0
  61. data/lib/sequel/model/associations.rb +40 -8
  62. data/lib/sequel/model/base.rb +19 -5
  63. data/lib/sequel/plugins/class_table_inheritance.rb +12 -0
  64. data/lib/sequel/plugins/delay_add_association.rb +1 -0
  65. data/lib/sequel/plugins/json_serializer.rb +10 -2
  66. data/lib/sequel/version.rb +1 -1
  67. data/spec/adapter_spec.rb +4 -0
  68. data/spec/adapters/mysql_spec.rb +1 -1
  69. data/spec/adapters/postgres_spec.rb +3 -2
  70. data/spec/core/connection_pool_spec.rb +2 -0
  71. data/spec/core/database_spec.rb +49 -0
  72. data/spec/core/dataset_spec.rb +25 -1
  73. data/spec/core/mock_adapter_spec.rb +3 -1
  74. data/spec/core/schema_generator_spec.rb +1 -1
  75. data/spec/core_model_spec.rb +2 -0
  76. data/spec/core_spec.rb +1 -0
  77. data/spec/extensions/delay_add_association_spec.rb +22 -0
  78. data/spec/extensions/json_serializer_spec.rb +6 -0
  79. data/spec/extensions/pg_range_spec.rb +30 -2
  80. data/spec/extensions/schema_dumper_spec.rb +3 -2
  81. data/spec/extensions/server_logging_spec.rb +45 -0
  82. data/spec/extensions/sql_comments_spec.rb +27 -0
  83. data/spec/files/reversible_migrations/006_reversible.rb +10 -0
  84. data/spec/files/reversible_migrations/007_reversible.rb +10 -0
  85. data/spec/integration/dataset_test.rb +28 -2
  86. data/spec/integration/migrator_test.rb +23 -1
  87. data/spec/integration/schema_test.rb +12 -32
  88. data/spec/integration/transaction_test.rb +10 -0
  89. data/spec/integration/type_test.rb +1 -1
  90. data/spec/model/eager_loading_spec.rb +16 -0
  91. data/spec/model/record_spec.rb +9 -0
  92. data/spec/model_no_assoc_spec.rb +1 -0
  93. data/spec/model_spec.rb +1 -0
  94. data/spec/plugin_spec.rb +1 -0
  95. metadata +16 -2
@@ -131,6 +131,22 @@ describe Sequel::Model, "#eager" do
131
131
  DB.sqls.must_equal []
132
132
  end
133
133
 
134
+ it "should eagerly load when using to_hash" do
135
+ h = EagerAlbum.eager(:band).to_hash
136
+ DB.sqls.must_equal ['SELECT * FROM albums', 'SELECT * FROM bands WHERE (bands.id IN (2))']
137
+ h.must_equal(1=>EagerAlbum.load(:id => 1, :band_id => 2))
138
+ h[1].band.must_equal EagerBand.load(:id=>2)
139
+ DB.sqls.must_equal []
140
+ end
141
+
142
+ it "should eagerly load when using to_hash_groups" do
143
+ h = EagerAlbum.eager(:band).to_hash_groups(:id)
144
+ DB.sqls.must_equal ['SELECT * FROM albums', 'SELECT * FROM bands WHERE (bands.id IN (2))']
145
+ h.must_equal(1=>[EagerAlbum.load(:id => 1, :band_id => 2)])
146
+ h[1].first.band.must_equal EagerBand.load(:id=>2)
147
+ DB.sqls.must_equal []
148
+ end
149
+
134
150
  it "should skip eager loading for a many_to_one association with no matching keys" do
135
151
  EagerAlbum.dataset._fetch = [{:id=>1, :band_id=>nil}]
136
152
  a = EagerAlbum.eager(:band).all
@@ -2142,6 +2142,15 @@ describe "Model#lock!" do
2142
2142
  o.instance_variable_get(:@a).must_equal 1
2143
2143
  DB.sqls.must_equal ["SELECT * FROM items WHERE (id = 1) LIMIT 1 FOR UPDATE"]
2144
2144
  end
2145
+
2146
+ it "should refresh the record using the specified lock when it is not a new record and a style is given" do
2147
+ o = @c.load(:id => 1)
2148
+ def o._refresh(x) instance_variable_set(:@a, 1); super(x) end
2149
+ x = o.lock!('FOR NO KEY UPDATE')
2150
+ x.must_equal o
2151
+ o.instance_variable_get(:@a).must_equal 1
2152
+ DB.sqls.must_equal ["SELECT * FROM items WHERE (id = 1) LIMIT 1 FOR NO KEY UPDATE"]
2153
+ end
2145
2154
  end
2146
2155
 
2147
2156
  describe "Model#schema_type_class" do
@@ -0,0 +1 @@
1
+ Dir['./spec/model/*_spec.rb'].delete_if{|f| f =~ /association|eager_loading/}.each{|f| require f}
@@ -0,0 +1 @@
1
+ Dir['./spec/model/*_spec.rb'].each{|f| require f}
@@ -0,0 +1 @@
1
+ Dir['./spec/extensions/*_spec.rb'].each{|f| require f}
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.34.0
4
+ version: 4.35.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: 2016-05-01 00:00:00.000000000 Z
11
+ date: 2016-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -235,6 +235,7 @@ extra_rdoc_files:
235
235
  - doc/release_notes/4.32.0.txt
236
236
  - doc/release_notes/4.33.0.txt
237
237
  - doc/release_notes/4.34.0.txt
238
+ - doc/release_notes/4.35.0.txt
238
239
  files:
239
240
  - CHANGELOG
240
241
  - MIT-LICENSE
@@ -358,6 +359,7 @@ files:
358
359
  - doc/release_notes/4.32.0.txt
359
360
  - doc/release_notes/4.33.0.txt
360
361
  - doc/release_notes/4.34.0.txt
362
+ - doc/release_notes/4.35.0.txt
361
363
  - doc/release_notes/4.4.0.txt
362
364
  - doc/release_notes/4.5.0.txt
363
365
  - doc/release_notes/4.6.0.txt
@@ -524,8 +526,10 @@ files:
524
526
  - lib/sequel/extensions/select_remove.rb
525
527
  - lib/sequel/extensions/sequel_3_dataset_methods.rb
526
528
  - lib/sequel/extensions/server_block.rb
529
+ - lib/sequel/extensions/server_logging.rb
527
530
  - lib/sequel/extensions/set_overrides.rb
528
531
  - lib/sequel/extensions/split_array_nil.rb
532
+ - lib/sequel/extensions/sql_comments.rb
529
533
  - lib/sequel/extensions/sql_expr.rb
530
534
  - lib/sequel/extensions/string_date_time.rb
531
535
  - lib/sequel/extensions/thread_local_timezones.rb
@@ -621,6 +625,7 @@ files:
621
625
  - lib/sequel/sql.rb
622
626
  - lib/sequel/timezones.rb
623
627
  - lib/sequel/version.rb
628
+ - spec/adapter_spec.rb
624
629
  - spec/adapters/db2_spec.rb
625
630
  - spec/adapters/firebird_spec.rb
626
631
  - spec/adapters/informix_spec.rb
@@ -645,6 +650,8 @@ files:
645
650
  - spec/core/spec_helper.rb
646
651
  - spec/core/version_spec.rb
647
652
  - spec/core_extensions_spec.rb
653
+ - spec/core_model_spec.rb
654
+ - spec/core_spec.rb
648
655
  - spec/extensions/accessed_columns_spec.rb
649
656
  - spec/extensions/active_model_spec.rb
650
657
  - spec/extensions/after_initialize_spec.rb
@@ -747,6 +754,7 @@ files:
747
754
  - spec/extensions/serialization_modification_detection_spec.rb
748
755
  - spec/extensions/serialization_spec.rb
749
756
  - spec/extensions/server_block_spec.rb
757
+ - spec/extensions/server_logging_spec.rb
750
758
  - spec/extensions/set_overrides_spec.rb
751
759
  - spec/extensions/sharding_spec.rb
752
760
  - spec/extensions/shared_caching_spec.rb
@@ -756,6 +764,7 @@ files:
756
764
  - spec/extensions/spec_helper.rb
757
765
  - spec/extensions/split_array_nil_spec.rb
758
766
  - spec/extensions/split_values_spec.rb
767
+ - spec/extensions/sql_comments_spec.rb
759
768
  - spec/extensions/sql_expr_spec.rb
760
769
  - spec/extensions/static_cache_spec.rb
761
770
  - spec/extensions/string_date_time_spec.rb
@@ -819,6 +828,8 @@ files:
819
828
  - spec/files/reversible_migrations/003_reversible.rb
820
829
  - spec/files/reversible_migrations/004_reversible.rb
821
830
  - spec/files/reversible_migrations/005_reversible.rb
831
+ - spec/files/reversible_migrations/006_reversible.rb
832
+ - spec/files/reversible_migrations/007_reversible.rb
822
833
  - spec/files/timestamped_migrations/1273253849_create_sessions.rb
823
834
  - spec/files/timestamped_migrations/1273253851_create_nodes.rb
824
835
  - spec/files/timestamped_migrations/1273253853_3_create_users.rb
@@ -856,6 +867,9 @@ files:
856
867
  - spec/model/record_spec.rb
857
868
  - spec/model/spec_helper.rb
858
869
  - spec/model/validations_spec.rb
870
+ - spec/model_no_assoc_spec.rb
871
+ - spec/model_spec.rb
872
+ - spec/plugin_spec.rb
859
873
  - spec/sequel_coverage.rb
860
874
  - spec/spec_config.rb
861
875
  homepage: http://sequel.jeremyevans.net