sequel 5.6.0 → 5.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +30 -5099
- data/Rakefile +1 -1
- data/doc/opening_databases.rdoc +0 -2
- data/doc/postgresql.rdoc +31 -0
- data/doc/querying.rdoc +2 -2
- data/doc/release_notes/5.7.0.txt +108 -0
- data/doc/testing.rdoc +1 -0
- data/lib/sequel/adapters/jdbc/derby.rb +1 -1
- data/lib/sequel/adapters/jdbc/oracle.rb +11 -0
- data/lib/sequel/adapters/postgres.rb +1 -0
- data/lib/sequel/adapters/shared/postgres.rb +117 -13
- data/lib/sequel/connection_pool/sharded_threaded.rb +7 -6
- data/lib/sequel/connection_pool/threaded.rb +6 -6
- data/lib/sequel/core.rb +20 -0
- data/lib/sequel/database/logging.rb +3 -2
- data/lib/sequel/database/schema_generator.rb +1 -2
- data/lib/sequel/dataset/actions.rb +15 -5
- data/lib/sequel/extensions/connection_expiration.rb +3 -3
- data/lib/sequel/extensions/connection_validator.rb +3 -3
- data/lib/sequel/extensions/integer64.rb +30 -0
- data/lib/sequel/extensions/migration.rb +2 -3
- data/lib/sequel/plugins/pg_array_associations.rb +5 -3
- data/lib/sequel/plugins/validate_associated.rb +18 -0
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/mssql_spec.rb +6 -6
- data/spec/adapters/mysql_spec.rb +1 -1
- data/spec/adapters/oracle_spec.rb +15 -1
- data/spec/adapters/postgres_spec.rb +78 -1
- data/spec/adapters/spec_helper.rb +3 -1
- data/spec/bin_spec.rb +1 -0
- data/spec/core/dataset_spec.rb +10 -0
- data/spec/extensions/integer64_spec.rb +22 -0
- data/spec/extensions/pg_array_associations_spec.rb +14 -2
- data/spec/extensions/spec_helper.rb +1 -0
- data/spec/integration/associations_test.rb +4 -4
- data/spec/integration/dataset_test.rb +2 -0
- data/spec/integration/spec_helper.rb +5 -11
- data/spec/model/spec_helper.rb +1 -0
- metadata +35 -165
- data/doc/release_notes/1.0.txt +0 -38
- data/doc/release_notes/1.1.txt +0 -143
- data/doc/release_notes/1.3.txt +0 -101
- data/doc/release_notes/1.4.0.txt +0 -53
- data/doc/release_notes/1.5.0.txt +0 -155
- data/doc/release_notes/2.0.0.txt +0 -298
- data/doc/release_notes/2.1.0.txt +0 -271
- data/doc/release_notes/2.10.0.txt +0 -328
- data/doc/release_notes/2.11.0.txt +0 -215
- data/doc/release_notes/2.12.0.txt +0 -534
- data/doc/release_notes/2.2.0.txt +0 -253
- data/doc/release_notes/2.3.0.txt +0 -88
- data/doc/release_notes/2.4.0.txt +0 -106
- data/doc/release_notes/2.5.0.txt +0 -137
- data/doc/release_notes/2.6.0.txt +0 -157
- data/doc/release_notes/2.7.0.txt +0 -166
- data/doc/release_notes/2.8.0.txt +0 -171
- data/doc/release_notes/2.9.0.txt +0 -97
- data/doc/release_notes/3.0.0.txt +0 -221
- data/doc/release_notes/3.1.0.txt +0 -406
- data/doc/release_notes/3.10.0.txt +0 -286
- data/doc/release_notes/3.11.0.txt +0 -254
- data/doc/release_notes/3.12.0.txt +0 -304
- data/doc/release_notes/3.13.0.txt +0 -210
- data/doc/release_notes/3.14.0.txt +0 -118
- data/doc/release_notes/3.15.0.txt +0 -78
- data/doc/release_notes/3.16.0.txt +0 -45
- data/doc/release_notes/3.17.0.txt +0 -58
- data/doc/release_notes/3.18.0.txt +0 -120
- data/doc/release_notes/3.19.0.txt +0 -67
- data/doc/release_notes/3.2.0.txt +0 -268
- data/doc/release_notes/3.20.0.txt +0 -41
- data/doc/release_notes/3.21.0.txt +0 -87
- data/doc/release_notes/3.22.0.txt +0 -39
- data/doc/release_notes/3.23.0.txt +0 -172
- data/doc/release_notes/3.24.0.txt +0 -420
- data/doc/release_notes/3.25.0.txt +0 -88
- data/doc/release_notes/3.26.0.txt +0 -88
- data/doc/release_notes/3.27.0.txt +0 -82
- data/doc/release_notes/3.28.0.txt +0 -304
- data/doc/release_notes/3.29.0.txt +0 -459
- data/doc/release_notes/3.3.0.txt +0 -192
- data/doc/release_notes/3.30.0.txt +0 -135
- data/doc/release_notes/3.31.0.txt +0 -146
- data/doc/release_notes/3.32.0.txt +0 -202
- data/doc/release_notes/3.33.0.txt +0 -157
- data/doc/release_notes/3.34.0.txt +0 -671
- data/doc/release_notes/3.35.0.txt +0 -144
- data/doc/release_notes/3.36.0.txt +0 -245
- data/doc/release_notes/3.37.0.txt +0 -338
- data/doc/release_notes/3.38.0.txt +0 -234
- data/doc/release_notes/3.39.0.txt +0 -237
- data/doc/release_notes/3.4.0.txt +0 -325
- data/doc/release_notes/3.40.0.txt +0 -73
- data/doc/release_notes/3.41.0.txt +0 -155
- data/doc/release_notes/3.42.0.txt +0 -74
- data/doc/release_notes/3.43.0.txt +0 -105
- data/doc/release_notes/3.44.0.txt +0 -152
- data/doc/release_notes/3.45.0.txt +0 -179
- data/doc/release_notes/3.46.0.txt +0 -122
- data/doc/release_notes/3.47.0.txt +0 -270
- data/doc/release_notes/3.48.0.txt +0 -477
- data/doc/release_notes/3.5.0.txt +0 -510
- data/doc/release_notes/3.6.0.txt +0 -366
- data/doc/release_notes/3.7.0.txt +0 -179
- data/doc/release_notes/3.8.0.txt +0 -151
- data/doc/release_notes/3.9.0.txt +0 -233
@@ -1,286 +0,0 @@
|
|
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.
|
@@ -1,254 +0,0 @@
|
|
1
|
-
= New Features
|
2
|
-
|
3
|
-
* A few new features were added to query logging. Sequel now
|
4
|
-
includes execution time when logging queries. Queries that
|
5
|
-
raise exceptions are now logged at ERROR level. You can now
|
6
|
-
set the log_warn_duration attribute on the Database instance
|
7
|
-
and queries that take longer than that will be logged at WARN
|
8
|
-
level. By using different log levels, you can now only log
|
9
|
-
queries that raise errors, or only log queries that take a long
|
10
|
-
time.
|
11
|
-
|
12
|
-
# The default - Log all successful queries at INFO level
|
13
|
-
DB.log_warn_duration = nil
|
14
|
-
|
15
|
-
# Log all successful queries at WARN level
|
16
|
-
DB.log_warn_duration = 0
|
17
|
-
|
18
|
-
# Log successful queries that take the database more than half a
|
19
|
-
# second at WARN level, other successful queries at INFO level
|
20
|
-
DB.log_warn_duration = 0.5
|
21
|
-
|
22
|
-
All adapters included with Sequel have been modified to support
|
23
|
-
the new logging API. The previous API is still available, so
|
24
|
-
any external adapters should still work, though switching to the
|
25
|
-
new logging API is encouraged.
|
26
|
-
|
27
|
-
* Sequel::Model now has a require_modification flag. If not set
|
28
|
-
explicitly, it is enabled by default if the dataset provides an
|
29
|
-
accurate number of rows matched by an update or delete statement.
|
30
|
-
When this setting is enabled, Sequel will raise an exception if
|
31
|
-
you attempt to update or delete a model object and it doesn't end
|
32
|
-
up affecting exactly one row. For example:
|
33
|
-
|
34
|
-
DB.create_table(:as){primary_key :id}
|
35
|
-
class A < Sequel::Model; end
|
36
|
-
a = A.create
|
37
|
-
|
38
|
-
# delete object from database
|
39
|
-
a.delete
|
40
|
-
|
41
|
-
a.require_modification = false
|
42
|
-
a.save # no error!
|
43
|
-
a.delete # no error!
|
44
|
-
|
45
|
-
a.require_modification = true
|
46
|
-
a.save # Sequel::NoExistingObject exception raised
|
47
|
-
a.delete # Sequel::NoExistingObject exception raised
|
48
|
-
|
49
|
-
Like many other Sequel::Model settings, this can be set on a
|
50
|
-
global, per class, and per instance level:
|
51
|
-
|
52
|
-
Sequel::Model.require_modification = false # global
|
53
|
-
Album.require_modification = true # class
|
54
|
-
album.require_modification = false # instance
|
55
|
-
|
56
|
-
* An instance_filters plugin was added to the list of built in
|
57
|
-
plugins, allowing you to add arbitrary filters when updating or
|
58
|
-
destroying an instance. This allows you to continue using models
|
59
|
-
when previously you would have had to drop down to using datasets
|
60
|
-
to get the desired behavior:
|
61
|
-
|
62
|
-
class Item < Sequel::Model
|
63
|
-
plugin :instance_filters
|
64
|
-
end
|
65
|
-
|
66
|
-
# These are two separate objects that represent the same
|
67
|
-
# database row.
|
68
|
-
i1 = Item.first(:id=>1, :delete_allowed=>false)
|
69
|
-
i2 = Item.first(:id=>1, :delete_allowed=>false)
|
70
|
-
|
71
|
-
# Add an instance filter to the object. This filter is in effect
|
72
|
-
# until the object is successfully updated or deleted.
|
73
|
-
i1.instance_filter(:delete_allowed=>true)
|
74
|
-
|
75
|
-
# Attempting to delete the object where the filter doesn't
|
76
|
-
# match any rows raises an error.
|
77
|
-
i1.delete # raises Sequel::Error
|
78
|
-
|
79
|
-
# The other object that represents the same row has no
|
80
|
-
# instance filters, and can be updated normally.
|
81
|
-
i2.update(:delete_allowed=>true)
|
82
|
-
|
83
|
-
# Even though the filter is now still in effect, since the
|
84
|
-
# database row has been updated to allow deleting,
|
85
|
-
# delete now works.
|
86
|
-
i1.delete
|
87
|
-
|
88
|
-
* An :after_connect database option is now supported. If provided,
|
89
|
-
the option value should be a proc that takes a single argument.
|
90
|
-
It will be called with the underlying connection object before
|
91
|
-
connection object is added to the connection pool, allowing you
|
92
|
-
to set per connection options in a thread-safe manner.
|
93
|
-
|
94
|
-
This is useful for customizations you want set on every connection
|
95
|
-
that Sequel doesn't already support. For example, on PostgreSQL
|
96
|
-
if you wanted to set the schema search_path on every connection:
|
97
|
-
|
98
|
-
DB = Sequel.postgres('dbname', :after_connect=>(proc do |conn|
|
99
|
-
conn.execute('SET search_path TO schema1,schema2')
|
100
|
-
end))
|
101
|
-
|
102
|
-
* A :test database option is now supported. If set to true, it
|
103
|
-
automatically calls test_connection to make sure a connection can
|
104
|
-
be made before returning a Database instance. For backwards
|
105
|
-
compatibility reasons, this is not set to true by default, but it
|
106
|
-
is possible that the default will change in a future version of
|
107
|
-
Sequel.
|
108
|
-
|
109
|
-
* The Dataset#select_append method was added, which always appends
|
110
|
-
to the existing selected columns. It operates identically to
|
111
|
-
select_more, except in the case that no columns are currently
|
112
|
-
selected:
|
113
|
-
|
114
|
-
ds = DB[:a]
|
115
|
-
# SELECT * FROM items
|
116
|
-
ds.select_more({:id=>DB[:b].select(:a_id)}.as(:in_b))
|
117
|
-
# SELECT id IN (SELECT a_id FROM b) AS in_b FROM a
|
118
|
-
ds.select_append({:id=>DB[:b].select(:a_id)}.as(:in_b))
|
119
|
-
# SELECT *, id IN (SELECT a_id FROM b) AS in_b FROM a
|
120
|
-
|
121
|
-
* The Dataset#provides_accurate_rows_matched? method was added which
|
122
|
-
allows you to see if the dataset will return the actual number of
|
123
|
-
rows matched/affected by an update or delete call.
|
124
|
-
|
125
|
-
* Sequel will now emulate DISTINCT ON support using GROUP BY on
|
126
|
-
MySQL. On MySQL, GROUP BY is similar to DISTINCT ON, except that
|
127
|
-
the order of returned rows is not deterministic.
|
128
|
-
|
129
|
-
* Support for connecting to Microsoft SQL Server using the JTDS JDBC
|
130
|
-
driver was added to the jdbc adapter.
|
131
|
-
|
132
|
-
* JDNI connection strings are now supported in the JDBC adapter.
|
133
|
-
|
134
|
-
* The JDBC adapter should now work in situations where driver
|
135
|
-
auto-loading has problems, just as when using Tomcat or Trinidad.
|
136
|
-
|
137
|
-
* Sequel's JDBC adapter schema parsing now supports a :scale option,
|
138
|
-
useful for numeric/decimal columns.
|
139
|
-
|
140
|
-
* Sequel's schema parsing on Microsoft SQL Server now supports
|
141
|
-
:column_size and :scale options.
|
142
|
-
|
143
|
-
* When connecting to SQLite, a Database#sqlite_version method is
|
144
|
-
available that gives you the SQLite version as an integer (e.g.
|
145
|
-
30613 for 3.6.13).
|
146
|
-
|
147
|
-
= Other Improvements
|
148
|
-
|
149
|
-
* Sequel no longer raises an error if you give Dataset#filter or
|
150
|
-
related method an empty argument such as {}, [], or ''. This allows
|
151
|
-
code such as the following to work:
|
152
|
-
|
153
|
-
h = {}
|
154
|
-
h[:name] = name if name
|
155
|
-
h[:number] = number if number
|
156
|
-
ds = ds.filter(h)
|
157
|
-
|
158
|
-
Before, this would raise an error if both name and number were
|
159
|
-
nil.
|
160
|
-
|
161
|
-
* Numeric and decimal columns with a 0 scale are now treated as
|
162
|
-
integer columns by the model typecasting code, since such columns
|
163
|
-
cannot store non-integer values.
|
164
|
-
|
165
|
-
* Calling Database#disconnect when using the single threaded
|
166
|
-
connection pool no longer raises an error if there is no current
|
167
|
-
connection.
|
168
|
-
|
169
|
-
* When using the :ignore_index_errors options to
|
170
|
-
Database#create_table, correctly swallow errors raised by Sequel
|
171
|
-
due to the adapter not supporting the given index type.
|
172
|
-
|
173
|
-
* The JDBC adapter no longer leaks ResultSets when retrieving
|
174
|
-
metadata.
|
175
|
-
|
176
|
-
* You can now connect to PostgreSQL when using ruby 1.9 with the
|
177
|
-
-Ku switch.
|
178
|
-
|
179
|
-
* When using the native MySQL adapter, only tinyint(1) columns are
|
180
|
-
now returned as booleans when using the convert_tinyint_to_bool
|
181
|
-
setting (the default). Previously, all tinyint columns would
|
182
|
-
be converted to booleans if the setting was enabled.
|
183
|
-
|
184
|
-
* Correctly handle inserts returning the autogenerated keys when
|
185
|
-
using MySQL JDBC Driver version 5.1.12 with the jdbc adapter.
|
186
|
-
|
187
|
-
* The native MySQL adapter now supports :config_default_group and
|
188
|
-
:config_local_infile options.
|
189
|
-
|
190
|
-
* When connecting to SQLite, you can provide the :auto_vacuum,
|
191
|
-
:foreign_keys, :synchronous, and :temp_store options for
|
192
|
-
making the appropriate PRAGMA setting on the database in a
|
193
|
-
thread-safe manner. The previous thread-unsafe PRAGMA setting
|
194
|
-
methods are available, but their use is discouraged.
|
195
|
-
|
196
|
-
* Sequel will not enable savepoints when connecting to SQLite
|
197
|
-
unless the version is 3.6.8 or greater.
|
198
|
-
|
199
|
-
* Using limit with distinct now works correctly on Microsoft SQL
|
200
|
-
Server.
|
201
|
-
|
202
|
-
* Database#rename_table now works correctly on Microsoft SQL Server.
|
203
|
-
|
204
|
-
* If you specify an explicit :provider when using the ADO adapter,
|
205
|
-
transactions will now work correctly. The default :provider uses
|
206
|
-
a new native connection for each query, so it cannot work with
|
207
|
-
transactions, or things like temporary tables.
|
208
|
-
|
209
|
-
* If you specify an explicit :provider when connecting to Microsoft
|
210
|
-
SQL Server using the ADO adapter (e.g. SQLNCLI10 or SQLNCLI),
|
211
|
-
Sequel is now able to provide an accurate number of rows modified
|
212
|
-
and deleted.
|
213
|
-
|
214
|
-
* Using set_column_allow_null with a decimal column with a precision
|
215
|
-
and scale now works correctly when connecting to Microsoft SQL
|
216
|
-
Server.
|
217
|
-
|
218
|
-
* You can now connect to Microsoft SQL Server using the dbi adapter.
|
219
|
-
|
220
|
-
* Sequel now recognizes the NUMBER database type as a synonym for
|
221
|
-
NUMERIC and DECIMAL, which may help some Oracle users.
|
222
|
-
|
223
|
-
* Transactions can now be rolled back correctly when connecting to
|
224
|
-
Oracle via JDBC.
|
225
|
-
|
226
|
-
* The active_model plugin now supports ActiveModel 3.0.0beta2.
|
227
|
-
|
228
|
-
* Many documentation improvements were made, including the addition
|
229
|
-
of a dataset basics guide, an association basics guide, an expanded
|
230
|
-
virtual row guide, and the separation of the Sequel::Dataset RDoc
|
231
|
-
page into sections. Additional, the RDoc class/method
|
232
|
-
documentation now contains links to the appropriate guides.
|
233
|
-
|
234
|
-
= Backwards Compatibility
|
235
|
-
|
236
|
-
* When connecting to SQLite, Sequel now automatically sets the
|
237
|
-
foreign_keys PRAGMA to true, which will make SQLite 3.6.19+ use
|
238
|
-
database enforced foreign key constraints. If you do not want
|
239
|
-
the database to enforce the foreign key constraints, you should
|
240
|
-
use the :foreign_keys=>false option when connecting to the
|
241
|
-
database.
|
242
|
-
|
243
|
-
* Sequel no longer creates #{plugin_name}_opts class, instance, and
|
244
|
-
dataset methods for each plugin loaded. No built-in plugin used
|
245
|
-
them, and I couldn't find an external plugin that did either.
|
246
|
-
|
247
|
-
* The Model#associations method is no longer available if the
|
248
|
-
default Associations plugin is not loaded due to the
|
249
|
-
SEQUEL_NO_ASSOCIATIONS constant or environment variable being set.
|
250
|
-
|
251
|
-
* DISTINCT ON support is turned off by default, and only enabled when
|
252
|
-
using PostgreSQL, since that appears to be the only database that
|
253
|
-
supports it. Previously, it was enabled by default and most common
|
254
|
-
adapters turned it off.
|