sequel 3.21.0 → 3.32.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 (234) hide show
  1. data/CHANGELOG +539 -3
  2. data/MIT-LICENSE +1 -1
  3. data/README.rdoc +20 -6
  4. data/Rakefile +37 -19
  5. data/bin/sequel +1 -5
  6. data/doc/advanced_associations.rdoc +17 -0
  7. data/doc/association_basics.rdoc +293 -43
  8. data/doc/dataset_basics.rdoc +4 -4
  9. data/doc/dataset_filtering.rdoc +8 -0
  10. data/doc/mass_assignment.rdoc +54 -0
  11. data/doc/migration.rdoc +15 -538
  12. data/doc/model_hooks.rdoc +72 -27
  13. data/doc/opening_databases.rdoc +89 -50
  14. data/doc/prepared_statements.rdoc +40 -13
  15. data/doc/reflection.rdoc +8 -2
  16. data/doc/release_notes/3.22.0.txt +39 -0
  17. data/doc/release_notes/3.23.0.txt +172 -0
  18. data/doc/release_notes/3.24.0.txt +420 -0
  19. data/doc/release_notes/3.25.0.txt +88 -0
  20. data/doc/release_notes/3.26.0.txt +88 -0
  21. data/doc/release_notes/3.27.0.txt +82 -0
  22. data/doc/release_notes/3.28.0.txt +304 -0
  23. data/doc/release_notes/3.29.0.txt +459 -0
  24. data/doc/release_notes/3.30.0.txt +135 -0
  25. data/doc/release_notes/3.31.0.txt +146 -0
  26. data/doc/release_notes/3.32.0.txt +202 -0
  27. data/doc/schema_modification.rdoc +547 -0
  28. data/doc/sharding.rdoc +7 -1
  29. data/doc/testing.rdoc +129 -0
  30. data/doc/transactions.rdoc +137 -0
  31. data/doc/virtual_rows.rdoc +2 -2
  32. data/lib/sequel/adapters/ado/mssql.rb +18 -6
  33. data/lib/sequel/adapters/ado.rb +40 -18
  34. data/lib/sequel/adapters/amalgalite.rb +17 -9
  35. data/lib/sequel/adapters/db2.rb +175 -86
  36. data/lib/sequel/adapters/dbi.rb +15 -15
  37. data/lib/sequel/adapters/do/mysql.rb +5 -7
  38. data/lib/sequel/adapters/do/postgres.rb +0 -5
  39. data/lib/sequel/adapters/do/sqlite.rb +0 -5
  40. data/lib/sequel/adapters/do.rb +17 -36
  41. data/lib/sequel/adapters/firebird.rb +27 -208
  42. data/lib/sequel/adapters/ibmdb.rb +448 -0
  43. data/lib/sequel/adapters/informix.rb +6 -23
  44. data/lib/sequel/adapters/jdbc/as400.rb +16 -34
  45. data/lib/sequel/adapters/jdbc/db2.rb +52 -0
  46. data/lib/sequel/adapters/jdbc/derby.rb +260 -0
  47. data/lib/sequel/adapters/jdbc/firebird.rb +29 -0
  48. data/lib/sequel/adapters/jdbc/h2.rb +66 -30
  49. data/lib/sequel/adapters/jdbc/hsqldb.rb +177 -0
  50. data/lib/sequel/adapters/jdbc/informix.rb +26 -0
  51. data/lib/sequel/adapters/jdbc/jtds.rb +34 -0
  52. data/lib/sequel/adapters/jdbc/mssql.rb +3 -33
  53. data/lib/sequel/adapters/jdbc/mysql.rb +11 -11
  54. data/lib/sequel/adapters/jdbc/oracle.rb +88 -25
  55. data/lib/sequel/adapters/jdbc/postgresql.rb +9 -13
  56. data/lib/sequel/adapters/jdbc/sqlite.rb +2 -6
  57. data/lib/sequel/adapters/jdbc/sqlserver.rb +71 -0
  58. data/lib/sequel/adapters/jdbc/transactions.rb +83 -0
  59. data/lib/sequel/adapters/jdbc.rb +231 -78
  60. data/lib/sequel/adapters/mock.rb +339 -0
  61. data/lib/sequel/adapters/mysql.rb +85 -184
  62. data/lib/sequel/adapters/mysql2.rb +26 -25
  63. data/lib/sequel/adapters/odbc/db2.rb +17 -0
  64. data/lib/sequel/adapters/odbc/mssql.rb +1 -6
  65. data/lib/sequel/adapters/odbc.rb +28 -9
  66. data/lib/sequel/adapters/openbase.rb +3 -5
  67. data/lib/sequel/adapters/oracle.rb +355 -53
  68. data/lib/sequel/adapters/postgres.rb +194 -33
  69. data/lib/sequel/adapters/shared/access.rb +32 -9
  70. data/lib/sequel/adapters/shared/db2.rb +328 -0
  71. data/lib/sequel/adapters/shared/firebird.rb +221 -0
  72. data/lib/sequel/adapters/shared/informix.rb +53 -0
  73. data/lib/sequel/adapters/shared/mssql.rb +278 -107
  74. data/lib/sequel/adapters/shared/mysql.rb +203 -65
  75. data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +149 -0
  76. data/lib/sequel/adapters/shared/oracle.rb +237 -46
  77. data/lib/sequel/adapters/shared/postgres.rb +214 -82
  78. data/lib/sequel/adapters/shared/progress.rb +5 -8
  79. data/lib/sequel/adapters/shared/sqlite.rb +200 -50
  80. data/lib/sequel/adapters/sqlite.rb +29 -21
  81. data/lib/sequel/adapters/swift/mysql.rb +12 -7
  82. data/lib/sequel/adapters/swift/postgres.rb +0 -5
  83. data/lib/sequel/adapters/swift/sqlite.rb +8 -6
  84. data/lib/sequel/adapters/swift.rb +5 -5
  85. data/lib/sequel/adapters/tinytds.rb +160 -19
  86. data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +66 -0
  87. data/lib/sequel/adapters/utils/stored_procedures.rb +1 -11
  88. data/lib/sequel/ast_transformer.rb +190 -0
  89. data/lib/sequel/connection_pool/threaded.rb +3 -2
  90. data/lib/sequel/connection_pool.rb +1 -1
  91. data/lib/sequel/core.rb +68 -5
  92. data/lib/sequel/database/connecting.rb +5 -6
  93. data/lib/sequel/database/dataset.rb +4 -4
  94. data/lib/sequel/database/dataset_defaults.rb +59 -1
  95. data/lib/sequel/database/logging.rb +1 -1
  96. data/lib/sequel/database/misc.rb +104 -19
  97. data/lib/sequel/database/query.rb +163 -59
  98. data/lib/sequel/database/schema_generator.rb +17 -7
  99. data/lib/sequel/database/schema_methods.rb +59 -29
  100. data/lib/sequel/dataset/actions.rb +240 -76
  101. data/lib/sequel/dataset/features.rb +91 -8
  102. data/lib/sequel/dataset/graph.rb +38 -11
  103. data/lib/sequel/dataset/misc.rb +50 -23
  104. data/lib/sequel/dataset/mutation.rb +12 -7
  105. data/lib/sequel/dataset/prepared_statements.rb +59 -27
  106. data/lib/sequel/dataset/query.rb +236 -43
  107. data/lib/sequel/dataset/sql.rb +676 -267
  108. data/lib/sequel/dataset.rb +8 -0
  109. data/lib/sequel/exceptions.rb +4 -0
  110. data/lib/sequel/extensions/columns_introspection.rb +61 -0
  111. data/lib/sequel/extensions/migration.rb +6 -4
  112. data/lib/sequel/extensions/named_timezones.rb +5 -0
  113. data/lib/sequel/extensions/query.rb +1 -1
  114. data/lib/sequel/extensions/thread_local_timezones.rb +1 -1
  115. data/lib/sequel/extensions/to_dot.rb +95 -83
  116. data/lib/sequel/model/associations.rb +1081 -344
  117. data/lib/sequel/model/base.rb +420 -133
  118. data/lib/sequel/model/errors.rb +1 -1
  119. data/lib/sequel/model/exceptions.rb +5 -1
  120. data/lib/sequel/model.rb +20 -10
  121. data/lib/sequel/plugins/active_model.rb +13 -1
  122. data/lib/sequel/plugins/association_pks.rb +22 -4
  123. data/lib/sequel/plugins/class_table_inheritance.rb +4 -4
  124. data/lib/sequel/plugins/composition.rb +43 -10
  125. data/lib/sequel/plugins/dataset_associations.rb +100 -0
  126. data/lib/sequel/plugins/defaults_setter.rb +58 -0
  127. data/lib/sequel/plugins/force_encoding.rb +6 -6
  128. data/lib/sequel/plugins/identity_map.rb +114 -7
  129. data/lib/sequel/plugins/many_through_many.rb +68 -7
  130. data/lib/sequel/plugins/nested_attributes.rb +65 -10
  131. data/lib/sequel/plugins/prepared_statements.rb +151 -0
  132. data/lib/sequel/plugins/prepared_statements_associations.rb +84 -0
  133. data/lib/sequel/plugins/prepared_statements_safe.rb +82 -0
  134. data/lib/sequel/plugins/prepared_statements_with_pk.rb +59 -0
  135. data/lib/sequel/plugins/rcte_tree.rb +29 -15
  136. data/lib/sequel/plugins/serialization.rb +98 -49
  137. data/lib/sequel/plugins/serialization_modification_detection.rb +63 -0
  138. data/lib/sequel/plugins/sharding.rb +21 -54
  139. data/lib/sequel/plugins/single_table_inheritance.rb +3 -1
  140. data/lib/sequel/plugins/typecast_on_load.rb +9 -12
  141. data/lib/sequel/plugins/update_primary_key.rb +2 -2
  142. data/lib/sequel/plugins/xml_serializer.rb +3 -3
  143. data/lib/sequel/sql.rb +109 -52
  144. data/lib/sequel/timezones.rb +57 -38
  145. data/lib/sequel/version.rb +1 -1
  146. data/spec/adapters/db2_spec.rb +146 -0
  147. data/spec/adapters/mssql_spec.rb +135 -30
  148. data/spec/adapters/mysql_spec.rb +244 -212
  149. data/spec/adapters/oracle_spec.rb +67 -77
  150. data/spec/adapters/postgres_spec.rb +267 -78
  151. data/spec/adapters/spec_helper.rb +6 -5
  152. data/spec/adapters/sqlite_spec.rb +35 -21
  153. data/spec/core/connection_pool_spec.rb +71 -92
  154. data/spec/core/core_sql_spec.rb +21 -30
  155. data/spec/core/database_spec.rb +789 -512
  156. data/spec/core/dataset_spec.rb +1176 -1061
  157. data/spec/core/expression_filters_spec.rb +159 -42
  158. data/spec/core/mock_adapter_spec.rb +419 -0
  159. data/spec/core/object_graph_spec.rb +86 -114
  160. data/spec/core/schema_generator_spec.rb +3 -3
  161. data/spec/core/schema_spec.rb +298 -38
  162. data/spec/core/spec_helper.rb +6 -48
  163. data/spec/extensions/active_model_spec.rb +13 -0
  164. data/spec/extensions/association_autoreloading_spec.rb +1 -10
  165. data/spec/extensions/association_dependencies_spec.rb +2 -12
  166. data/spec/extensions/association_pks_spec.rb +66 -32
  167. data/spec/extensions/caching_spec.rb +23 -50
  168. data/spec/extensions/class_table_inheritance_spec.rb +31 -83
  169. data/spec/extensions/columns_introspection_spec.rb +91 -0
  170. data/spec/extensions/composition_spec.rb +18 -13
  171. data/spec/extensions/dataset_associations_spec.rb +199 -0
  172. data/spec/extensions/defaults_setter_spec.rb +64 -0
  173. data/spec/extensions/hook_class_methods_spec.rb +65 -91
  174. data/spec/extensions/identity_map_spec.rb +114 -22
  175. data/spec/extensions/instance_filters_spec.rb +11 -21
  176. data/spec/extensions/instance_hooks_spec.rb +53 -0
  177. data/spec/extensions/json_serializer_spec.rb +4 -5
  178. data/spec/extensions/lazy_attributes_spec.rb +16 -20
  179. data/spec/extensions/list_spec.rb +17 -39
  180. data/spec/extensions/many_through_many_spec.rb +283 -250
  181. data/spec/extensions/migration_spec.rb +35 -32
  182. data/spec/extensions/named_timezones_spec.rb +23 -3
  183. data/spec/extensions/nested_attributes_spec.rb +97 -88
  184. data/spec/extensions/optimistic_locking_spec.rb +9 -20
  185. data/spec/extensions/prepared_statements_associations_spec.rb +111 -0
  186. data/spec/extensions/prepared_statements_safe_spec.rb +61 -0
  187. data/spec/extensions/prepared_statements_spec.rb +53 -0
  188. data/spec/extensions/prepared_statements_with_pk_spec.rb +31 -0
  189. data/spec/extensions/pretty_table_spec.rb +1 -6
  190. data/spec/extensions/query_spec.rb +6 -0
  191. data/spec/extensions/rcte_tree_spec.rb +41 -43
  192. data/spec/extensions/schema_dumper_spec.rb +5 -8
  193. data/spec/extensions/schema_spec.rb +13 -21
  194. data/spec/extensions/serialization_modification_detection_spec.rb +72 -0
  195. data/spec/extensions/serialization_spec.rb +81 -43
  196. data/spec/extensions/sharding_spec.rb +66 -140
  197. data/spec/extensions/single_table_inheritance_spec.rb +18 -29
  198. data/spec/extensions/spec_helper.rb +13 -61
  199. data/spec/extensions/sql_expr_spec.rb +20 -60
  200. data/spec/extensions/tactical_eager_loading_spec.rb +9 -19
  201. data/spec/extensions/thread_local_timezones_spec.rb +22 -2
  202. data/spec/extensions/timestamps_spec.rb +6 -6
  203. data/spec/extensions/to_dot_spec.rb +4 -7
  204. data/spec/extensions/touch_spec.rb +13 -14
  205. data/spec/extensions/tree_spec.rb +11 -26
  206. data/spec/extensions/typecast_on_load_spec.rb +1 -6
  207. data/spec/extensions/update_primary_key_spec.rb +30 -24
  208. data/spec/extensions/validation_class_methods_spec.rb +30 -51
  209. data/spec/extensions/validation_helpers_spec.rb +16 -35
  210. data/spec/extensions/xml_serializer_spec.rb +16 -4
  211. data/spec/integration/associations_test.rb +661 -21
  212. data/spec/integration/database_test.rb +4 -2
  213. data/spec/integration/dataset_test.rb +500 -67
  214. data/spec/integration/eager_loader_test.rb +19 -21
  215. data/spec/integration/model_test.rb +80 -1
  216. data/spec/integration/plugin_test.rb +367 -119
  217. data/spec/integration/prepared_statement_test.rb +222 -125
  218. data/spec/integration/schema_test.rb +217 -39
  219. data/spec/integration/spec_helper.rb +39 -30
  220. data/spec/integration/timezone_test.rb +38 -12
  221. data/spec/integration/transaction_test.rb +182 -5
  222. data/spec/integration/type_test.rb +17 -3
  223. data/spec/model/association_reflection_spec.rb +201 -7
  224. data/spec/model/associations_spec.rb +955 -662
  225. data/spec/model/base_spec.rb +275 -95
  226. data/spec/model/dataset_methods_spec.rb +7 -27
  227. data/spec/model/eager_loading_spec.rb +677 -676
  228. data/spec/model/hooks_spec.rb +349 -67
  229. data/spec/model/model_spec.rb +222 -168
  230. data/spec/model/plugins_spec.rb +24 -13
  231. data/spec/model/record_spec.rb +381 -218
  232. data/spec/model/spec_helper.rb +13 -71
  233. data/spec/model/validations_spec.rb +11 -0
  234. metadata +117 -73
@@ -0,0 +1,146 @@
1
+ = New Features
2
+
3
+ * The serialization plugin can now support custom serialization
4
+ formats, by supplying a serializer/deserializer pair of
5
+ callable objects. You can also register custom deserializers
6
+ via Sequel::Plugins::Serialization.register_format, so that
7
+ they can be referenced by name. Example:
8
+
9
+ Sequel::Plugins::Serialization.register_format(:reverse,
10
+ lambda{|v| v.reverse},
11
+ lambda{|v| v.reverse})
12
+ class User < Sequel::Model
13
+ serialize_attributes :reverse, :password
14
+ end
15
+
16
+ * Dataset#import and #multi_insert now support a
17
+ :return=>:primary_key option. When this option is used, the
18
+ methods return an array of primary key values, one for each
19
+ inserted row. Usage of this option on MySQL requires that a
20
+ separate query be issued per row (instead of the single
21
+ query for all rows that MySQL would usually use).
22
+
23
+ * PostgreSQL can now use Dataset#returning in conjunction with
24
+ import/multi_insert to set a custom column to return.
25
+
26
+ * Microsoft SQL Server can now use Dataset#output in conjection with
27
+ import/multi_insert to set a custom column to return.
28
+
29
+ * Dataset#import and #multi_insert now respect a :server option to
30
+ set the server/shard on which to execute the queries.
31
+ Additionally, options given to this method are also passed to
32
+ Dataset#transaction.
33
+
34
+ * Dataset#insert_multiple now returns an array of inserted primary
35
+ keys.
36
+
37
+ * Model.def_column_alias has been added to make it easy to create
38
+ alias methods for columns. This is useful if you have a legacy
39
+ database and want to create friendly method names for the
40
+ underlying columns. Note that this alias only affects the setter
41
+ and getter methods. This does not affect the dataset level, so you
42
+ still need to use the actual column names in dataset filters.
43
+
44
+ * many_to_one associations can now have the same name as the related
45
+ foreign key column, using the :key_column option. Use of this
46
+ feature is not recommended, as it is much better to either rename
47
+ the column or rename the association. Here's an example of usage:
48
+
49
+ # Example schema:
50
+ # albums artists
51
+ # :id /--> :id
52
+ # :artist --/ :name
53
+ # :name
54
+ class Album < Sequel::Model
55
+ def_column_alias(:artist_id, :artist)
56
+ many_to_one :artist, :key_column=>:artist
57
+ end
58
+
59
+ * The mock adapter can now mock out database types, by providing a
60
+ shared adapter name as the host (e.g. mock://postgres). This
61
+ emulation is not perfect, but in most cases it allows you to see
62
+ what SQL Sequel would generate on a given database without needing
63
+ to install the required database driver.
64
+
65
+ * Sequel now supports creating full text indexes on Microsoft SQL
66
+ Server. Before using it, you must have previously setup a default
67
+ full text search catalog, and you need to provide a :key_index
68
+ option with an index name symbol.
69
+
70
+ * Dataset#group_rollup and #group_cube methods have been added for
71
+ GROUP BY ROLLUP and GROUP BY CUBE support. These features are in
72
+ a recent SQL standard, and they are supported to various degrees on
73
+ Microsoft SQL Server, DB2, Oracle, MySQL, and Derby.
74
+
75
+ * Dataset#full_text_search on Microsoft SQL Server now supports
76
+ multiple search terms.
77
+
78
+ * The jdbc adapter now supports a :login_timeout option, giving the
79
+ timeout in seconds.
80
+
81
+ = Other Improvements
82
+
83
+ * Dataset#exists can now be used with prepared statement
84
+ placeholders.
85
+
86
+ * Dataset#full_text_search can now be used with prepared statement
87
+ placeholders on PostgreSQL, MySQL, and Microsoft SQL Server.
88
+
89
+ * If tables from two separate schema are detected when parsing the
90
+ schema for a table on PostgreSQL, an error is now raised.
91
+ Previously, no error was raised, which led to weird errors later,
92
+ such as duplicate columns in a model's primary_key.
93
+
94
+ * RETURNING is now supported with UPDATE/DELETE on PostgreSQL 8.2+.
95
+ Previously, Sequel only supported it on 9.1+, but PostgreSQL
96
+ introduced support for it in 8.2.
97
+
98
+ * The shared postgres adapter now correctly handles the return value
99
+ for Dataset#insert if you provide a separate column array and value
100
+ array on PostgreSQL < 8.2.
101
+
102
+ * Handle case in the PostgreSQL adapter where the server version
103
+ cannot be determined via a query.
104
+
105
+ * H2 clob types are now treated as string instead of as blob.
106
+ Treating clob as blob breaks on H2, as it doesn't automatically
107
+ hex-unescape the input for clobs as it does for blobs.
108
+
109
+ * Dataset#empty? now works correctly when the dataset has an offset
110
+ and offset support is being emulated.
111
+
112
+ * The mock adapter no longer defaults to downcasing identifiers on
113
+ output.
114
+
115
+ = Backwards Compatibility
116
+
117
+ * Dataset#exists now returns a PlaceholderLiteralString instead of a
118
+ LiteralString, which could potentially break some code. If you
119
+ would like a String returned, you can pass the returned object to
120
+ Dataset#literal:
121
+
122
+ dataset.literal(dataset.exists)
123
+
124
+ * Dataset#from no longer handles :a__b__c___d as "a.b.c AS d". This
125
+ was not the intended behavior, and nowhere else in Sequel is a
126
+ symbol treated that way. Now, Dataset#from is consistent with the
127
+ rest of Sequel, using "a.b__c AS d". This should only affect
128
+ people in very rare cases, as most databases don't use three level
129
+ qualified tables. One exception is Microsoft SQL Server, which can
130
+ use three level qualified tables for cross-database access.
131
+
132
+ * Previously, Dataset#insert_multiple returned an array of hashes, now
133
+ it returns an array of primary key values.
134
+
135
+ * Dataset#EXRACT_CLOSE in the shared sqlite adapter has been renamed to
136
+ Dataset#EXTRACT_CLOSE.
137
+
138
+ * Dataset::StoredProcedureMethods::SQL_QUERY_TYPE and
139
+ Dataset::ArgumentMapper::SQL_QUERY_TYPE constants have been removed,
140
+ as have related sql_query_type private methods.
141
+
142
+ * The serialization plugin was significantly refactored.
143
+ Model.serialization_map now contains a callable object instead of a
144
+ Symbol, and Model.serialization_format has been removed.
145
+ Model.define_serialized_attribute_accessors private method now takes
146
+ two callable objects before the columns, instead of a single symbol.
@@ -0,0 +1,202 @@
1
+ = New Features
2
+
3
+ * Prepared statements now support :map and :to_hash prepared
4
+ statement types. The main reason for this is that certain
5
+ extensions (e.g. sequel_pg) optimize map/to_hash calls, and
6
+ there previously was not a way to use prepared statements
7
+ with the map/to_hash optimizations.
8
+
9
+ * Sequel.empty_array_handle_nulls has been added to change how
10
+ IN/NOT IN operations with an empty array are handled. See
11
+ the Backwards Compatibility section for details.
12
+
13
+ * 5 new association options have been added that allow you to
14
+ define associations where the underlying columns clash with
15
+ standard ruby method names:
16
+
17
+ many_to_one :primary_key_method
18
+ one_to_many :key_method
19
+ one_to_many :primary_key_column
20
+ many_to_many :left_primary_key_column
21
+ many_to_many :right_primary_key_method
22
+
23
+ Using these new options, you can now define associations
24
+ that work correctly when the underlying primary/foreign key
25
+ columns clash with existing ruby method names. See the RDoc
26
+ for details.
27
+
28
+ * A use_after_commit_rollback setting has been added to models.
29
+ This defaults to true, but can be set to false for performance
30
+ or to allow models to be used in prepared transactions
31
+ (which don't support after_commit/after_rollback).
32
+
33
+ * Dataset#update_ignore has been added when connecting to MySQL,
34
+ enabling use of the UPDATE IGNORE syntax to skip updating a row
35
+ if the update would cause a unique constraint to be violated.
36
+
37
+ * Database#indexes is now supported when connecting to Microsoft
38
+ SQL Server.
39
+
40
+ * On Microsoft SQL Server, the :include option is now supported
41
+ when creating indexes, for storing column values in the index,
42
+ which can be used by the query optimizer.
43
+
44
+ = Other Improvements
45
+
46
+ * The filtering/excluding by associations code now uses qualified
47
+ identifiers instead of unqualified identifiers, which allows it
48
+ to avoid ambiguous column names if you are doing your own joins.
49
+
50
+ * Virtual row blocks that return arrays are now handled correctly
51
+ in Dataset#select_map/select_order_map.
52
+
53
+ * Dataset#select_map/select_order_map can now take both a block
54
+ argument as well as a regular argument.
55
+
56
+ * Dataset#select_order_map now handles virtual row blocks that
57
+ return ordered expressions.
58
+
59
+ * Database#table_exists? should no longer generate false negatives
60
+ if you only have permission to retrieve some column values but
61
+ not all. Note that if you lack permission to SELECT from the
62
+ table itself, table_exists? can still generate false negatives.
63
+
64
+ * The active_model plugin now supports ActiveModel 3.2, by adding
65
+ support for to_partial_path.
66
+
67
+ * The serialization_modification_detection plugin now handles
68
+ changed_columns correctly both for new objects and after saving
69
+ objects.
70
+
71
+ * The serialization plugin now clears the deserialized values when
72
+ it does the automatic refresh after saving a new object, mostly for
73
+ consistency. You can use the skip_create_refresh plugin to skip
74
+ refreshing when creating a new model object.
75
+
76
+ * Column default values are now wrapped in parentheses on SQLite,
77
+ which fixes some cases such as when the default is an SQL function
78
+ call.
79
+
80
+ * Alter table emulation now works correctly on SQLite when foreign
81
+ keys reference the table being altered. The emulation requires
82
+ a renaming/deleting the existing table and creating a new table,
83
+ which can break foreign key references. Sequel now disables the
84
+ foreign key PRAGMA when altering tables, so SQLite won't track
85
+ the table renames and break the foreign key relationships.
86
+
87
+ * The set_column_type table alteration method no longer modifies
88
+ default values and NULL/NOT NULL settings on Microsoft SQL
89
+ Server, H2, and SQLite.
90
+
91
+ * On MySQL, Time/DateTime columns now use the timestamp type if the
92
+ default value is Sequel::CURRENT_TIMESTAMP, since it is currently
93
+ impossible for MySQL to have a non-constant default for a
94
+ datetime column (without using a workaround like a trigger).
95
+
96
+ * Metadata methods such as tables, views, and view_exists? are now
97
+ handled correctly on Oracle if custom identifier input methods
98
+ are used.
99
+
100
+ * Sequel now ignores errors that occur when attempting to get
101
+ information on column defaults in Oracle (which can happen if you
102
+ lack permission to the appropriate table). Previously, such errors
103
+ would cause the schema parser to raise an error, now, the schema
104
+ information is just returned without default information.
105
+
106
+ * Database#indexes now skips the primary key index when connecting to
107
+ DB2, Derby, HSQLDB, and Oracle via the jdbc adapter.
108
+
109
+ * Database#indexes now works correctly on DB2.
110
+
111
+ * The progress adapter has been fixed, it had been broken since the
112
+ dataset literalization refactoring.
113
+
114
+ * Dataset#naked! now works correctly. Previously, it just returned
115
+ the receiver unmodified.
116
+
117
+ * Dataset#paginate! has been removed, as it was broken.
118
+
119
+ * The query extension no longer breaks Dataset#clone if an argument
120
+ is not given.
121
+
122
+ * Transaction related queries are no longer logged twice in the mock
123
+ adapter.
124
+
125
+ = Backwards Compatibility
126
+
127
+ * Sequel's default handling of NOT IN operators with an empty array
128
+ of values has changed, which can change which rows are returned for
129
+ such queries.
130
+
131
+ Previously, Sequel was inconsistent in that it tried to handle NULL
132
+ values correctly in the IN case, but not in the NOT IN case. Now,
133
+ it defaults to handling NULL values correctly in both cases:
134
+
135
+ # 3.31.0
136
+ DB[:a].where(:b=>[])
137
+ # SELECT * FROM a WHERE (b != b)
138
+ DB[:a].exclude(:b=>[])
139
+ # SELECT * FROM a WHERE (1 = 1)
140
+
141
+ # 3.32.0
142
+ DB[:a].where(:b=>[])
143
+ # SELECT * FROM a WHERE (b != b)
144
+ DB[:a].exclude(:b=>[])
145
+ # SELECT * FROM a WHERE (b = b)
146
+
147
+ The important change in behavior is that in the NOT IN case, if
148
+ the left hand argument is NULL, the filter returns NULL instead
149
+ of true. This has the potential to change query results.
150
+
151
+ "Correct" here is really an opinion and not a fact, as there are
152
+ valid arguments for the alternative behavior:
153
+
154
+ DB[:a].where(:b=>[])
155
+ # SELECT * FROM a WHERE (1 = 0)
156
+ DB[:a].exclude(:b=>[])
157
+ # SELECT * FROM a WHERE (1 = 1)
158
+
159
+ The difference is that the "correct" NULL behavior is more
160
+ consistent with the non-empty array cases. For example, if b is
161
+ NULL:
162
+
163
+ # "Correct" NULL handling
164
+ # Empty array: where(:b=>[])
165
+ WHERE (b != b) # NULL
166
+ WHERE (b = b) # NULL
167
+ # Non-empty array: where(:b=>[1, 2])
168
+ WHERE (b IN (1, 2)) # NULL
169
+ WHERE (b NOT IN (1, 2)) # NULL
170
+
171
+ # Static boolean handling
172
+ # Empty array: where(:b=>[])
173
+ WHERE (1 = 0) # false
174
+ WHERE (1 = 1) # true
175
+ # Non-empty array: where(:b=>[1, 2])
176
+ WHERE (b IN (1, 2)) # NULL
177
+ WHERE (b NOT IN (1, 2)) # NULL
178
+
179
+ Sequel chooses to default to behavior consistent with the non-empty
180
+ array cases (similar to SQLAlchemy). However, there are two
181
+ downsides to this handling. The first is that some databases with
182
+ poor optimizers (e.g. MySQL) might do a full table scan with the
183
+ default syntax. The second is that the static boolean handling may
184
+ be generally perferable, if you believe that IN/NOT IN with an
185
+ empty array should always be true or false and never NULL even if
186
+ the left hand argument is NULL.
187
+
188
+ As there really isn't a truly correct answer in this case, Sequel
189
+ defaults to the "correct" NULL handling, and allows you to switch
190
+ to the static boolean handling via:
191
+
192
+ Sequel.empty_array_handle_nulls = false
193
+
194
+ This is currently a global setting, it may be made Database or
195
+ Dataset specific later if requested. Also, it is possible the
196
+ default will switch in the future, so if you care about a specific
197
+ handling, you should set your own default.
198
+
199
+ * Database#table_exists? now only rescues Sequel::DatabaseErrors
200
+ instead of StandardErrors, so it's possible it will raise errors
201
+ instead of returning false on custom adapters that don't wrap
202
+ their errors correctly.