sequel 4.44.0 → 4.45.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 (140) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +110 -0
  3. data/README.rdoc +8 -9
  4. data/doc/active_record.rdoc +2 -3
  5. data/doc/model_plugins.rdoc +1 -1
  6. data/doc/opening_databases.rdoc +0 -46
  7. data/doc/release_notes/4.45.0.txt +370 -0
  8. data/lib/sequel/adapters/cubrid.rb +2 -0
  9. data/lib/sequel/adapters/do.rb +2 -0
  10. data/lib/sequel/adapters/jdbc/as400.rb +2 -0
  11. data/lib/sequel/adapters/jdbc/cubrid.rb +2 -0
  12. data/lib/sequel/adapters/jdbc/firebirdsql.rb +2 -0
  13. data/lib/sequel/adapters/jdbc/informix-sqli.rb +2 -0
  14. data/lib/sequel/adapters/jdbc/jdbcprogress.rb +2 -0
  15. data/lib/sequel/adapters/jdbc/mysql.rb +1 -0
  16. data/lib/sequel/adapters/jdbc/postgresql.rb +5 -0
  17. data/lib/sequel/adapters/mysql.rb +1 -0
  18. data/lib/sequel/adapters/mysql2.rb +1 -0
  19. data/lib/sequel/adapters/odbc/oracle.rb +11 -0
  20. data/lib/sequel/adapters/odbc/progress.rb +2 -0
  21. data/lib/sequel/adapters/postgres.rb +0 -2
  22. data/lib/sequel/adapters/shared/cubrid.rb +2 -0
  23. data/lib/sequel/adapters/shared/firebird.rb +2 -0
  24. data/lib/sequel/adapters/shared/informix.rb +2 -0
  25. data/lib/sequel/adapters/shared/mssql.rb +47 -7
  26. data/lib/sequel/adapters/shared/mysql.rb +16 -1
  27. data/lib/sequel/adapters/shared/postgres.rb +9 -1
  28. data/lib/sequel/adapters/shared/progress.rb +2 -0
  29. data/lib/sequel/adapters/shared/sqlanywhere.rb +1 -1
  30. data/lib/sequel/adapters/swift.rb +2 -0
  31. data/lib/sequel/ast_transformer.rb +13 -6
  32. data/lib/sequel/core.rb +13 -16
  33. data/lib/sequel/database/connecting.rb +25 -10
  34. data/lib/sequel/database/dataset.rb +6 -1
  35. data/lib/sequel/database/dataset_defaults.rb +9 -2
  36. data/lib/sequel/database/misc.rb +10 -3
  37. data/lib/sequel/database/schema_methods.rb +4 -0
  38. data/lib/sequel/dataset/mutation.rb +8 -20
  39. data/lib/sequel/dataset/prepared_statements.rb +2 -0
  40. data/lib/sequel/dataset/query.rb +32 -7
  41. data/lib/sequel/dataset/sql.rb +13 -3
  42. data/lib/sequel/deprecated.rb +9 -1
  43. data/lib/sequel/exceptions.rb +37 -8
  44. data/lib/sequel/extensions/_deprecated_identifier_mangling.rb +117 -0
  45. data/lib/sequel/extensions/date_arithmetic.rb +1 -0
  46. data/lib/sequel/extensions/identifier_mangling.rb +3 -2
  47. data/lib/sequel/extensions/pg_hstore.rb +1 -5
  48. data/lib/sequel/extensions/schema_dumper.rb +3 -1
  49. data/lib/sequel/extensions/sequel_3_dataset_methods.rb +2 -2
  50. data/lib/sequel/extensions/string_agg.rb +1 -0
  51. data/lib/sequel/model.rb +23 -10
  52. data/lib/sequel/model/associations.rb +17 -5
  53. data/lib/sequel/model/base.rb +115 -62
  54. data/lib/sequel/model/dataset_module.rb +10 -3
  55. data/lib/sequel/model/exceptions.rb +7 -5
  56. data/lib/sequel/plugins/association_pks.rb +13 -1
  57. data/lib/sequel/plugins/association_proxies.rb +8 -1
  58. data/lib/sequel/plugins/before_after_save.rb +1 -0
  59. data/lib/sequel/plugins/class_table_inheritance.rb +7 -3
  60. data/lib/sequel/plugins/columns_updated.rb +42 -0
  61. data/lib/sequel/plugins/composition.rb +10 -5
  62. data/lib/sequel/plugins/error_splitter.rb +1 -1
  63. data/lib/sequel/plugins/hook_class_methods.rb +39 -5
  64. data/lib/sequel/plugins/instance_hooks.rb +58 -5
  65. data/lib/sequel/plugins/lazy_attributes.rb +10 -5
  66. data/lib/sequel/plugins/nested_attributes.rb +10 -5
  67. data/lib/sequel/plugins/prepared_statements.rb +7 -0
  68. data/lib/sequel/plugins/prepared_statements_associations.rb +2 -0
  69. data/lib/sequel/plugins/prepared_statements_with_pk.rb +2 -0
  70. data/lib/sequel/plugins/schema.rb +2 -0
  71. data/lib/sequel/plugins/scissors.rb +2 -0
  72. data/lib/sequel/plugins/serialization.rb +10 -5
  73. data/lib/sequel/plugins/split_values.rb +5 -1
  74. data/lib/sequel/plugins/static_cache.rb +2 -2
  75. data/lib/sequel/plugins/tactical_eager_loading.rb +1 -1
  76. data/lib/sequel/plugins/validation_contexts.rb +49 -0
  77. data/lib/sequel/plugins/validation_helpers.rb +1 -0
  78. data/lib/sequel/sql.rb +1 -1
  79. data/lib/sequel/version.rb +1 -1
  80. data/spec/adapters/mssql_spec.rb +31 -0
  81. data/spec/adapters/mysql_spec.rb +20 -2
  82. data/spec/adapters/postgres_spec.rb +43 -12
  83. data/spec/adapters/spec_helper.rb +5 -8
  84. data/spec/core/database_spec.rb +47 -12
  85. data/spec/core/dataset_mutation_spec.rb +22 -22
  86. data/spec/core/dataset_spec.rb +88 -20
  87. data/spec/core/deprecated_spec.rb +1 -1
  88. data/spec/core/expression_filters_spec.rb +1 -1
  89. data/spec/core/mock_adapter_spec.rb +0 -3
  90. data/spec/core/placeholder_literalizer_spec.rb +1 -1
  91. data/spec/core/schema_spec.rb +8 -1
  92. data/spec/core/spec_helper.rb +6 -1
  93. data/spec/core_extensions_spec.rb +4 -0
  94. data/spec/deprecation_helper.rb +17 -0
  95. data/spec/extensions/_deprecated_identifier_mangling_spec.rb +314 -0
  96. data/spec/extensions/association_pks_spec.rb +61 -13
  97. data/spec/extensions/association_proxies_spec.rb +3 -3
  98. data/spec/extensions/class_table_inheritance_spec.rb +39 -0
  99. data/spec/extensions/columns_updated_spec.rb +35 -0
  100. data/spec/extensions/composition_spec.rb +6 -1
  101. data/spec/extensions/hook_class_methods_spec.rb +114 -26
  102. data/spec/extensions/identifier_mangling_spec.rb +107 -73
  103. data/spec/extensions/instance_hooks_spec.rb +78 -14
  104. data/spec/extensions/lazy_attributes_spec.rb +8 -2
  105. data/spec/extensions/many_through_many_spec.rb +2 -2
  106. data/spec/extensions/mssql_optimistic_locking_spec.rb +1 -1
  107. data/spec/extensions/nested_attributes_spec.rb +8 -2
  108. data/spec/extensions/pg_array_spec.rb +18 -4
  109. data/spec/extensions/prepared_statements_associations_spec.rb +48 -39
  110. data/spec/extensions/prepared_statements_with_pk_spec.rb +13 -11
  111. data/spec/extensions/query_spec.rb +1 -1
  112. data/spec/extensions/schema_dumper_spec.rb +34 -6
  113. data/spec/extensions/schema_spec.rb +13 -7
  114. data/spec/extensions/scissors_spec.rb +3 -1
  115. data/spec/extensions/sequel_3_dataset_methods_spec.rb +4 -4
  116. data/spec/extensions/serialization_spec.rb +7 -1
  117. data/spec/extensions/set_overrides_spec.rb +2 -2
  118. data/spec/extensions/shared_caching_spec.rb +19 -15
  119. data/spec/extensions/spec_helper.rb +7 -3
  120. data/spec/extensions/split_values_spec.rb +45 -10
  121. data/spec/extensions/string_agg_spec.rb +2 -2
  122. data/spec/extensions/subset_conditions_spec.rb +3 -3
  123. data/spec/extensions/tactical_eager_loading_spec.rb +1 -1
  124. data/spec/extensions/validation_contexts_spec.rb +31 -0
  125. data/spec/guards_helper.rb +2 -0
  126. data/spec/integration/associations_test.rb +22 -20
  127. data/spec/integration/dataset_test.rb +25 -2
  128. data/spec/integration/model_test.rb +1 -1
  129. data/spec/integration/plugin_test.rb +11 -16
  130. data/spec/integration/prepared_statement_test.rb +40 -32
  131. data/spec/integration/spec_helper.rb +5 -8
  132. data/spec/model/association_reflection_spec.rb +4 -0
  133. data/spec/model/associations_spec.rb +37 -10
  134. data/spec/model/base_spec.rb +6 -0
  135. data/spec/model/hooks_spec.rb +56 -35
  136. data/spec/model/model_spec.rb +21 -5
  137. data/spec/model/record_spec.rb +14 -11
  138. data/spec/model/spec_helper.rb +7 -1
  139. data/spec/sequel_warning.rb +11 -0
  140. metadata +13 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f527b0eacda71627a6bfed400fce411509a1ce77
4
- data.tar.gz: ca7bf3f62b76c4618d59b825d270cca436d54d54
3
+ metadata.gz: 823afa5d16b89b8446d98fe80d985cadb2e58e65
4
+ data.tar.gz: 8bd6d96fc5c32b1199cf36cf955d93e4700b9308
5
5
  SHA512:
6
- metadata.gz: fb226f39b19f50d82d6eb712c685bb614f77e68e266c898c049bbb1c6345b6347cd661b06a1986be7f1c22add658036dc4f3960966bc2cea30e26e57e0554a36
7
- data.tar.gz: 4cb5d97a25593e77119726bba294145c8b5f3ee0503f12e52389c4fbe6f5a4cd4f2b6d7c2f5d592f5a58d3cc827e58824e4f03c282dff0146c2760142401163b
6
+ metadata.gz: 79ecfbb21f5fcfb61921baa56353338b2dfbe2311851b0811c91fbb42cacb2ec7952684e4c1abd1f4bf3afb5b380465945de0c673581672bccc2e5e3dea60ae9
7
+ data.tar.gz: 3bae1fbfc25de1394f74e8f76cf435ce9353d55d0cd2a95b0246a53dc27335f1dd00bfe0f6574372ae8edf85e94d776da9d79b91f6833c0ae9bcc2d8671bcfbf
data/CHANGELOG CHANGED
@@ -1,3 +1,113 @@
1
+ === 4.45.0 (2017-04-01)
2
+
3
+ * Correctly handle datasets with offsets but no limits used in compound datasets on MSSQL <2012 (jeremyevans)
4
+
5
+ * Correctly handle false values in the split_values plugin (bananarne) (#1333)
6
+
7
+ * Deprecate Dataset#dup/clone and Model.dup/clone (jeremyevans)
8
+
9
+ * Deprecate the schema and scissors plugins (jeremyevans)
10
+
11
+ * Deprecate Model.{lazy_attributes,nested_attributes,composition,serialization}_module accessors (jeremyevans)
12
+
13
+ * Deprecate Database#database_name on MySQL (jeremyevans)
14
+
15
+ * Deprecate Database#use on MySQL (jeremyevans)
16
+
17
+ * Make pg_hstore extension no longer update PG_NAMED_TYPES (jeremyevans)
18
+
19
+ * Deprecate Sequel::PG_NAMED_TYPES (jeremyevans)
20
+
21
+ * Add columns_updated plugin for making updated columns hash available in after_update and after_save hooks (jeremyevans)
22
+
23
+ * Deprecate accessing @columns_updated directly in model after_update and after_save hooks (jeremyevans)
24
+
25
+ * Deprecate Database#{add,remove}_servers when not using a sharded connection pool (jeremyevans)
26
+
27
+ * Deprecate Database#each_server (jeremyevans)
28
+
29
+ * Make Model#_valid? private method accept only an options hash (jeremyevans)
30
+
31
+ * Deprecate returning false from model before hooks to cancel the action, use Model#cancel_action (jeremyevans)
32
+
33
+ * Handle Model#cancel_action correctly in before hooks when Model#valid? is called (jeremyevans)
34
+
35
+ * Deprecate Sequel::BeforeHookFailed (jeremyevans)
36
+
37
+ * Deprecate passing multiple arguments as filter arguments when not using a conditions specifier (jeremyevans)
38
+
39
+ * Deprecate passing Procs as filter arguments, require they be passed as blocks (jeremyevans)
40
+
41
+ * Deprecate Sequel::Error::* exception class aliases (jeremyevans)
42
+
43
+ * Deprecate prepared_statements_associations and prepared_statements_with_pk plugins (jeremyevans)
44
+
45
+ * Deprecate Sequel::Unbinder, Sequel::UnbindDuplicate, and Dataset#unbind (jeremyevans)
46
+
47
+ * Deprecating calling Sequel::Qualifier with two arguments (jeremyevans)
48
+
49
+ * Add validation_contexts plugin for supporting custom contexts when validating (jeremyevans)
50
+
51
+ * Deprecate Sequel::Database.single_threaded singleton accessor (jeremyevans)
52
+
53
+ * Deprecate treating unrecognized prepared statement type as :select (jeremyevans)
54
+
55
+ * Deprecate Sequel.identifier_{in,out}put_method= and .quote_identifiers= singleton setters (jeremyevans)
56
+
57
+ * Deprecate Sequel::Database.identifier_{in,out}put_method and .quote_identifiers singleton accessors (jeremyevans)
58
+
59
+ * Deprecate loading the identifier_mangling by default, require it be loaded explicitly if needed (jeremyevans)
60
+
61
+ * Make Database#dump_{table_schema,schema_migration} in schema_dumper extension support :schema option (dadario) (#1328)
62
+
63
+ * Make Dataset#delete respect an existing limit on Microsoft SQL Server (jeremyevans)
64
+
65
+ * Add Dataset#skip_limit_check to mark a dataset as skipping the limit/offset check for updates and deletes (jeremyevans)
66
+
67
+ * Deprecate calling Dataset#{update/delete/truncate} on datasets with limits or offsets unless the database supports it (jeremyevans)
68
+
69
+ * Add deprecation message for using association_pks setter method with :delay_pks=>true association option (jeremyevans)
70
+
71
+ * Add deprecation message for using association_pks setter method without :delay_pks association option (jeremyevans)
72
+
73
+ * Deprecate having duplicate column names in subclass tables when using the class_table_inheritance plugin (jeremyevans)
74
+
75
+ * Deprecate do (DataObjects), swift, and jdbc/as400 adapters (jeremyevans)
76
+
77
+ * Deprecate support for Cubrid, Firebird, Informix, and Progress databases (jeremyevans)
78
+
79
+ * The :proxy_argument option passed to association_proxies plugin block is now an empty hash if no arguments are passed to the association method (jeremyevans)
80
+
81
+ * Deprecate passing non-hash arguments to association methods (jeremyevans)
82
+
83
+ * Deprecate passing multiple arguments to association methods (jeremyevans)
84
+
85
+ * Deprecate model transaction hook methods (jeremyevans)
86
+
87
+ * Drop support for pg <0.8.0 in the postgres adapter (jeremyevans)
88
+
89
+ * Deprecate passing a block to Database#from (jeremyevans)
90
+
91
+ * Deprecate Sequel::Model::ANONYMOUS_MODEL_CLASSES{,_MUTEX} (jeremyevans)
92
+
93
+ * Deprecate Sequel.cache_anonymous_models and Sequel.cache_anonymous_models= (jeremyevans)
94
+
95
+ * Automatically use from_self when using a dataset as part of a compound if it has an offset but no limit (jeremyevans)
96
+
97
+ * Drop order on existing datasets when using Dataset#union/intersect/except on Microsoft SQL Server unless a limit or offset is used (jeremyevans)
98
+
99
+ * Deprecate dataset mutation (jeremyevans)
100
+
101
+ * Handle dumping of autoincrementing 64-bit integer primary key columns correctly when using :same_db option in the schema dumper (jeremyevans) (#1324)
102
+
103
+ * Add Model.dataset_module_class accessor, allowing plugins to support custom behavior in dataset_module blocks (jeremyevans)
104
+
105
+ * Make ORDER BY come after UNION/INTERSECT/EXCEPT on Microsoft SQL Server and SQLAnywhere (jeremyevans)
106
+
107
+ * Make Database#indexes on MySQL handle qualified identifiers (jeremyevans) (#1316)
108
+
109
+ * Add oracle support to the odbc adapter (samuel02) (#1315)
110
+
1
111
  === 4.44.0 (2017-03-01)
2
112
 
3
113
  * Add where_all, where_each, where_single_value model dataset methods, optimized for frozen datasets (jeremyevans)
data/README.rdoc CHANGED
@@ -11,9 +11,9 @@ toolkit for Ruby.
11
11
  statements, bound variables, stored procedures, savepoints,
12
12
  two-phase commit, transaction isolation, master/slave
13
13
  configurations, and database sharding.
14
- * Sequel currently has adapters for ADO, Amalgalite, CUBRID,
15
- DataObjects, IBM_DB, JDBC, MySQL, Mysql2, ODBC, Oracle,
16
- PostgreSQL, SQLAnywhere, SQLite3, Swift, and TinyTDS.
14
+ * Sequel currently has adapters for ADO, Amalgalite,
15
+ IBM_DB, JDBC, MySQL, Mysql2, ODBC, Oracle,
16
+ PostgreSQL, SQLAnywhere, SQLite3, and TinyTDS.
17
17
 
18
18
  == Resources
19
19
 
@@ -512,15 +512,14 @@ Sequel model classes assume that the table name is an underscored plural of the
512
512
 
513
513
  You can explicitly set the table name or even the dataset used:
514
514
 
515
- class Post < Sequel::Model(:my_posts)
516
- end
515
+ class Post < Sequel::Model(:my_posts); end
517
516
  # or:
518
- Post.set_dataset :my_posts
517
+ class Post < Sequel::Model(DB[:my_posts]); end
519
518
 
520
- If you call +set_dataset+ with a symbol, it assumes you are referring to the table with the same name. You can also call it with a dataset, which will set the defaults for all retrievals for that model:
519
+ If you pass a symbol to the <tt>Sequel::Model</tt> method, it assumes you are referring to the table with the same name. You can also call it with a dataset, which will set the defaults for all retrievals for that model:
521
520
 
522
- Post.set_dataset DB[:my_posts].where(:category => 'ruby')
523
- Post.set_dataset DB[:my_posts].select(:id, :name).order(:date)
521
+ class Post < Sequel::Model(DB[:my_posts].where(:category => 'ruby')); end
522
+ class Post < Sequel::Model(DB[:my_posts].select(:id, :name).order(:date)); end
524
523
 
525
524
  === Model instances
526
525
 
@@ -535,10 +535,9 @@ If you want to use a specific <tt>Sequel::Database</tt> object, you can use <tt>
535
535
  BACKUP_DB = Sequel.connect('postgres://...')
536
536
  Album.db = BACKUP_DB
537
537
 
538
- If you want a specific dataset in that database, you can use +set_dataset+ or <tt>dataset=</tt>:
538
+ If you want a specific dataset in that database for a model, setup the model with a specific dataset:
539
539
 
540
- Album.set_dataset BACKUP_DB[:albums]
541
- Album.dataset = BACKUP_DB[:albums]
540
+ class Album < Sequel::Model(BACKUP_DB[:albums]); end
542
541
 
543
542
  ==== <tt>exists?</tt>
544
543
 
@@ -243,7 +243,7 @@ In many plugins, if the model class changes the dataset, you need to change the
243
243
  end
244
244
  end
245
245
 
246
- With this code, any time the model's dataset changes, the state of the plugin will be updated to set the correct table name.
246
+ With this code, any time the model's dataset changes, the state of the plugin will be updated to set the correct table name. This is also called when creating a new model class with a dataset.
247
247
 
248
248
  == Making Dataset Methods Callable as Class Methods
249
249
 
@@ -155,31 +155,6 @@ Without a database argument, assumes a memory database, so you can do:
155
155
  Handles paths in the connection string similar to the SQLite adapter, so see
156
156
  the sqlite section below for details.
157
157
 
158
- === cubrid
159
-
160
- cubrid is a ruby extension for accessing a CUBRID database. Currently,
161
- the ruby cubrid gem is in fairly rough state, with broken transaction
162
- support and some other issues, but most things work.
163
-
164
- === do
165
-
166
- Requires: data_objects
167
-
168
- The DataObjects adapter supports PostgreSQL, MySQL, and SQLite. One possible
169
- advantage of using DataObjects is that it does the typecasting in C, which may
170
- be faster than the other adapters.
171
-
172
- Similar to the JDBC adapter, the DO adapter only cares about connection strings,
173
- which can either be the String argument given to Sequel.connect directly or contained
174
- in a :uri or :url option. The DO adapter passes through the connection string
175
- directly to DataObjects, it does no processing of it (other than removing the do: prefix).
176
-
177
- Connection string examples:
178
-
179
- do:sqlite3::memory:
180
- do:postgres://user:password@host/database
181
- do:mysql://user:password@host/database
182
-
183
158
  === ibmdb
184
159
 
185
160
  requires 'ibm_db'
@@ -226,9 +201,6 @@ Example connection strings:
226
201
  jdbc:jtds:sqlserver://localhost/sequel_test;user=sequel_test;password=sequel_test
227
202
  jdbc:oracle:thin:user/password@localhost:1521:database
228
203
  jdbc:db2://localhost:3700/database:user=user;password=password;
229
- jdbc:firebirdsql:localhost/3050:/path/to/database.fdb
230
- jdbc:jdbcprogress:T:hostname:port:database
231
- jdbc:cubrid:hostname:port:database:::
232
204
  jdbc:sqlanywhere://localhost?DBN=Test;UID=user;PWD=password
233
205
 
234
206
  You can also use JNDI connection strings:
@@ -392,24 +364,6 @@ database is used. Attempts to force the use of more than 1 connection
392
364
  can result in weird behavior, since the connections will be to separate
393
365
  memory databases.
394
366
 
395
- === swift
396
-
397
- swift is a ruby 1.9+ library, so you'll need to be running ruby 1.9+. It
398
- can connect to SQLite, MySQL, and PostgreSQL, and you must specify which
399
- database using the db_type option.
400
-
401
- You need to install one of the swift db adapters
402
-
403
- * swift-db-sqlite3
404
- * swift-db-mysql
405
- * swift-db-postgres
406
-
407
- Examples:
408
-
409
- swift:///?database=:memory:&db_type=sqlite
410
- swift://root:root@localhost/test?db_type=mysql
411
- swift://root:root@localhost/test?db_type=postgres
412
-
413
367
  === tinytds
414
368
 
415
369
  Requires: tiny_tds
@@ -0,0 +1,370 @@
1
+ = Deprecated Features
2
+
3
+ * Dataset mutation is now deprecated. Users should switch to using
4
+ the non-mutating methods.
5
+
6
+ # Instead of:
7
+ dataset.where!(:foo)
8
+ # Switch to:
9
+ dataset = dataset.where(:foo)
10
+
11
+ * Support for the Cubrid, Firebird, Informix, and Progress databases
12
+ has been deprecated. Any users of this support should consider
13
+ creating an external adapter with the current code and maintaining
14
+ such support themselves.
15
+
16
+ * The do (DataObjects), swift, and jdbc/as400 adapters have been
17
+ deprecated. Any users of these adapters should consider creating an
18
+ external adapter with the current code and maintaining the adapter
19
+ themselves.
20
+
21
+ * Model transaction hooks (after_commit, after_rollback,
22
+ after_destroy_commit, after_destroy_rollback) are now deprecated.
23
+ Users should switch to calling the after_commit and after_rollback
24
+ database transaction hooks directly.
25
+
26
+ # Instead of:
27
+ def after_commit
28
+ super
29
+ do_something
30
+ end
31
+ # Switch to:
32
+ def after_save
33
+ super
34
+ db.after_commit{do_something}
35
+ end
36
+
37
+ * Passing a block to Database#from is now deprecated. For backwards
38
+ compatibility, this block affected the WHERE clause instead of the
39
+ FROM clause. In Sequel 5, Database#from blocks will be treated like
40
+ Dataset#from blocks, and will affect the FROM clause. This behavior
41
+ has been available for years by using the from_block extension.
42
+
43
+ # Instead of:
44
+ DB.from(:foo){a > b}
45
+ # Switch to:
46
+ DB.from(:foo).where{a > b}
47
+
48
+ * Passing non-hash arguments and multiple arguments to the
49
+ model association methods is now deprecated. Switch to using a
50
+ hash as an argument.
51
+
52
+ # Instead of:
53
+ model.association(true)
54
+ model.association(proc{|ds| ds.where(:foo)})
55
+ # Switch to:
56
+ model.association(:reload=>true)
57
+ model.association(:callback=>proc{|ds| ds.where(:foo)})
58
+ model.association{|ds| ds.where(:foo)}
59
+
60
+ * Passing procs as filter arguments is now deprecated. These should
61
+ now be passed as blocks instead of arguments.
62
+
63
+ # Instead of:
64
+ dataset.where(proc{foo > bar})
65
+ # Switch to:
66
+ dataset.where{foo > bar}
67
+
68
+ * Passing multiple arguments or an array as filter arguments when the
69
+ array/arguments does not represent a conditions specifier (array of
70
+ two element arrays, treated like a hash) is now deprecated. Switch
71
+ to calling the filter method separately with each argument or using
72
+ Sequel.& to combine the arguments:
73
+
74
+ # Instead of:
75
+ dataset.where(:foo, :bar)
76
+ dataset.where([:foo, :bar])
77
+ # Switch to:
78
+ dataset.where(:foo).where(:bar)
79
+ dataset.where(Sequel.&(:foo, :bar))
80
+
81
+ * Returning false from model before hooks to cancel an action is
82
+ now deprecated. Switch to calling cancel_action instead.
83
+
84
+ # Instead of:
85
+ def before_save
86
+ return false if something
87
+ super
88
+ end
89
+ # Switch to:
90
+ def before_save
91
+ cancel_action('something bad') if something
92
+ super
93
+ end
94
+
95
+ * Database#each_server has been deprecated. Switch to using
96
+ Database#servers and Database#with_server from server_block
97
+ extension:
98
+
99
+ # Instead of:
100
+ DB.each_server{|db| db.run("foo")}
101
+ # Switch to:
102
+ DB.extension :server_block
103
+ DB.servers.each{|s| DB.with_server(s){DB.run("foo")}}
104
+
105
+ * Calling Database#add_servers and Database#remove_servers on a
106
+ database that does not use the :servers option is now deprecated.
107
+ Currently, the calls to add_servers and remove_servers are
108
+ ignored for such databases, which can hide errors.
109
+
110
+ * Sequel::Postgres::PG_NAMED_TYPES is now deprecated. Switch to
111
+ calling Database#add_named_conversion_proc instead.
112
+
113
+ # Instead of:
114
+ require 'sequel/adapters/utils/pg_types'
115
+ Sequel::Postgres::PG_NAMED_TYPES[:foo] = lambda{|v| v}
116
+ DB = Sequel.connect('postgres://...')
117
+ # Switch to:
118
+ DB = Sequel.connect('postgres://...')
119
+ DB.add_named_conversion_proc(:foo){|v| v}
120
+
121
+ * Modifying the identifier mangling settings for a Database or
122
+ Dataset is now deprecated unless the identifier_mangling extension
123
+ is explicitly loaded into the Database instance.
124
+
125
+ * The Sequel::Database.single_threaded accessor is now deprecated.
126
+ Switch to using Sequel.single_threaded= and Sequel.single_threaded?.
127
+
128
+ * Sequel::Database.identifier_input_method,
129
+ Sequel::Database.identifier_output_method,
130
+ and Sequel::Database.quote_identifier accessors are now deprecated.
131
+ Switch to modifying the setting for each Database instance.
132
+
133
+ * Sequel.identifier_input_method=, Sequel.identifier_output_method=,
134
+ and Sequel.quote_identifer= setter methods are now deprecated.
135
+ Switch to modifying the setting for each Database instance.
136
+
137
+ * Calling Dataset#delete/update/truncate on datasets with limits
138
+ or offsets is now deprecated, unless the database will respect
139
+ the limit or offset. Currently, only MySQL and Microsoft SQL
140
+ Server have limited support for such deletes and updates. You
141
+ should either call unlimited or skip_limit_check before calling
142
+ delete/update/truncate.
143
+
144
+ * Deprecate having duplicate column names in subclass tables when
145
+ using the class_table_inheritance plugin. The documentation has
146
+ warned against this for a long time, but the code did not enforce
147
+ it.
148
+
149
+ * When using the association_pks plugin setter methods without the
150
+ :delay_pks association option set, a warning is now issued. In
151
+ Sequel 5, the default will be to assume that the :delay_pks
152
+ option is :always, and not to make modifications until the object
153
+ is saved. If you would like to keep the current behavior, set
154
+ the :delay_pks=>false association option.
155
+
156
+ The current :delay_pks=>true behavior will be removed in Sequel 5,
157
+ with it being treated like :delay_pks=>:always. If you are relying
158
+ on the current behavior of :delay_pks=>true (delay for new objects,
159
+ immediate for existing objects), you will need to update your code.
160
+
161
+ * Database#dup/clone are now deprecated. They have never been
162
+ handled correctly, since the default implementation from Kernel
163
+ has been used.
164
+
165
+ * Model.dup/clone are now deprecated. They have never been
166
+ handled correctly, as the default implemenation from Kernel/Module
167
+ has been used.
168
+
169
+ * Database#use on MySQL is now deprecated. Switch to creating a new
170
+ Database instance instead of modifying the database for an existing
171
+ instance.
172
+
173
+ * Database#database_name on MySQL is now deprecated. Switch to asking
174
+ the database server which database you are connected to:
175
+
176
+ # Instead of:
177
+ DB.database_name
178
+ # Switch to:
179
+ DB.get{DATABASE{}}
180
+
181
+ * In the lazy_attributes, nested_attributes, composition, and
182
+ serialization plugins, the *_module accessors are now deprecated.
183
+ These were implementation details that should not have been
184
+ exposed.
185
+
186
+ * The schema plugin is now deprecated. Switch to defining the schema
187
+ before creating the model class using the Database schema methods.
188
+
189
+ * The scissors plugin is deprecated. It existed for compatibility
190
+ with Sequel 3, but it is dangerous as it makes it easier to modify
191
+ all rows when the intent was to modify a single row.
192
+
193
+ * The prepared_statements_associations and prepared_statements_with_pk
194
+ plugins are now deprecated. These plugins generally make things
195
+ slower.
196
+
197
+ * Dataset#unbind, Sequel::Unbinder, and Sequel::UnbindDuplicate are
198
+ now deprecated. This mostly existed to support the
199
+ prepared_statements_associations and prepared_statements_with_pk
200
+ plugins.
201
+
202
+ * Sequel::Error::* exception class aliases are now deprecated. Switch
203
+ to using the exception classes in the Sequel namespace.
204
+
205
+ * Sequel::BeforeHookFailed is now deprecated. Switch to using
206
+ Sequel::HookFailed.
207
+
208
+ * Calling Sequel::Qualifier.new with 2 arguments is now deprecated.
209
+ Users should switch to calling it with a single argument (the
210
+ table used for qualifying unqualified identifiers).
211
+
212
+ * Treating unrecognized prepared statement types as :select is now
213
+ deprecated. Switch to using :select as the prepared statement
214
+ type.
215
+
216
+ * The @was_new instance variable available in model after_save hooks
217
+ is now deprecated. There is no deprecation warning associated
218
+ with this change.
219
+
220
+ # Instead of:
221
+ def after_save
222
+ super
223
+ if @was_new
224
+ do_something
225
+ else
226
+ do_something_else
227
+ end
228
+ end
229
+ # Switch to:
230
+ def after_create
231
+ super
232
+ do_something
233
+ end
234
+ def after_update
235
+ super
236
+ do_something_else
237
+ end
238
+
239
+ * The @columns_updated instance variable available in model
240
+ after_save and after_update hooks is deprecated. Switch to
241
+ using the new columns_updated plugin and calling the
242
+ columns_updated method.
243
+
244
+ * The Sequel.cache_anonymous_models accessor has been deprecated.
245
+ Switch to using Sequel::Model.cache_anonymous_models.
246
+
247
+ * Sequel::Model::ANONYMOUS_MODEL_CLASSES and
248
+ Sequel::Model::ANONYMOUS_MODEL_CLASSES_MUTEX have been
249
+ deprecated.
250
+
251
+ * Sequel::Database::ResetIdentifierMangling has been deprecated.
252
+
253
+ = New Features
254
+
255
+ * A validation_contexts plugin has been added, which adds support
256
+ for a :validation_context option to Model#save and Model#valid?.
257
+ The value for this option will be available via the
258
+ validation_context method inside the validation hooks and
259
+ validate method.
260
+
261
+ class Album < Sequel::Model
262
+ plugin :validation_contexts
263
+
264
+ def validate
265
+ super
266
+ if validation_context == :approve
267
+ errors.add(:status_id, 'not 42') unless status_id == 42
268
+ end
269
+ end
270
+ end
271
+
272
+ album = Album.first
273
+ album.status_id = 41
274
+ album.valid?(:validation_context=>:approve) # => false
275
+ album.status_id = 42
276
+ album.valid?(:validation_context=>:approve) # => true
277
+
278
+ * A columns_updated plugin has been added, allowing you to get
279
+ access to the hash used for updating a model instance via the
280
+ columns_updated method:
281
+
282
+ class Album < Sequel::Model
283
+ plugin :columns_updated
284
+
285
+ def after_update
286
+ super
287
+ if columns_updated.has_key?(:foo)
288
+ do_something(columns_updated[:foo])
289
+ end
290
+ end
291
+ end
292
+
293
+ * Dataset#delete on Microsoft SQL Server now respects limits. Note
294
+ that Microsoft SQL Server does not respect orders for deletes, only
295
+ limits, which makes this support not very useful. Currently a
296
+ deprecation warning will be issued when using a delete with an
297
+ order and a limit, and in Sequel 5 an exception will be raised.
298
+
299
+ * An odbc/oracle subadapter has been added.
300
+
301
+ * A Model.dataset_module_class accessor has been added, allowing
302
+ plugins to add support for custom behavior in dataset_module blocks.
303
+
304
+ * Support for deprecating constants on Ruby 2.3+ has been added.
305
+ Note that you will only get warnings for deprecated constant
306
+ use if you are running on Ruby 2.3+. If you are running on a
307
+ previous version of Ruby, you should scan your code manually for
308
+ deprecated constant use.
309
+
310
+ = Other Improvements
311
+
312
+ * Using Model#cancel_action inside validation hooks now works
313
+ correctly when Model#valid? is called.
314
+
315
+ * Model#[] now handles columns with false values correctly when using
316
+ the split_values plugin.
317
+
318
+ * When calling Dataset#union/intersect/except on a dataset with
319
+ an offset but no limit, the dataset is wrapped in a subquery, just
320
+ like a dataset with a limit.
321
+
322
+ * The dumping of 64-bit autoincrementing primary key columns by the
323
+ schema_dumper extension is now handled correctly when using the
324
+ :same_db option.
325
+
326
+ * The schema_dumper extension now supports the :schema option when
327
+ dumping schema.
328
+
329
+ * On Microsoft SQL Server and SQLAnywhere, ORDER BY clauses now come
330
+ after UNION/INTERSECT/EXCEPT instead of before, fixing issues when
331
+ the :from_self=>false option is used with union/intersect/except
332
+ and an order is applied afterward.
333
+
334
+ * On Microsoft SQL Server, if calling Dataset#union/intersect/except
335
+ on a dataset with an order and without a limit or offset, the order
336
+ is removed. When using UNION/INTERSECT/EXCEPT, Microsoft SQL
337
+ Server does not guarantee any ordering unless you specify an order
338
+ for the compound dataset. As a general rule, you should always
339
+ apply orders after compounds instead of before.
340
+
341
+ * On Microsoft SQL Server <2012, when using a dataset with an offset
342
+ without a limit in a UNION/INTERSECT/EXCEPT query, Sequel now uses
343
+ TOP (100) PERCENT to work around the limitation that using orders
344
+ in subqueries is not supported unless there is a limit (offsets
345
+ are emulated by a ROW_NUMBER window function with an order in this
346
+ case).
347
+
348
+ * Database#indexes on MySQL now handles qualified identifiers.
349
+
350
+ * Sequel now literalizes Sequel::SQLTime instances with 3 fractional
351
+ digits in the jdbc/postgresql adapter, fixing issues on JRuby
352
+ 9.1.8.0+ (the first JRuby version to support greater than
353
+ millisecond precision).
354
+
355
+ = Backwards Compatibility
356
+
357
+ * When using the association_proxies plugin and passing a block when
358
+ loading the plugin, the :proxy_argument option in hash passed to
359
+ the block is now an empty hash instead of nil if no argument was
360
+ given to the association method.
361
+
362
+ * The private Model#_valid? method now takes a single options hash
363
+ argument, instead of 2 arguments.
364
+
365
+ * The pg_hstore extension no longer modifies PG_NAMED_TYPES. This
366
+ should not affect behavior if the pg_hstore extension is loaded
367
+ into the Database instance.
368
+
369
+ * Support for pg <0.8.0 has been dropped. pg 0.8.0 was released in
370
+ January 2008.