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,286 @@
1
+ New Features
2
+ ------------
3
+
4
+ * A real one_to_one association was added to Sequel, replacing the
5
+ previous :one_to_one option of the one_to_many association.
6
+
7
+ This is a fully backwards incompatible change, any code that uses
8
+ the :one_to_one option of one_to_many will be broken in Sequel
9
+ 3.10.0, as that option now raises an exception. Keeping backwards
10
+ compatibility was not possible, as even the name of the association
11
+ needs to be changed. Here are the code changes you need to make:
12
+
13
+ * The association definition needs to change from one_to_many to
14
+ one_to_one, with no :one_to_one option, and with the association
15
+ name changed from the plural form to the singular form:
16
+
17
+ # Before
18
+ Lyric.one_to_many :songs, :one_to_one=>true
19
+ # After
20
+ Lyric.one_to_one :song
21
+
22
+ * All usage of the association when eager loading or when getting
23
+ reflections need to use the new singular association name:
24
+
25
+ # Before
26
+ Lyric.eager(:songs).all
27
+ Lyric.eager_graph(:songs).all
28
+ Lyric.association_reflection(:songs)
29
+ # After
30
+ Lyric.eager(:song).all
31
+ Lyric.eager_graph(:song).all
32
+ Lyric.association_reflection(:song)
33
+
34
+ Any Sequel plugins or extensions that deal with the internals of
35
+ associations need to be made aware of the one_to_one association,
36
+ and how it is different than one_to_many's previous :one_to_one
37
+ option. Here are some internal changes that may affect you:
38
+
39
+ * one_to_one associations are now cached like many_to_one
40
+ associations instead of like one_to_many associations. So the
41
+ cache includes the associated object or nil, instead of an array.
42
+ Note that this change means that all custom :eager_loader options
43
+ for one_to_one associations need to change to use this new
44
+ caching scheme.
45
+
46
+ * The one_to_one association setter method is now handled similarly
47
+ to the many_to_one setter method, instead of using the internal
48
+ one_to_many association add method.
49
+
50
+ * Instead of raising an error when multiple rows are returned,
51
+ one_to_one associations now use limit(1) to only return a single
52
+ row.
53
+
54
+ There were some other fixes made during these changes:
55
+
56
+ * The one_to_one setter now accepts nil to disassociate the record.
57
+ Previously, this raised an error.
58
+
59
+ * If the one_to_one association already had a separate object
60
+ associated, and you assigned a different object in the setter
61
+ method, Sequel now disassociates the old object before
62
+ associating the new object, fixing some potential issues if there
63
+ is a UNIQUE constraint on the foreign key column.
64
+
65
+ * Using the many_to_one association setter where the reciprocal
66
+ association is a one_to_one association with a currently
67
+ different cached associated object no longer raises an exception.
68
+
69
+ * The nested_attributes and association_dependencies plugins
70
+ both now correctly handle one_to_one associations.
71
+
72
+ If you need any help migrating, please post on the Sequel Google
73
+ Group or ask in the #sequel IRC channel.
74
+
75
+ * Both many_to_one and one_to_one associations now use before_set
76
+ and after_set callbacks instead of trying to make the one_to_many
77
+ and many_to_many associations' (before|after)_(add|remove)
78
+ callbacks work.
79
+
80
+ This change makes the code simpler, makes writing callbacks easier,
81
+ and no longer requires Sequel to send a query to the database to
82
+ get the currently associated object in the many_to_one association
83
+ setter method (you can still do so manually in a before_set
84
+ callback if you want to).
85
+
86
+ * Dataset#for_update was added as a default dataset method.
87
+ Previously, it was only supported on PostgreSQL. It has been
88
+ tested to work on PostgreSQL, MySQL, SQLite (where it is ignored),
89
+ H2, and MSSQL.
90
+
91
+ * Dataset#lock_style was added as a backbone for Dataset#for_update,
92
+ but allowing you to specify custom lock styles. These can either
93
+ be symbols recognized by the adapters, or strings which are treated
94
+ as literal SQL.
95
+
96
+ * Model#lock! was added, which uses Dataset#for_update to lock model
97
+ rows for specific instances. Combined with the Dataset#for_update,
98
+ Sequel now has an equivalent to ActiveRecord's pessimistic locking
99
+ support.
100
+
101
+ * A composition plugin was added, given similar functionality as
102
+ ActiveRecord's composed_of.
103
+
104
+ The composition plugin allows you to easily define getter and
105
+ setter instance methods for a class where the backing data is
106
+ composed of other getters and decomposed to other setters.
107
+
108
+ A simple example of this is when you have a database table with
109
+ separate columns for year, month, and day, but where you want to
110
+ deal with Date objects in your ruby code. This can be handled
111
+ with:
112
+
113
+ Model.composition :date, :mapping=>[:year, :month, :day]
114
+
115
+ The :mapping option is optional, but if not used, you need define
116
+ custom composition and decomposition procs via the :composer and
117
+ :decomposer options.
118
+
119
+ Note that when using the composition object, you should not modify
120
+ the underlying columns if you are also instantiating the
121
+ composition, as otherwise the composition object values will
122
+ override any underlying columns when the object is saved.
123
+
124
+ * An rcte_tree plugin was added, which uses recursive common table
125
+ expressions to load all ancestors and descendants in a single
126
+ query. If your database supports recursive common table
127
+ expressions (PostgreSQL 8.4+, MSSQL 2005+, newer versions of
128
+ Firebird), using recursive common table expressions to load
129
+ all ancestors and descendants is significantly faster than storing
130
+ trees as nested sets and using nested set queries. Usage:
131
+
132
+ Model.plugin :rcte_tree
133
+
134
+ # Lazy loading
135
+ model = Model.first
136
+ model.parent
137
+ model.children
138
+ model.ancestors # Populates :parent association as well
139
+ model.descendants # Populates :children association as well
140
+
141
+ # Eager loading - also populates the :parent and children
142
+ # associations for all ancestors and descendants
143
+ Model.filter(:id=>[1, 2]).eager(:ancestors, :descendants).all
144
+
145
+ # Eager loading children and grandchildren
146
+ Model.filter(:id=>[1, 2]).eager(:descendants=>2).all
147
+ # Eager loading children, grandchildren, and great grandchildren
148
+ Model.filter(:id=>[1, 2]).eager(:descendants=>3).all
149
+
150
+ * Dataset#first_source_table was added, giving you the unaliased
151
+ version of the table for the first source.
152
+
153
+ * Add Sequel::BasicObject.remove_methods!, useful on ruby 1.8 if you
154
+ require other libraries after Sequel that add methods to Object.
155
+ For example, if YAML is required after sequel, then the following
156
+ will raise an error:
157
+
158
+ DB[:a].filter{x > y}
159
+
160
+ because YAML adds the y method to all objects. Now, you can call
161
+ Sequel::BasicObject.remove_methods!, which will remove those
162
+ methods from Sequel::BasicObject, allowing them to be used as
163
+ intended in the above DSL.
164
+
165
+ * Sequel associations now accept an :eager_loader_key option, which
166
+ can be useful for associations to specify the column to use for the
167
+ key_hash for custom :eager_loaders.
168
+
169
+ * A JDBC subadapter for the AS400 database was added.
170
+
171
+ Other Improvements
172
+ ------------------
173
+
174
+ * The one_to_one setter method and the one_to_many and many_to_many
175
+ remove_all methods now apply the association options (such as
176
+ filters) on the appropriate dataset:
177
+
178
+ Artist.one_to_many :good_albums, :class=>:Album,
179
+ :conditions=>{:good=>true}
180
+ a = Artist[10]
181
+ a.remove_all_good_albums
182
+ # Before: WHERE artist_id = 10
183
+ # After: WHERE artist_id = 10 AND good IS TRUE
184
+
185
+ * Plugin loading now works correctly when the plugin module name
186
+ is the same name as an already defined top level constant. This
187
+ means that the active_model plugin should now work correctly if
188
+ you require active_model before loading the Sequel plugin.
189
+
190
+ * The nested_attributes plugin now preserves nested attributes for
191
+ *_to_one associations on validation failures.
192
+
193
+ * Transactions now work correctly on Oracle when using the JDBC
194
+ adapter.
195
+
196
+ * Dataset#limit once again works correctly on MSSQL 2000. It was
197
+ broken in Sequel 3.9.0.
198
+
199
+ * many_to_one associations now use limit(1) to ensure only one
200
+ record is returned. If you don't want this (because maybe you
201
+ are using the :eager_graph association option), you need to
202
+ set the :key option to nil and use a custom :dataset option.
203
+
204
+ * many_to_one and one_to_many associations now work correctly
205
+ with the association :eager option to eagerly load associations
206
+ specified by :eager when lazy loading the association.
207
+
208
+ * The typecast_on_load plugin now correctly handles
209
+ reloading/refreshing the object, both explicitly and implicitly
210
+ on object creation.
211
+
212
+ * The schema parser and dumper now return tinyint columns as
213
+ booleans when connecting to mysql using the do adapter, since
214
+ DataObjects now returns the columns as booleans.
215
+
216
+ * The schema dumper now deals better with unusual or database
217
+ specific primary key types when using the :same_db option.
218
+
219
+ * On ruby 1.8, Sequel::BasicObject now undefs private methods in
220
+ addition to public and protected methods. So the following
221
+ code now works as expected:
222
+
223
+ DB[:a].filter{x > p} # WHERE x > p
224
+
225
+ * Sequel.connect with a block now returns the value of the block:
226
+
227
+ max_price = Sequel.connect('sqlite://items.db') do |db|
228
+ db[:items].max(:price)
229
+ end
230
+
231
+ * MSSQL emulated offset support now works correctly when Sequel's
232
+ core extensions are not loaded.
233
+
234
+ * Sequel::BasicObject now works correctly on rubinius, and almost
235
+ all Sequel specs now pass on rubinius.
236
+
237
+ * The nested_attributes plugin now uses a better exception message
238
+ no matching associated object is found.
239
+
240
+ * Sequel now raises a more informative error if you attempt to use
241
+ the native sqlite adapter with the sqlite3 gem instead of the
242
+ sqlite3-ruby gem.
243
+
244
+ * Multiple complex expressions with the same operator are now
245
+ combined for simpler SQL:
246
+
247
+ DB[:a].filter(:a=>1, :b=>2).filter(:c=>3)
248
+ # Before: (((a = 1) AND (b = 2)) AND (c = 3))
249
+ # After: ((a = 1) AND (b = 2) AND (c = 3))
250
+
251
+ * The Sequel::Model dataset methods (class methods proxied to the
252
+ model's dataset) and the Sequel::Dataset mutation methods
253
+ (methods that have a ! counterpart to modify the object in place)
254
+ have both been updated to use new dataset methods added in recent
255
+ versions.
256
+
257
+ Backwards Compatibility
258
+ -----------------------
259
+
260
+ * The :one_to_one option of the one_to_many associations now raises
261
+ an exception. Please see the section above about the new real
262
+ one_to_one association.
263
+
264
+ * The change to apply the association options to the one_to_many and
265
+ many_to_many remove_all methods has the potential to break some
266
+ code that uses the remove_all method on associations that use
267
+ association options. This is especially true for many_to_many
268
+ associations, as filters in many_to_many associations will often
269
+ reference columns in the associated table, while the dataset
270
+ used in the remove_all method only contains the join table. Such
271
+ cases should be handled by manually overriding the _remove_all
272
+ association instance method in the class. It was determined that
273
+ it was better to issue possibly invalid queries than to issue
274
+ queries that make unexpected modifications.
275
+
276
+ * Dataset#group_and_count now longer orders the dataset by the count.
277
+ Since it returns a modified dataset, if you want to order the
278
+ dataset, just call order on the returned dataset.
279
+
280
+ * many_to_one associations now require a working :class option.
281
+ Previously, if you provided a custom :dataset option, a working
282
+ :class option was not required in some cases.
283
+
284
+ * The MSSQL shared adapter dataset methods switched from using
285
+ the :table_options internal option key to using the :lock internal
286
+ option key.
@@ -0,0 +1,268 @@
1
+ New Features
2
+ ------------
3
+
4
+ * Common table expressions (CTEs) are now supported. CTEs use the
5
+ SQL WITH clause, and specify inline views that queries can use.
6
+ They also support a recursive mode, where the CTE can recursively
7
+ query its own output, allowing you do do things like load all
8
+ branches for a given node in a plain tree structure.
9
+
10
+ The standard with takes an alias and a dataset:
11
+
12
+ DB[:vw].with(:vw, DB[:table].filter{col < 1})
13
+ # WITH vw AS (SELECT * FROM table WHERE col < 1)
14
+ # SELECT * FROM vw
15
+
16
+ The recursive with takes an alias, a nonrecursive dataset, and a
17
+ recursive dataset:
18
+
19
+ DB[:vw].with_recursive(:vw,
20
+ DB[:tree].filter(:id=>1),
21
+ DB[:tree].join(:vw, :id=>:parent_id).
22
+ select(:vw__id, :vw__parent_id))
23
+ # WITH RECURSIVE vw AS (SELECT * FROM tree
24
+ # WHERE (id = 1)
25
+ # UNION ALL
26
+ # SELECT vw.id, vw.parent_id
27
+ # FROM tree
28
+ # INNER JOIN vw ON (vw.id = tree.parent_id))
29
+ # SELECT * FROM vw
30
+
31
+ CTEs are supported by Microsoft SQL Server 2005+, DB2 7+,
32
+ Firebird 2.1+, Oracle 9+, and PostgreSQL 8.4+.
33
+
34
+ * SQL window functions are now supported, and a DSL has been added to
35
+ ease their creation. Window functions act similarly to aggregate
36
+ functions but operate on sliding ranges of rows.
37
+
38
+ In virtual row blocks (blocks passed to filter, select, order, etc.)
39
+ you can now provide a block to method calls to change the default
40
+ behavior to create functions that weren't possible previously. The
41
+ blocks aren't called, but their presence serves as a flag.
42
+
43
+ What function is created depends on the arguments to the method:
44
+
45
+ * If there are no arguments, an SQL::Function is created with the
46
+ name of method used, and no arguments. Previously, it was not
47
+ possible to create functions without arguments using the virtual
48
+ row block DSL. Example:
49
+
50
+ DB.dataset.select{version{}} # SELECT version()
51
+
52
+ * If the first argument is :*, an SQL::Function is created with a
53
+ single wildcard argument (*). This is mostly useful for count:
54
+
55
+ DB[:t].select{count(:*){}} # SELECT count(*) FROM t
56
+
57
+ * If the first argument is :distinct, an SQL::Function is created
58
+ with the keyword DISTINCT prefacing all remaining arguments. This
59
+ is useful for aggregate functions such as count:
60
+
61
+ DB[:t].select{count(:distinct, col1){}}
62
+ # SELECT count(DISTINCT col1) FROM t
63
+
64
+ * If the first argument is :over, the second argument, if provided,
65
+ should be a hash of options to pass to SQL::Window. The options
66
+ hash can also contain :*=>true to use a wildcard argument as the
67
+ function argument, or :args=>... to specify an array of arguments
68
+ to use as the function arguments.
69
+
70
+ DB[:t].select{rank(:over){}} # SELECT rank() OVER ()
71
+ DB[:t].select{count(:over, :*=>true){}} # SELECT count(*) OVER ()
72
+ DB[:t].select{sum(:over, :args=>col1,
73
+ :partition=>col2, :order=>col3){}}
74
+ # SELECT sum(col1) OVER (PARTITION BY col2 ORDER BY col3)
75
+
76
+ PostgreSQL also supports named windows. Named windows can be
77
+ specified by Dataset#window, and window functions can reference
78
+ them using the :window option.
79
+
80
+ * Schema information for columns now includes a :ruby_default entry
81
+ which contains a ruby object that represents the default given by
82
+ the database (which is stored in :default). Not all :default
83
+ entries can be parsed into a :ruby_default, but if the
84
+ schema_dumper extension previously supported it, it should work.
85
+
86
+ * Methods to create compound datasets (union, intersect, except), now
87
+ take an options hash instead of a true/false flag. The previous
88
+ API is still supported, but switching to specifying the ALL setting
89
+ using :all=>true is recommended.
90
+
91
+ Additionally, you can now set :from_self=>false to not wrap the
92
+ returned dataset in a "SELECT * FROM (...)".
93
+
94
+ * Dataset#ungraphed was added that removes the graphing information
95
+ from the dataset. This allows you to use Dataset#graph for the
96
+ automatic aliasing, or #eager_graph for the automatic aliasing and
97
+ joining, and then remove the graphing information so that the
98
+ resulting objects will not be split into subhashes or associations.
99
+
100
+ * There were some introspection methods added to Dataset to describe
101
+ which capabilities that dataset does or does not support:
102
+
103
+ supports_cte?
104
+ supports_distinct_on?
105
+ supports_intersect_except?
106
+ supports_intersect_except_all?
107
+ supports_window_functions?
108
+
109
+ In addition to being available for the user to use, these are also
110
+ used internally, so attempting to use a CTE on a dataset that
111
+ doesn't support it will raise an Error.
112
+
113
+ * Dataset#qualify was added, which is like qualify_to with a default
114
+ of first_source.
115
+
116
+ Additionally, qualify now affects PlaceholderLiteralStrings. It
117
+ doesn't scan the string (as Sequel never attempts to parse SQL),
118
+ but if you provide the column as a symbol placeholder argument, it
119
+ will qualify it.
120
+
121
+ * You can now specify the table and column Sequel::Migrator will use
122
+ to record the current schema version. The new Migrator.run method
123
+ must be used to use these new options.
124
+
125
+ * The JDBC adapter now accepts :user and :password options, instead
126
+ of requiring them to be specified in the connection string and
127
+ handled by the JDBC driver. This should allow connections to
128
+ Oracle using the Thin JDBC driver.
129
+
130
+ * You can now specify the max_connections, pool_timeout, and
131
+ single_threaded settings directly in the connection string:
132
+
133
+ postgres:///database?single_threaded=t
134
+ postgres:///database?max_connections=10&pool_timeout=20
135
+
136
+ * Dataset#on_duplicate_key_update now affects Dataset#insert when
137
+ using MySQL.
138
+
139
+ * You can now specify the :opclass option when creating PostgreSQL
140
+ indexes. Currently, this only supports a single operator class
141
+ for all columns. If you need different operator classes per
142
+ column, please post on sequel-talk.
143
+
144
+ * Model#autoincrementing_primary_key was added and can be used if
145
+ the autoincrementing key isn't the same as the primary key. The
146
+ only likely use for this is on MySQL MyISAM tables with composite
147
+ primary keys where only one of the composite parts is
148
+ autoincrementing.
149
+
150
+ * You can now use database column values as search patterns and
151
+ specify the text to search as a String or Regexp:
152
+
153
+ String.send(:include, Sequel::SQL::StringMethods)
154
+ Regexp.send(:include, Sequel::SQL::StringMethods)
155
+
156
+ 'a'.like(:x) # ('a' LIKE x)
157
+ /a/.like(:x) # ('a' ~ x)
158
+ /a/i.like(:x) # ('a' ~* x)
159
+ /a/.like(:x, 'b') # (('a' ~ x) OR ('a' ~ 'b'))
160
+
161
+ * The Dataset#dataset_alias private method was added. It can be
162
+ overridden if you have tables named t0, t1, etc and want to make
163
+ sure the default dataset aliases that Sequel uses do not clash
164
+ with existing table names.
165
+
166
+ * Sequel now raises an Error if you call Sequel.connect with
167
+ something that is not a Hash or String.
168
+
169
+ * bin/sequel now accepts a -N option to not test the database
170
+ connection.
171
+
172
+ * An opening_databases.rdoc file was added to the documentation
173
+ directory, which should be a good introduction for new users about
174
+ how to set up your Database connection.
175
+
176
+ Other Improvements
177
+ ------------------
178
+
179
+ * MySQL native adapter SELECT is much faster than before, up to 75%
180
+ faster.
181
+
182
+ * JDBC SELECT is about 10% faster than before. It's still much
183
+ slower than the native adapters, due to conversion issues.
184
+
185
+ * bin/sequel now works with a YAML file on ruby 1.9.
186
+
187
+ * MySQL foreign key table constraints have been fixed.
188
+
189
+ * Database#indexes now works on PostgreSQL if the schema used is a
190
+ Symbol. It also works on PostgreSQL versions all the way back to
191
+ 7.4.
192
+
193
+ * Graphing of datasets with dataset sources has been fixed.
194
+
195
+ * Changing a columns name, type, or NULL status on MySQL now
196
+ supports a much wider selection of column defaults.
197
+
198
+ * The stored procedure code is now thread-safe. Sequel is
199
+ thread-safe in general, but due to a bug the previous stored
200
+ procedure code was not thread-safe.
201
+
202
+ * The ODBC adapter now drops statements automatically instead of
203
+ requiring the user to do so manually, making it more similar
204
+ to other adapters.
205
+
206
+ * The single_table_inheritance plugin no longer overwrites the STI
207
+ field if the field already has a value. This allows you to use
208
+ create in the generic class to insert a value that will be
209
+ returned as a subclass:
210
+
211
+ Person.create(:kind => "Manager")
212
+
213
+ * When altering colums on MySQL, :unsigned, :elements, :size and other
214
+ options given are no longer ignored.
215
+
216
+ * The PostgreSQL shared adapter's explain and analyze methods have
217
+ been fixed, they had been broken in 3.0.
218
+
219
+ * Parsing of the server's version is more robust on PostgreSQL.
220
+ It should now work correctly for 8.4 and 8.4rc1 type versions.
221
+
222
+ Backwards Compatibility
223
+ -----------------------
224
+
225
+ * Dataset#table_exists? has been removed, since it never worked
226
+ perfectly. Use Database#table_exists? instead.
227
+
228
+ * Model.grep now calls Dataset#grep instead of Enumerable#grep.
229
+ If you are using Model.grep, you need to modify your application.
230
+
231
+ * The MSSQL shared adapter previously used the :with option for
232
+ storing the NOLOCK setting of the query. That option has been
233
+ renamed to :table_options, since :with is now used for CTEs.
234
+ This should not have an effect unless you where using the option
235
+ manually.
236
+
237
+ * Previously, providing a block to a method calls in virtual row
238
+ blocks did not change behavior, where now it causes a different
239
+ code path to be used. In both cases, the block is not evaluated,
240
+ but that may change in a future version.
241
+
242
+ * Dataset#to_table_reference protected method was removed, as it was
243
+ no longer used.
244
+
245
+ * The pool_timeout setting is now converted to an Integer, so if you
246
+ used to pass in a Float, it no longer works the same way.
247
+
248
+ * Most files in adapters/utils have been removed, in favor of
249
+ integrating the code directly into Database and Dataset. If you
250
+ were previously checking for the UnsupportedIntersectExcept or
251
+ related modules, use the Dataset introspection methods instead
252
+ (e.g. supports_intersect_except?).
253
+
254
+ * If you were using the ODBC adapter and manually dropping returned
255
+ statements, you should note that now statements are dropped
256
+ automatically, and the execute method doesn't return a statement
257
+ object.
258
+
259
+ * The MySQL adapter on_duplicate_key_update_sql is now a private
260
+ method.
261
+
262
+ * If you were modifying the :from dataset option directly, note that
263
+ Sequel now expects this option to be preprocessed. See the new
264
+ implementation of Dataset#from for an idea of the changes
265
+ required.
266
+
267
+ * Dataset#simple_select_all? now returns false instead of true for a
268
+ dataset that selects from another dataset.