viking-sequel 3.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. data/CHANGELOG +3134 -0
  2. data/COPYING +19 -0
  3. data/README.rdoc +723 -0
  4. data/Rakefile +193 -0
  5. data/bin/sequel +196 -0
  6. data/doc/advanced_associations.rdoc +644 -0
  7. data/doc/cheat_sheet.rdoc +218 -0
  8. data/doc/dataset_basics.rdoc +106 -0
  9. data/doc/dataset_filtering.rdoc +158 -0
  10. data/doc/opening_databases.rdoc +296 -0
  11. data/doc/prepared_statements.rdoc +104 -0
  12. data/doc/reflection.rdoc +84 -0
  13. data/doc/release_notes/1.0.txt +38 -0
  14. data/doc/release_notes/1.1.txt +143 -0
  15. data/doc/release_notes/1.3.txt +101 -0
  16. data/doc/release_notes/1.4.0.txt +53 -0
  17. data/doc/release_notes/1.5.0.txt +155 -0
  18. data/doc/release_notes/2.0.0.txt +298 -0
  19. data/doc/release_notes/2.1.0.txt +271 -0
  20. data/doc/release_notes/2.10.0.txt +328 -0
  21. data/doc/release_notes/2.11.0.txt +215 -0
  22. data/doc/release_notes/2.12.0.txt +534 -0
  23. data/doc/release_notes/2.2.0.txt +253 -0
  24. data/doc/release_notes/2.3.0.txt +88 -0
  25. data/doc/release_notes/2.4.0.txt +106 -0
  26. data/doc/release_notes/2.5.0.txt +137 -0
  27. data/doc/release_notes/2.6.0.txt +157 -0
  28. data/doc/release_notes/2.7.0.txt +166 -0
  29. data/doc/release_notes/2.8.0.txt +171 -0
  30. data/doc/release_notes/2.9.0.txt +97 -0
  31. data/doc/release_notes/3.0.0.txt +221 -0
  32. data/doc/release_notes/3.1.0.txt +406 -0
  33. data/doc/release_notes/3.10.0.txt +286 -0
  34. data/doc/release_notes/3.2.0.txt +268 -0
  35. data/doc/release_notes/3.3.0.txt +192 -0
  36. data/doc/release_notes/3.4.0.txt +325 -0
  37. data/doc/release_notes/3.5.0.txt +510 -0
  38. data/doc/release_notes/3.6.0.txt +366 -0
  39. data/doc/release_notes/3.7.0.txt +179 -0
  40. data/doc/release_notes/3.8.0.txt +151 -0
  41. data/doc/release_notes/3.9.0.txt +233 -0
  42. data/doc/schema.rdoc +36 -0
  43. data/doc/sharding.rdoc +113 -0
  44. data/doc/virtual_rows.rdoc +205 -0
  45. data/lib/sequel.rb +1 -0
  46. data/lib/sequel/adapters/ado.rb +90 -0
  47. data/lib/sequel/adapters/ado/mssql.rb +30 -0
  48. data/lib/sequel/adapters/amalgalite.rb +176 -0
  49. data/lib/sequel/adapters/db2.rb +139 -0
  50. data/lib/sequel/adapters/dbi.rb +113 -0
  51. data/lib/sequel/adapters/do.rb +188 -0
  52. data/lib/sequel/adapters/do/mysql.rb +49 -0
  53. data/lib/sequel/adapters/do/postgres.rb +91 -0
  54. data/lib/sequel/adapters/do/sqlite.rb +40 -0
  55. data/lib/sequel/adapters/firebird.rb +283 -0
  56. data/lib/sequel/adapters/informix.rb +77 -0
  57. data/lib/sequel/adapters/jdbc.rb +587 -0
  58. data/lib/sequel/adapters/jdbc/as400.rb +58 -0
  59. data/lib/sequel/adapters/jdbc/h2.rb +133 -0
  60. data/lib/sequel/adapters/jdbc/mssql.rb +57 -0
  61. data/lib/sequel/adapters/jdbc/mysql.rb +78 -0
  62. data/lib/sequel/adapters/jdbc/oracle.rb +50 -0
  63. data/lib/sequel/adapters/jdbc/postgresql.rb +108 -0
  64. data/lib/sequel/adapters/jdbc/sqlite.rb +55 -0
  65. data/lib/sequel/adapters/mysql.rb +421 -0
  66. data/lib/sequel/adapters/odbc.rb +143 -0
  67. data/lib/sequel/adapters/odbc/mssql.rb +42 -0
  68. data/lib/sequel/adapters/openbase.rb +64 -0
  69. data/lib/sequel/adapters/oracle.rb +131 -0
  70. data/lib/sequel/adapters/postgres.rb +504 -0
  71. data/lib/sequel/adapters/shared/mssql.rb +490 -0
  72. data/lib/sequel/adapters/shared/mysql.rb +498 -0
  73. data/lib/sequel/adapters/shared/oracle.rb +195 -0
  74. data/lib/sequel/adapters/shared/postgres.rb +830 -0
  75. data/lib/sequel/adapters/shared/progress.rb +44 -0
  76. data/lib/sequel/adapters/shared/sqlite.rb +389 -0
  77. data/lib/sequel/adapters/sqlite.rb +224 -0
  78. data/lib/sequel/adapters/utils/stored_procedures.rb +84 -0
  79. data/lib/sequel/connection_pool.rb +99 -0
  80. data/lib/sequel/connection_pool/sharded_single.rb +84 -0
  81. data/lib/sequel/connection_pool/sharded_threaded.rb +211 -0
  82. data/lib/sequel/connection_pool/single.rb +29 -0
  83. data/lib/sequel/connection_pool/threaded.rb +150 -0
  84. data/lib/sequel/core.rb +293 -0
  85. data/lib/sequel/core_sql.rb +241 -0
  86. data/lib/sequel/database.rb +1079 -0
  87. data/lib/sequel/database/schema_generator.rb +327 -0
  88. data/lib/sequel/database/schema_methods.rb +203 -0
  89. data/lib/sequel/database/schema_sql.rb +320 -0
  90. data/lib/sequel/dataset.rb +32 -0
  91. data/lib/sequel/dataset/actions.rb +441 -0
  92. data/lib/sequel/dataset/features.rb +86 -0
  93. data/lib/sequel/dataset/graph.rb +254 -0
  94. data/lib/sequel/dataset/misc.rb +119 -0
  95. data/lib/sequel/dataset/mutation.rb +64 -0
  96. data/lib/sequel/dataset/prepared_statements.rb +227 -0
  97. data/lib/sequel/dataset/query.rb +709 -0
  98. data/lib/sequel/dataset/sql.rb +996 -0
  99. data/lib/sequel/exceptions.rb +51 -0
  100. data/lib/sequel/extensions/blank.rb +43 -0
  101. data/lib/sequel/extensions/inflector.rb +242 -0
  102. data/lib/sequel/extensions/looser_typecasting.rb +21 -0
  103. data/lib/sequel/extensions/migration.rb +239 -0
  104. data/lib/sequel/extensions/named_timezones.rb +61 -0
  105. data/lib/sequel/extensions/pagination.rb +100 -0
  106. data/lib/sequel/extensions/pretty_table.rb +82 -0
  107. data/lib/sequel/extensions/query.rb +52 -0
  108. data/lib/sequel/extensions/schema_dumper.rb +271 -0
  109. data/lib/sequel/extensions/sql_expr.rb +122 -0
  110. data/lib/sequel/extensions/string_date_time.rb +46 -0
  111. data/lib/sequel/extensions/thread_local_timezones.rb +48 -0
  112. data/lib/sequel/metaprogramming.rb +9 -0
  113. data/lib/sequel/model.rb +120 -0
  114. data/lib/sequel/model/associations.rb +1514 -0
  115. data/lib/sequel/model/base.rb +1069 -0
  116. data/lib/sequel/model/default_inflections.rb +45 -0
  117. data/lib/sequel/model/errors.rb +39 -0
  118. data/lib/sequel/model/exceptions.rb +21 -0
  119. data/lib/sequel/model/inflections.rb +162 -0
  120. data/lib/sequel/model/plugins.rb +70 -0
  121. data/lib/sequel/plugins/active_model.rb +59 -0
  122. data/lib/sequel/plugins/association_dependencies.rb +103 -0
  123. data/lib/sequel/plugins/association_proxies.rb +41 -0
  124. data/lib/sequel/plugins/boolean_readers.rb +53 -0
  125. data/lib/sequel/plugins/caching.rb +141 -0
  126. data/lib/sequel/plugins/class_table_inheritance.rb +214 -0
  127. data/lib/sequel/plugins/composition.rb +138 -0
  128. data/lib/sequel/plugins/force_encoding.rb +72 -0
  129. data/lib/sequel/plugins/hook_class_methods.rb +126 -0
  130. data/lib/sequel/plugins/identity_map.rb +116 -0
  131. data/lib/sequel/plugins/instance_filters.rb +98 -0
  132. data/lib/sequel/plugins/instance_hooks.rb +57 -0
  133. data/lib/sequel/plugins/lazy_attributes.rb +77 -0
  134. data/lib/sequel/plugins/many_through_many.rb +208 -0
  135. data/lib/sequel/plugins/nested_attributes.rb +206 -0
  136. data/lib/sequel/plugins/optimistic_locking.rb +81 -0
  137. data/lib/sequel/plugins/rcte_tree.rb +281 -0
  138. data/lib/sequel/plugins/schema.rb +66 -0
  139. data/lib/sequel/plugins/serialization.rb +166 -0
  140. data/lib/sequel/plugins/single_table_inheritance.rb +74 -0
  141. data/lib/sequel/plugins/subclasses.rb +45 -0
  142. data/lib/sequel/plugins/tactical_eager_loading.rb +61 -0
  143. data/lib/sequel/plugins/timestamps.rb +87 -0
  144. data/lib/sequel/plugins/touch.rb +118 -0
  145. data/lib/sequel/plugins/typecast_on_load.rb +72 -0
  146. data/lib/sequel/plugins/validation_class_methods.rb +405 -0
  147. data/lib/sequel/plugins/validation_helpers.rb +223 -0
  148. data/lib/sequel/sql.rb +1020 -0
  149. data/lib/sequel/timezones.rb +161 -0
  150. data/lib/sequel/version.rb +12 -0
  151. data/lib/sequel_core.rb +1 -0
  152. data/lib/sequel_model.rb +1 -0
  153. data/spec/adapters/firebird_spec.rb +407 -0
  154. data/spec/adapters/informix_spec.rb +97 -0
  155. data/spec/adapters/mssql_spec.rb +403 -0
  156. data/spec/adapters/mysql_spec.rb +1019 -0
  157. data/spec/adapters/oracle_spec.rb +286 -0
  158. data/spec/adapters/postgres_spec.rb +969 -0
  159. data/spec/adapters/spec_helper.rb +51 -0
  160. data/spec/adapters/sqlite_spec.rb +432 -0
  161. data/spec/core/connection_pool_spec.rb +808 -0
  162. data/spec/core/core_sql_spec.rb +417 -0
  163. data/spec/core/database_spec.rb +1662 -0
  164. data/spec/core/dataset_spec.rb +3827 -0
  165. data/spec/core/expression_filters_spec.rb +595 -0
  166. data/spec/core/object_graph_spec.rb +296 -0
  167. data/spec/core/schema_generator_spec.rb +159 -0
  168. data/spec/core/schema_spec.rb +830 -0
  169. data/spec/core/spec_helper.rb +56 -0
  170. data/spec/core/version_spec.rb +7 -0
  171. data/spec/extensions/active_model_spec.rb +76 -0
  172. data/spec/extensions/association_dependencies_spec.rb +127 -0
  173. data/spec/extensions/association_proxies_spec.rb +50 -0
  174. data/spec/extensions/blank_spec.rb +67 -0
  175. data/spec/extensions/boolean_readers_spec.rb +92 -0
  176. data/spec/extensions/caching_spec.rb +250 -0
  177. data/spec/extensions/class_table_inheritance_spec.rb +252 -0
  178. data/spec/extensions/composition_spec.rb +194 -0
  179. data/spec/extensions/force_encoding_spec.rb +117 -0
  180. data/spec/extensions/hook_class_methods_spec.rb +470 -0
  181. data/spec/extensions/identity_map_spec.rb +202 -0
  182. data/spec/extensions/inflector_spec.rb +181 -0
  183. data/spec/extensions/instance_filters_spec.rb +55 -0
  184. data/spec/extensions/instance_hooks_spec.rb +133 -0
  185. data/spec/extensions/lazy_attributes_spec.rb +153 -0
  186. data/spec/extensions/looser_typecasting_spec.rb +39 -0
  187. data/spec/extensions/many_through_many_spec.rb +884 -0
  188. data/spec/extensions/migration_spec.rb +332 -0
  189. data/spec/extensions/named_timezones_spec.rb +72 -0
  190. data/spec/extensions/nested_attributes_spec.rb +396 -0
  191. data/spec/extensions/optimistic_locking_spec.rb +100 -0
  192. data/spec/extensions/pagination_spec.rb +99 -0
  193. data/spec/extensions/pretty_table_spec.rb +91 -0
  194. data/spec/extensions/query_spec.rb +85 -0
  195. data/spec/extensions/rcte_tree_spec.rb +205 -0
  196. data/spec/extensions/schema_dumper_spec.rb +357 -0
  197. data/spec/extensions/schema_spec.rb +127 -0
  198. data/spec/extensions/serialization_spec.rb +209 -0
  199. data/spec/extensions/single_table_inheritance_spec.rb +96 -0
  200. data/spec/extensions/spec_helper.rb +91 -0
  201. data/spec/extensions/sql_expr_spec.rb +89 -0
  202. data/spec/extensions/string_date_time_spec.rb +93 -0
  203. data/spec/extensions/subclasses_spec.rb +52 -0
  204. data/spec/extensions/tactical_eager_loading_spec.rb +65 -0
  205. data/spec/extensions/thread_local_timezones_spec.rb +45 -0
  206. data/spec/extensions/timestamps_spec.rb +150 -0
  207. data/spec/extensions/touch_spec.rb +155 -0
  208. data/spec/extensions/typecast_on_load_spec.rb +69 -0
  209. data/spec/extensions/validation_class_methods_spec.rb +984 -0
  210. data/spec/extensions/validation_helpers_spec.rb +438 -0
  211. data/spec/integration/associations_test.rb +281 -0
  212. data/spec/integration/database_test.rb +26 -0
  213. data/spec/integration/dataset_test.rb +963 -0
  214. data/spec/integration/eager_loader_test.rb +734 -0
  215. data/spec/integration/model_test.rb +130 -0
  216. data/spec/integration/plugin_test.rb +814 -0
  217. data/spec/integration/prepared_statement_test.rb +213 -0
  218. data/spec/integration/schema_test.rb +361 -0
  219. data/spec/integration/spec_helper.rb +73 -0
  220. data/spec/integration/timezone_test.rb +55 -0
  221. data/spec/integration/transaction_test.rb +122 -0
  222. data/spec/integration/type_test.rb +96 -0
  223. data/spec/model/association_reflection_spec.rb +175 -0
  224. data/spec/model/associations_spec.rb +2633 -0
  225. data/spec/model/base_spec.rb +418 -0
  226. data/spec/model/dataset_methods_spec.rb +78 -0
  227. data/spec/model/eager_loading_spec.rb +1391 -0
  228. data/spec/model/hooks_spec.rb +240 -0
  229. data/spec/model/inflector_spec.rb +26 -0
  230. data/spec/model/model_spec.rb +593 -0
  231. data/spec/model/plugins_spec.rb +236 -0
  232. data/spec/model/record_spec.rb +1500 -0
  233. data/spec/model/spec_helper.rb +97 -0
  234. data/spec/model/validations_spec.rb +153 -0
  235. data/spec/rcov.opts +6 -0
  236. data/spec/spec_config.rb.example +10 -0
  237. metadata +346 -0
@@ -0,0 +1,366 @@
1
+ New Features
2
+ ------------
3
+
4
+ * Dataset#filter and related methods now accept a string with named
5
+ placeholders, and a hash with placeholder values:
6
+
7
+ ds.filter('copies_sold > :sales', :sales=>500000)
8
+
9
+ Sequel's general support for this syntax is nicer:
10
+
11
+ ds.filter{copies_sold > 500000}
12
+
13
+ But named placeholder support can make it easier to port code
14
+ from other database libraries. Also, it works much better than
15
+ the ? placeholder support if you have a long SQL statement:
16
+
17
+ DB['SELECT :n FROM t WHERE p > :q AND p < :r', :n=>1,:q=>2,:r=>3]
18
+
19
+ Sequel doesn't subsitute values that don't appear in the hash:
20
+
21
+ ds.where('price < :p AND id in :ids', :p=>100)
22
+ # WHERE (price < 100 AND id in :ids)
23
+
24
+ This makes it easier to spot missed placeholders, and avoids issues
25
+ with PostgreSQL's :: casting syntax or : inside string literals.
26
+
27
+ * The Model add_ association method now accepts a hash and creates
28
+ a new associated model object associated to the receiver:
29
+
30
+ Artist[:name=>'YJM'].add_album(:name=>'RF')
31
+
32
+ * The Model remove_ association method now accepts a primary key
33
+ and removes the associated model object from the association. For
34
+ models using composite primary keys, an array of primary key values
35
+ can be used. Example:
36
+
37
+ Artist[:name=>'YJM'].remove_album(1) # regular pk
38
+ Artist[:name=>'YJM'].remove_album([2, 3]) # composite pk
39
+
40
+ * Dataset#bind was added, allowing you to bind values before calling
41
+ Dataset#call. This is more consistent with Sequel's general
42
+ approach where queries can be built in any order.
43
+
44
+ * The native postgres adapter now has Dataset#use_cursor, which
45
+ allows you to process huge datasets without keeping all records in
46
+ memory. The default number of rows per cursor fetch is 1000, but
47
+ that can be modified:
48
+
49
+ DB[:huge_table].use_cursor.each{|r| p r}
50
+ DB[:huge_table].use_cursor(:rows_per_fetch=>10000).each{|r| p r}
51
+
52
+ This probably won't work with prepared statements or
53
+ bound variables.
54
+
55
+ * The nested_attributes plugin now adds newly created objects to the
56
+ cached association array immediately, even though the changes
57
+ are not persisted to the database until after the object is saved.
58
+ The reasoning for this is that otherwise there is no way to access
59
+ the newly created associated objects before the save, and no way
60
+ to access them at all if validation fails.
61
+
62
+ This makes the nested_attributes plugin much easier to use, since
63
+ now you can just iterate over the cached association array when
64
+ building the form. If validation fails, it will have the newly
65
+ created failed objects in the array, so you can easily display the
66
+ form as the user entered it for them to make changes.
67
+
68
+ This change doesn't affect many_to_one associations, since those
69
+ don't have a cached association array. This also does not affect
70
+ updating existing records, since those are already in the cached
71
+ array.
72
+
73
+ * You can now easily override the default options used in the
74
+ validation_helpers plugin (the recommended validation plugin).
75
+ Options can be overridden at a global level:
76
+
77
+ Sequel::Plugins::ValidationHelpers::DEFAULT_OPTIONS[:format].
78
+ merge!(:message=>"incorrect format", :allow_missing=>true)
79
+
80
+ Options can also be overridden on a per-class level:
81
+
82
+ class Album < Sequel::Model
83
+ plugin :validation_helpers
84
+ DEFAULT_VALIDATION_OPTIONS = {
85
+ :format=>{:message=>"incorrect format", :allow_missing=>true}}
86
+
87
+ private
88
+
89
+ def default_validation_helpers_options(type)
90
+ super.merge(DEFAULT_VALIDATION_OPTIONS[type] || {})
91
+ end
92
+ end
93
+
94
+ * You can now use a proc instead of a string for the
95
+ validation_helpers :message option. This should allow much
96
+ easier internationalization support. If a proc is given, Sequel
97
+ calls it to get the format string to use. Whether the proc should
98
+ take an argument depends on whether the associated validation
99
+ method takes an argument before the array of columns to validate,
100
+ and the argument provided is what is passed to the proc. The
101
+ exception to this is the validates_not_string method, which doesn't
102
+ take an argument, but does pass one to the proc (a symbol with the
103
+ schema type of the column).
104
+
105
+ Combined with the above default option support, full
106
+ internationalization support for the validation_helpers plugin
107
+ should be fairly easy.
108
+
109
+ * The nested_attributes plugin now accepts a :fields option that
110
+ specifies the fields that are allowed. If specified, the
111
+ plugin will use set_only instead of set when mass assigning
112
+ attributes. Without this, the only way to control which fields
113
+ are allowed is to set allowed/restricted attributes at a class
114
+ level in the associated class.
115
+
116
+ * Associations now accept a :distinct option which uses the SQL
117
+ DISTINCT clause. This can be used instead of :uniq for
118
+ many_to_many and many_through_many associations to handle
119
+ the uniqueness in the database instead of in ruby. It can
120
+ also be useful for one_to_many associations to models that
121
+ don't have primary keys.
122
+
123
+ * The caching plugin now accepts an :ignore_exceptions option that
124
+ allows it to work with memcached (which raises exceptions instead
125
+ of returning nil for missing records).
126
+
127
+ * Sequel now emulates JOIN USING poorly using JOIN ON for databases
128
+ that don't support JOIN USING (MSSQL and H2). This isn't
129
+ guaranteed to work for all queries, since USING and ON have
130
+ different semantics, but should work in most cases.
131
+
132
+ * The MSSQL shared adapter now supports insert_select, for faster
133
+ model object creation. If for some reason you need to disable it,
134
+ you can use disable_insert_output.
135
+
136
+ * Model#modified! has been added which explicitly marks the object
137
+ as modified. So even if no column values have been modified,
138
+ calling save_changes/update will still run through the regular
139
+ save process and call all before and after save/update hooks.
140
+
141
+ * Model#marshallable! has been added which removes unmarshallable
142
+ attributes from the object. Previously, you couldn't marshal
143
+ a saved model object because it contained a dataset with a
144
+ singleton class. Custom _dump and _load methods could be used
145
+ instead, but this approach is easier to implement.
146
+
147
+ * Dataset#literal_other now calls sql_literal on the object with
148
+ the current dataset instance, if the object responds to it.
149
+ This makes it easier to support the literalization of arbitrary
150
+ objects.
151
+
152
+ Note that if the object is a subclass of a class handled by
153
+ an existing dataset literalization method, you cannot use this
154
+ method. You have to override the specific Dataset#literal_* method
155
+ in that case.
156
+
157
+ * Model#save_changes now accepts an option hash that is passed to
158
+ save:
159
+
160
+ album.save_changes(:validate=>false)
161
+
162
+ * A bunch of Dataset#*_join methods have been added, for specific
163
+ join types:
164
+
165
+ * cross_join
166
+ * natural_join
167
+ * full_join
168
+ * left_join
169
+ * right_join
170
+ * natural_full_join
171
+ * natural_left_join
172
+ * natural_right_join
173
+
174
+ Previously, you had to use join_table(:cross, ...) to use a CROSS
175
+ JOIN.
176
+
177
+ * You can now create clustered indexes on Microsoft SQL Server using
178
+ the :clustered option.
179
+
180
+ * AssociationReflection#associated_object_keys has been added,
181
+ specifying the keys in the associated model object that are related
182
+ to this association.
183
+
184
+ * Sequel::SQL::SQLArray#to_a was added.
185
+
186
+ Other Improvements
187
+ ------------------
188
+
189
+ * Constant lookup in virtual row blocks now works correctly in ruby
190
+ 1.9. Virtual row blocks are based on BasicObject on ruby 1.9,
191
+ which doesn't allow referencing objects in the top level scope. So
192
+ the following code would cause an error on 1.9:
193
+
194
+ DB[:bonds].filter{maturity_date > Time.now}
195
+
196
+ Sequel now uses a Sequel::BasicObject class on 1.9 with a
197
+ const_missing that looks up constants in Object, which allows the
198
+ above code to work.
199
+
200
+ * Sequel no longer attempts to load associated objects when
201
+ one of the key fields in the current table is NULL. This fixes
202
+ the behavior when the :primary_key option for the association
203
+ is used to point to a non-primary key.
204
+
205
+ A consequence of this change is that attempting to load a
206
+ *_to_many association for a new model object now returns
207
+ an empty array instead of raising an exception. This has its
208
+ own advantage of allowing the same association viewing code
209
+ to work on both new and existing objects. Previously, you had
210
+ to actively avoid calling the association method on new objects,
211
+ or Sequel would raise an exception.
212
+
213
+ * Dataset aggreate methods (sum/avg/min/max/range/interval) now
214
+ work correctly with limited, grouped, or compound datasets.
215
+ Previously, count worked with them, but other aggregate methods
216
+ did not. These methods now use a subquery if called on a
217
+ limited, grouped or compound dataset.
218
+
219
+ * It is no longer required to have an existing GROUP BY clause
220
+ to use a HAVING clause (except on SQLite, which doesn't permit
221
+ it). Sequel has always had this limitation, but it's not required
222
+ by the SQL standard, and there are valid reasons to use HAVING
223
+ without GROUP BY.
224
+
225
+ * Sequel will now emulate support for databases that don't support
226
+ multiple column IN/NOT IN syntax, such as MSSQL and SQLite:
227
+
228
+ ds.filter([:col1, :col2]=>[[1, 2], [3, 4]].sql_array)
229
+ # default: WHERE (col1, col2) IN ((1, 2), (3, 4))
230
+ # emulated: WHERE (((col1 = 1) AND (col2 = 2)) OR
231
+ # ((col1 = 3) AND (col2 = 4)))
232
+
233
+ This is necessary for eager loading associated objects for models
234
+ with composite primary keys.
235
+
236
+ * Sequel now emulates :column.ilike('blah%') for case insensitive
237
+ searches on MSSQL and H2. MSSQL is case insensitive by default,
238
+ so it is the same as like. H2 is case sensitive, so Sequel
239
+ uses a case insensitive cast there.
240
+
241
+ * The nested_attributes plugin no longer allows modification of
242
+ keys related to the association. This fixes a possible security
243
+ issue with the plugin, where a user could associate the nested
244
+ record to a different record. For example:
245
+
246
+ Artist.one_to_many :albums
247
+ Artist.plugin :nested_attributes
248
+ Artist.nested_attributes :albums
249
+ artist = Artist.create
250
+ artist2 = Artist.create
251
+ album = Album.create
252
+ artist.add_album(album)
253
+ artist.albums_attributes = [{:id=>album.id,
254
+ :artist_id=>artist2.id}]
255
+ artist.save
256
+
257
+ * The one_to_many remove_* association method now makes sure that the
258
+ object to be removed is currently associated to this object.
259
+ Before, the method could be abused to disassociate the object from
260
+ whatever object it was associated to.
261
+
262
+ * Model add_ and remove_ association methods now check that the passed
263
+ object is of the correct class.
264
+
265
+ * Calling the add_* association method no longer adds the record
266
+ to the cached association array if the object is already in the
267
+ array. Previously, Sequel did this for reciprocal associations,
268
+ but not for regular associations.
269
+
270
+ This makes the most sense for one_to_many associations, since
271
+ those can only be associated to the object once. For many_to_many
272
+ associations, if you want an option to disable the behavior, please
273
+ bring it up on the Sequel mailing list.
274
+
275
+ * An array with a string and placeholders that is passed to
276
+ Dataset#filter is no longer modified. Previously:
277
+
278
+ options = ["name like ?", "%dog%"]
279
+ DB[:players].where(options)
280
+ options # => ["%dog%"]
281
+
282
+ * Getting the most recently inserted autoincremented primary key
283
+ is now optimized when connecting to MySQL via JDBC.
284
+
285
+ * Model.inherited now calls Class.inherited.
286
+
287
+ * The MSSQL shared adapter once again works on ruby 1.9. It was
288
+ broken in 3.5.0 due to minor syntax issues.
289
+
290
+ * The force_encoding plugin now handles refreshing an existing
291
+ object, either explicitly or implicitly when new objects are
292
+ created.
293
+
294
+ To use the force_encoding plugin with the identity_map plugin, the
295
+ identity_map plugin should be loaded first.
296
+
297
+ * Using nil as a bound variable now works on PostgreSQL. Before,
298
+ Sequel would incorrectly use "" instead of NULL, since it
299
+ transformed all objects to strings before binding them. Sequel
300
+ now binds the objects directly.
301
+
302
+ * The Amalgalite adapter is now significantly faster, especially for
303
+ code that modifies the schema or submits arbitrary SQL statements
304
+ using Database <<, run, or execute_ddl.
305
+
306
+ * Model#save_changes is now used when updating existing associated
307
+ objects in the nested_attributes plugin. This should be
308
+ significantly faster for the common case of submitting a complex
309
+ form with nested objects without making modifications.
310
+
311
+ * You can now prepare insert statements that take multiple arguments,
312
+ such as insert(1, 2, 3) and insert(columns, values).
313
+
314
+ * Dataset#group_and_count now supports aliased columns.
315
+
316
+ * Adding indexes to tables outside the default schema now works.
317
+
318
+ * Eager graphing now works better with models that use aliased tables.
319
+
320
+ * Sequel now correctly parses the column schema information for tables
321
+ in a non-default schema on Microsoft SQL Server.
322
+
323
+ * changed_columns is now cleared for when saving new model objects
324
+ for adapters that support insert_select, such as PostgreSQL.
325
+
326
+ * Dataset#replace on MySQL now works correctly when default values
327
+ are used.
328
+
329
+ * Dataset#lock on PostgreSQL now works correctly.
330
+
331
+ * Dataset#explain now works correctly on SQLite, and works using
332
+ any adapter. It also works correctly on Amalgalite.
333
+
334
+ * The JDBC adapter now handles binding Time arguments correctly when
335
+ using prepared statements.
336
+
337
+ * Model add_ and remove_ association methods now have more
338
+ descriptive exception messages.
339
+
340
+ * Dataset#simple_select_all? now ignores options that don't affect
341
+ the SQL, such as :server.
342
+
343
+ * Dataset#window in the PostgreSQL adapter now respects existing
344
+ named windows.
345
+
346
+ * Sequel now better handles a failure to begin a new transaction.
347
+
348
+ * The dataset code was split into some additional files for improved
349
+ readability.
350
+
351
+ * Many documentation improvements were made.
352
+
353
+ Backwards Compatibility
354
+ -----------------------
355
+
356
+ * Model::Errors no longer uses a default proc, but emulates one in the
357
+ [] method. This is unlikely to have a negative affect unless you
358
+ are calling a method on it that doesn't call [] (maybe using it in
359
+ a C extension?).
360
+
361
+ * Model#table_name now only provides the alias if an aliased table is
362
+ used.
363
+
364
+ * The Sequel::Dataset::STOCK_COUNT_OPTS constant has been removed.
365
+
366
+ * Dataset#lock on PostgreSQL now returns nil instead of a dataset.
@@ -0,0 +1,179 @@
1
+ New Features
2
+ ------------
3
+
4
+ * Sequel now has support for deleting and updating joined datasets
5
+ on MySQL and PostgreSQL. Previously, Sequel only supported this to
6
+ a limited extent on Microsoft SQL Server, and support there has been
7
+ improved as well.
8
+
9
+ This allows you to do:
10
+
11
+ DB.create_table!(:a){Integer :a; Integer :d}
12
+ DB.create_table!(:b){Integer :b; Integer :e}
13
+ DB.create_table!(:c){Integer :c; Integer :f}
14
+
15
+ # Insert some rows
16
+
17
+ ds = DB.from(:a, :b).
18
+ join(:c, :c=>:e.identifier).
19
+ where(:d=>:b)
20
+ ds.where(:f=>6).update(:a => 10)
21
+ ds.where(:f=>5).delete
22
+
23
+ Which will set the a column to 10 for all rows in table a, where
24
+ an associated row in table c (through table b) has a value of 6 for
25
+ column f. It will delete rows from table a where an associated row
26
+ in table c (through table b) has a value of 5 for column f.
27
+
28
+ Sequel assumes the that first FROM table is the table being
29
+ updated/deleted. MySQL and Microsoft SQL Server do not require
30
+ multiple FROM tables, but PostgreSQL does.
31
+
32
+ * Dataset #select_map, #select_order_map, and #select_hash
33
+ convenience methods were added for quickly creating arrays and
34
+ hashes from a dataset.
35
+
36
+ select_map and select_order_map both return arrays of values for the
37
+ column specified. The column can be specified either via an argument
38
+ or a block, similar to Dataset#get. Both accept any valid objects as
39
+ arguments.
40
+
41
+ select_hash returns a hash. It requires two symbol arguments, but
42
+ can handle implicit qualifiers or aliases in the symbols.
43
+
44
+ Neither of these methods offer any new functionality, they just cut
45
+ down on the number of required key strokes:
46
+
47
+ select_map(:column) # select(:column).map(:column)
48
+ select_order_map(:column) # select(:column).order(:column).
49
+ # map(:column)
50
+ select_hash(:key_column, :value_column)
51
+ # select(:key_column, :value_column).
52
+ # to_hash(:key_column, :value_column)
53
+
54
+ * The NULL, NOTNULL, TRUE, SQLTRUE, FALSE, and SQLFALSE constants
55
+ were added to Sequel::SQL::Constants. This allows you to do:
56
+
57
+ include Sequel::SQL::Constants
58
+ DB[:table].where(:a=>'1', :b=>NOTNULL)
59
+
60
+ Previously, the shortest way to do this was:
61
+
62
+ DB[:table].where(:a=>'1').exclude(:b=>nil)
63
+
64
+ It may make the code more descriptive:
65
+
66
+ DB[:table].where(:b=>NULL)
67
+ # compared to
68
+ DB[:table].where(:b=>nil)
69
+
70
+ This gives the option to use SQL terminology instead of ruby
71
+ terminology.
72
+
73
+ The other advantage of using the constants it that they handle
74
+ operators and methods like other Sequel::SQL objects:
75
+
76
+ NULL & SQLFALSE # BooleanExpression => "(NULL AND FALSE)"
77
+ nil & false # false
78
+
79
+ NULL + :a # NumericExpression => "(NULL + a)"
80
+ nil + :a # raises NoMethodError
81
+ NULL.sql_string + :a # StringExpression => "(NULL || a)"
82
+ NULL.as(:b) # AliasedExpression => "NULL AS b"
83
+
84
+ For complex systems that want to represent SQL boolean objects
85
+ in ruby (where you don't know exactly how they'll be used), using
86
+ the constants is recommended.
87
+
88
+ In order not to be too verbose, including Sequel::SQL::Constants
89
+ is recommended. It's not done by default, but you can still
90
+ reference the constants under the main Sequel module by default
91
+ (e.g. Sequel::NULL).
92
+
93
+ * The validates_unique method in the validation_helpers plugin now
94
+ supports an :only_if_modified option, which should speed up the
95
+ common case where the unique attribute is not modified for an
96
+ existing record. It's not on by default, since it's possible the
97
+ database could be changed between retrieving the model object and
98
+ updating it.
99
+
100
+ * The Dataset #union, #intersect, and #except methods now accept an
101
+ :alias option which is used as the alias for the returned dataset.
102
+
103
+ DB[:table].union(DB[:old_table], :alias=>:table)
104
+
105
+ * Model#destroy now supports a :transaction option, similar to
106
+ Model#save.
107
+
108
+ * The shared Oracle adapter now supports Dataset#sequence for
109
+ returning autogenerated primary key values on insert from a
110
+ related sequence.
111
+
112
+ This makes Oracle work correctly when using models, with
113
+ something like the following:
114
+
115
+ class Album < Sequel::Model
116
+ set_dataset dataset.sequence(:seq_albums_id)
117
+ end
118
+
119
+ You currently need to call Dataset#sequence in every model
120
+ class where the underlying table uses a sequence to generate
121
+ primary key values.
122
+
123
+ Other Improvements
124
+ ------------------
125
+
126
+ * In Model #save and #destroy when using transactions and when
127
+ raise_on_save_failure is false, ensure that transactions are rolled
128
+ back if a before hook returns false.
129
+
130
+ * Dataset#group_and_count now handles arguments other than Symbols.
131
+ A previous change to the method raised an exception if a Symbol was
132
+ not provided. It also handles AliasedExpressions natively, so the
133
+ following works correctly:
134
+
135
+ DB[:table].group_and_count(:column.as(:alias))
136
+
137
+ * Sequel no longer uses native autoreconnection in the mysql adapter.
138
+ Native autoreconnection has problems with prepared statements,
139
+ where a new native connection is used behind Sequel's back, so
140
+ Sequel thinks the prepared statement has already been defined on
141
+ the connection, when it fact it hasn't. Any other changes that
142
+ affect the state of the connection will be lost when native
143
+ autoreconnection is used as well.
144
+
145
+ Sequel's connection pool already handles reconnection if it detects
146
+ a disconnection. This commit also adds an additional exception
147
+ message to recognize as a disconnect. If there other exception
148
+ messages related to disconnects, please post them on the Sequel
149
+ mailing list.
150
+
151
+ * The schema_dumper plugin now specifies the :type option for primary
152
+ key if it isn't Integer.
153
+
154
+ * On PostgreSQL, the bigserial type is used if :type=>Bignum is
155
+ given as an option to primary key. This makes it operate more
156
+ similarly to other adapters that support autoincrementing 64-bit
157
+ integer primary keys.
158
+
159
+ * The native mysql adapter will now attempt to load options in the
160
+ [client] section of the my.cnf file.
161
+
162
+ * The rake spec tasks for the project now work correctly with RSpec
163
+ 1.2.9.
164
+
165
+ Backwards Compatibility
166
+ -----------------------
167
+
168
+ * Dataset::GET_ERROR_MSG and Dataset::MAP_ERROR_MSG constants were
169
+ removed. Both were replaced with Dataset::ARG_BLOCK_ERROR_MSG.
170
+
171
+ * The behavior of the Model#save_failure private instance method was
172
+ modified. It now always raises an exception, and validation
173
+ failures no longer call it.
174
+
175
+ * The internals of how autogenerated primary key metadata is stored
176
+ when creating tables on PostgreSQL has been modified.
177
+
178
+ * The native MySQL adapter no longer sets the OPT_LOCAL_INFILE option
179
+ to "client" on the native connection.