viking-sequel 3.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3134 -0
- data/COPYING +19 -0
- data/README.rdoc +723 -0
- data/Rakefile +193 -0
- data/bin/sequel +196 -0
- data/doc/advanced_associations.rdoc +644 -0
- data/doc/cheat_sheet.rdoc +218 -0
- data/doc/dataset_basics.rdoc +106 -0
- data/doc/dataset_filtering.rdoc +158 -0
- data/doc/opening_databases.rdoc +296 -0
- data/doc/prepared_statements.rdoc +104 -0
- data/doc/reflection.rdoc +84 -0
- data/doc/release_notes/1.0.txt +38 -0
- data/doc/release_notes/1.1.txt +143 -0
- data/doc/release_notes/1.3.txt +101 -0
- data/doc/release_notes/1.4.0.txt +53 -0
- data/doc/release_notes/1.5.0.txt +155 -0
- data/doc/release_notes/2.0.0.txt +298 -0
- data/doc/release_notes/2.1.0.txt +271 -0
- data/doc/release_notes/2.10.0.txt +328 -0
- data/doc/release_notes/2.11.0.txt +215 -0
- data/doc/release_notes/2.12.0.txt +534 -0
- data/doc/release_notes/2.2.0.txt +253 -0
- data/doc/release_notes/2.3.0.txt +88 -0
- data/doc/release_notes/2.4.0.txt +106 -0
- data/doc/release_notes/2.5.0.txt +137 -0
- data/doc/release_notes/2.6.0.txt +157 -0
- data/doc/release_notes/2.7.0.txt +166 -0
- data/doc/release_notes/2.8.0.txt +171 -0
- data/doc/release_notes/2.9.0.txt +97 -0
- data/doc/release_notes/3.0.0.txt +221 -0
- data/doc/release_notes/3.1.0.txt +406 -0
- data/doc/release_notes/3.10.0.txt +286 -0
- data/doc/release_notes/3.2.0.txt +268 -0
- data/doc/release_notes/3.3.0.txt +192 -0
- data/doc/release_notes/3.4.0.txt +325 -0
- data/doc/release_notes/3.5.0.txt +510 -0
- data/doc/release_notes/3.6.0.txt +366 -0
- data/doc/release_notes/3.7.0.txt +179 -0
- data/doc/release_notes/3.8.0.txt +151 -0
- data/doc/release_notes/3.9.0.txt +233 -0
- data/doc/schema.rdoc +36 -0
- data/doc/sharding.rdoc +113 -0
- data/doc/virtual_rows.rdoc +205 -0
- data/lib/sequel.rb +1 -0
- data/lib/sequel/adapters/ado.rb +90 -0
- data/lib/sequel/adapters/ado/mssql.rb +30 -0
- data/lib/sequel/adapters/amalgalite.rb +176 -0
- data/lib/sequel/adapters/db2.rb +139 -0
- data/lib/sequel/adapters/dbi.rb +113 -0
- data/lib/sequel/adapters/do.rb +188 -0
- data/lib/sequel/adapters/do/mysql.rb +49 -0
- data/lib/sequel/adapters/do/postgres.rb +91 -0
- data/lib/sequel/adapters/do/sqlite.rb +40 -0
- data/lib/sequel/adapters/firebird.rb +283 -0
- data/lib/sequel/adapters/informix.rb +77 -0
- data/lib/sequel/adapters/jdbc.rb +587 -0
- data/lib/sequel/adapters/jdbc/as400.rb +58 -0
- data/lib/sequel/adapters/jdbc/h2.rb +133 -0
- data/lib/sequel/adapters/jdbc/mssql.rb +57 -0
- data/lib/sequel/adapters/jdbc/mysql.rb +78 -0
- data/lib/sequel/adapters/jdbc/oracle.rb +50 -0
- data/lib/sequel/adapters/jdbc/postgresql.rb +108 -0
- data/lib/sequel/adapters/jdbc/sqlite.rb +55 -0
- data/lib/sequel/adapters/mysql.rb +421 -0
- data/lib/sequel/adapters/odbc.rb +143 -0
- data/lib/sequel/adapters/odbc/mssql.rb +42 -0
- data/lib/sequel/adapters/openbase.rb +64 -0
- data/lib/sequel/adapters/oracle.rb +131 -0
- data/lib/sequel/adapters/postgres.rb +504 -0
- data/lib/sequel/adapters/shared/mssql.rb +490 -0
- data/lib/sequel/adapters/shared/mysql.rb +498 -0
- data/lib/sequel/adapters/shared/oracle.rb +195 -0
- data/lib/sequel/adapters/shared/postgres.rb +830 -0
- data/lib/sequel/adapters/shared/progress.rb +44 -0
- data/lib/sequel/adapters/shared/sqlite.rb +389 -0
- data/lib/sequel/adapters/sqlite.rb +224 -0
- data/lib/sequel/adapters/utils/stored_procedures.rb +84 -0
- data/lib/sequel/connection_pool.rb +99 -0
- data/lib/sequel/connection_pool/sharded_single.rb +84 -0
- data/lib/sequel/connection_pool/sharded_threaded.rb +211 -0
- data/lib/sequel/connection_pool/single.rb +29 -0
- data/lib/sequel/connection_pool/threaded.rb +150 -0
- data/lib/sequel/core.rb +293 -0
- data/lib/sequel/core_sql.rb +241 -0
- data/lib/sequel/database.rb +1079 -0
- data/lib/sequel/database/schema_generator.rb +327 -0
- data/lib/sequel/database/schema_methods.rb +203 -0
- data/lib/sequel/database/schema_sql.rb +320 -0
- data/lib/sequel/dataset.rb +32 -0
- data/lib/sequel/dataset/actions.rb +441 -0
- data/lib/sequel/dataset/features.rb +86 -0
- data/lib/sequel/dataset/graph.rb +254 -0
- data/lib/sequel/dataset/misc.rb +119 -0
- data/lib/sequel/dataset/mutation.rb +64 -0
- data/lib/sequel/dataset/prepared_statements.rb +227 -0
- data/lib/sequel/dataset/query.rb +709 -0
- data/lib/sequel/dataset/sql.rb +996 -0
- data/lib/sequel/exceptions.rb +51 -0
- data/lib/sequel/extensions/blank.rb +43 -0
- data/lib/sequel/extensions/inflector.rb +242 -0
- data/lib/sequel/extensions/looser_typecasting.rb +21 -0
- data/lib/sequel/extensions/migration.rb +239 -0
- data/lib/sequel/extensions/named_timezones.rb +61 -0
- data/lib/sequel/extensions/pagination.rb +100 -0
- data/lib/sequel/extensions/pretty_table.rb +82 -0
- data/lib/sequel/extensions/query.rb +52 -0
- data/lib/sequel/extensions/schema_dumper.rb +271 -0
- data/lib/sequel/extensions/sql_expr.rb +122 -0
- data/lib/sequel/extensions/string_date_time.rb +46 -0
- data/lib/sequel/extensions/thread_local_timezones.rb +48 -0
- data/lib/sequel/metaprogramming.rb +9 -0
- data/lib/sequel/model.rb +120 -0
- data/lib/sequel/model/associations.rb +1514 -0
- data/lib/sequel/model/base.rb +1069 -0
- data/lib/sequel/model/default_inflections.rb +45 -0
- data/lib/sequel/model/errors.rb +39 -0
- data/lib/sequel/model/exceptions.rb +21 -0
- data/lib/sequel/model/inflections.rb +162 -0
- data/lib/sequel/model/plugins.rb +70 -0
- data/lib/sequel/plugins/active_model.rb +59 -0
- data/lib/sequel/plugins/association_dependencies.rb +103 -0
- data/lib/sequel/plugins/association_proxies.rb +41 -0
- data/lib/sequel/plugins/boolean_readers.rb +53 -0
- data/lib/sequel/plugins/caching.rb +141 -0
- data/lib/sequel/plugins/class_table_inheritance.rb +214 -0
- data/lib/sequel/plugins/composition.rb +138 -0
- data/lib/sequel/plugins/force_encoding.rb +72 -0
- data/lib/sequel/plugins/hook_class_methods.rb +126 -0
- data/lib/sequel/plugins/identity_map.rb +116 -0
- data/lib/sequel/plugins/instance_filters.rb +98 -0
- data/lib/sequel/plugins/instance_hooks.rb +57 -0
- data/lib/sequel/plugins/lazy_attributes.rb +77 -0
- data/lib/sequel/plugins/many_through_many.rb +208 -0
- data/lib/sequel/plugins/nested_attributes.rb +206 -0
- data/lib/sequel/plugins/optimistic_locking.rb +81 -0
- data/lib/sequel/plugins/rcte_tree.rb +281 -0
- data/lib/sequel/plugins/schema.rb +66 -0
- data/lib/sequel/plugins/serialization.rb +166 -0
- data/lib/sequel/plugins/single_table_inheritance.rb +74 -0
- data/lib/sequel/plugins/subclasses.rb +45 -0
- data/lib/sequel/plugins/tactical_eager_loading.rb +61 -0
- data/lib/sequel/plugins/timestamps.rb +87 -0
- data/lib/sequel/plugins/touch.rb +118 -0
- data/lib/sequel/plugins/typecast_on_load.rb +72 -0
- data/lib/sequel/plugins/validation_class_methods.rb +405 -0
- data/lib/sequel/plugins/validation_helpers.rb +223 -0
- data/lib/sequel/sql.rb +1020 -0
- data/lib/sequel/timezones.rb +161 -0
- data/lib/sequel/version.rb +12 -0
- data/lib/sequel_core.rb +1 -0
- data/lib/sequel_model.rb +1 -0
- data/spec/adapters/firebird_spec.rb +407 -0
- data/spec/adapters/informix_spec.rb +97 -0
- data/spec/adapters/mssql_spec.rb +403 -0
- data/spec/adapters/mysql_spec.rb +1019 -0
- data/spec/adapters/oracle_spec.rb +286 -0
- data/spec/adapters/postgres_spec.rb +969 -0
- data/spec/adapters/spec_helper.rb +51 -0
- data/spec/adapters/sqlite_spec.rb +432 -0
- data/spec/core/connection_pool_spec.rb +808 -0
- data/spec/core/core_sql_spec.rb +417 -0
- data/spec/core/database_spec.rb +1662 -0
- data/spec/core/dataset_spec.rb +3827 -0
- data/spec/core/expression_filters_spec.rb +595 -0
- data/spec/core/object_graph_spec.rb +296 -0
- data/spec/core/schema_generator_spec.rb +159 -0
- data/spec/core/schema_spec.rb +830 -0
- data/spec/core/spec_helper.rb +56 -0
- data/spec/core/version_spec.rb +7 -0
- data/spec/extensions/active_model_spec.rb +76 -0
- data/spec/extensions/association_dependencies_spec.rb +127 -0
- data/spec/extensions/association_proxies_spec.rb +50 -0
- data/spec/extensions/blank_spec.rb +67 -0
- data/spec/extensions/boolean_readers_spec.rb +92 -0
- data/spec/extensions/caching_spec.rb +250 -0
- data/spec/extensions/class_table_inheritance_spec.rb +252 -0
- data/spec/extensions/composition_spec.rb +194 -0
- data/spec/extensions/force_encoding_spec.rb +117 -0
- data/spec/extensions/hook_class_methods_spec.rb +470 -0
- data/spec/extensions/identity_map_spec.rb +202 -0
- data/spec/extensions/inflector_spec.rb +181 -0
- data/spec/extensions/instance_filters_spec.rb +55 -0
- data/spec/extensions/instance_hooks_spec.rb +133 -0
- data/spec/extensions/lazy_attributes_spec.rb +153 -0
- data/spec/extensions/looser_typecasting_spec.rb +39 -0
- data/spec/extensions/many_through_many_spec.rb +884 -0
- data/spec/extensions/migration_spec.rb +332 -0
- data/spec/extensions/named_timezones_spec.rb +72 -0
- data/spec/extensions/nested_attributes_spec.rb +396 -0
- data/spec/extensions/optimistic_locking_spec.rb +100 -0
- data/spec/extensions/pagination_spec.rb +99 -0
- data/spec/extensions/pretty_table_spec.rb +91 -0
- data/spec/extensions/query_spec.rb +85 -0
- data/spec/extensions/rcte_tree_spec.rb +205 -0
- data/spec/extensions/schema_dumper_spec.rb +357 -0
- data/spec/extensions/schema_spec.rb +127 -0
- data/spec/extensions/serialization_spec.rb +209 -0
- data/spec/extensions/single_table_inheritance_spec.rb +96 -0
- data/spec/extensions/spec_helper.rb +91 -0
- data/spec/extensions/sql_expr_spec.rb +89 -0
- data/spec/extensions/string_date_time_spec.rb +93 -0
- data/spec/extensions/subclasses_spec.rb +52 -0
- data/spec/extensions/tactical_eager_loading_spec.rb +65 -0
- data/spec/extensions/thread_local_timezones_spec.rb +45 -0
- data/spec/extensions/timestamps_spec.rb +150 -0
- data/spec/extensions/touch_spec.rb +155 -0
- data/spec/extensions/typecast_on_load_spec.rb +69 -0
- data/spec/extensions/validation_class_methods_spec.rb +984 -0
- data/spec/extensions/validation_helpers_spec.rb +438 -0
- data/spec/integration/associations_test.rb +281 -0
- data/spec/integration/database_test.rb +26 -0
- data/spec/integration/dataset_test.rb +963 -0
- data/spec/integration/eager_loader_test.rb +734 -0
- data/spec/integration/model_test.rb +130 -0
- data/spec/integration/plugin_test.rb +814 -0
- data/spec/integration/prepared_statement_test.rb +213 -0
- data/spec/integration/schema_test.rb +361 -0
- data/spec/integration/spec_helper.rb +73 -0
- data/spec/integration/timezone_test.rb +55 -0
- data/spec/integration/transaction_test.rb +122 -0
- data/spec/integration/type_test.rb +96 -0
- data/spec/model/association_reflection_spec.rb +175 -0
- data/spec/model/associations_spec.rb +2633 -0
- data/spec/model/base_spec.rb +418 -0
- data/spec/model/dataset_methods_spec.rb +78 -0
- data/spec/model/eager_loading_spec.rb +1391 -0
- data/spec/model/hooks_spec.rb +240 -0
- data/spec/model/inflector_spec.rb +26 -0
- data/spec/model/model_spec.rb +593 -0
- data/spec/model/plugins_spec.rb +236 -0
- data/spec/model/record_spec.rb +1500 -0
- data/spec/model/spec_helper.rb +97 -0
- data/spec/model/validations_spec.rb +153 -0
- data/spec/rcov.opts +6 -0
- data/spec/spec_config.rb.example +10 -0
- metadata +346 -0
@@ -0,0 +1,534 @@
|
|
1
|
+
Overview
|
2
|
+
--------
|
3
|
+
|
4
|
+
Sequel 2.12 is really just a stepping stone to Sequel 3.0, which will
|
5
|
+
be released next month. All major changes currently planned for 3.0
|
6
|
+
have been made in 2.12, but 2.12 contains many features that have
|
7
|
+
been deprecated and will be removed or moved into extensions or
|
8
|
+
plugins in 3.0.
|
9
|
+
|
10
|
+
Deprecation Logging
|
11
|
+
-------------------
|
12
|
+
|
13
|
+
If you use a deprecated method or feature, Sequel will by default
|
14
|
+
print a deprecation message and 10 lines of backtrace to standard
|
15
|
+
error to easily allow you to figure out which code needs to be
|
16
|
+
updated. You can change where the deprecation messages go and how
|
17
|
+
many lines of backtrace are given using the following:
|
18
|
+
|
19
|
+
# Log deprecation information to a file
|
20
|
+
Sequel::Deprecation.output = File.open('deprecated.txt', 'wb')
|
21
|
+
|
22
|
+
# Use 5 lines of backtrace when logging deprecation messages
|
23
|
+
Sequel::Deprecation.backtraces = 5
|
24
|
+
|
25
|
+
# Use all backtrace lines when logging deprecation messages
|
26
|
+
Sequel::Deprecation.backtraces = true
|
27
|
+
|
28
|
+
# Don't include backtraces in the deprecation logging
|
29
|
+
Sequel.Deprecation.backtraces = false
|
30
|
+
|
31
|
+
# Turn off all deprecation logging
|
32
|
+
Sequel::Deprecation.output = nil
|
33
|
+
|
34
|
+
Deprecated Features Moving to Extensions
|
35
|
+
----------------------------------------
|
36
|
+
|
37
|
+
* Migrations are being moved into sequel/extensions/migration. There
|
38
|
+
isn't any reason that they should be loaded in normal use since
|
39
|
+
they are used so rarely. The sequel command line tool uses this
|
40
|
+
extension to run the migrations.
|
41
|
+
|
42
|
+
* Adding the blank? method to all objects has been moved into
|
43
|
+
sequel/extensions/blank.
|
44
|
+
|
45
|
+
* Dataset#print and Sequel::PrettyTable have been moved into
|
46
|
+
sequel/extensions/pretty_table.
|
47
|
+
|
48
|
+
* Dataset#query and related methods have been moved into
|
49
|
+
sequel/extensions/query.
|
50
|
+
|
51
|
+
* Dataset#paginate and related methods have been moved into
|
52
|
+
sequel/extensions/pagination.
|
53
|
+
|
54
|
+
* String inflection methods (e.g. "people".singularize) have been
|
55
|
+
moved into sequel/extensions/inflector.
|
56
|
+
|
57
|
+
* String date/time conversion methods (e.g. '2000-01-01'.to_date)
|
58
|
+
have been moved into sequel/extensions/string_date_time.
|
59
|
+
|
60
|
+
Deprecated Model Features Moving to Plugins
|
61
|
+
-------------------------------------------
|
62
|
+
|
63
|
+
* Model validation class methods have been moved to a plugin. Sequel
|
64
|
+
users are encouraged to write their own validate instance method
|
65
|
+
instead. A new validation_helpers plugin has been added to make
|
66
|
+
this easier, it's explained in the New Features section. If you
|
67
|
+
want to continue using the validation class methods:
|
68
|
+
|
69
|
+
Sequel::Model.plugin :validation_class_methods
|
70
|
+
|
71
|
+
* Model hook class methods have been moved to a plugin. Sequel users
|
72
|
+
are encouraged to write their own hook instance methods, and call
|
73
|
+
super to get hooks specified in superclasses or plugins. If you
|
74
|
+
want to continue using the hook class methods:
|
75
|
+
|
76
|
+
Sequel::Model.plugin :hook_class_methods
|
77
|
+
|
78
|
+
* Model schema methods (e.g. Model.set_schema, Model.create_table,
|
79
|
+
Model.drop_table) have been moved to a plugin. The use of these
|
80
|
+
methods has been discouraged for a long time. If you want to use
|
81
|
+
them:
|
82
|
+
|
83
|
+
Sequel::Model.plugin :schema
|
84
|
+
|
85
|
+
* Model.set_sti_key has been moved to a plugin. So you should
|
86
|
+
change:
|
87
|
+
|
88
|
+
MyModel.set_sti_key :key_column
|
89
|
+
|
90
|
+
to:
|
91
|
+
|
92
|
+
MyModel.plugin :single_table_inheritance, :key_column
|
93
|
+
|
94
|
+
* Model.set_cache has been moved to a plugin. So you should change:
|
95
|
+
|
96
|
+
MyModel.set_cache cache_store, opts
|
97
|
+
|
98
|
+
to:
|
99
|
+
|
100
|
+
MyModel.plugin :caching, cache_store, opts
|
101
|
+
|
102
|
+
* Model.serialize has been moved to a plugin. So you should change:
|
103
|
+
|
104
|
+
MyModel.serialize :column, :format=>:yaml
|
105
|
+
|
106
|
+
to:
|
107
|
+
|
108
|
+
MyModel.plugin :serialization, :yaml, :column
|
109
|
+
|
110
|
+
Because the previous serialization support depended on dataset
|
111
|
+
transforms, the new serialization support is implemented
|
112
|
+
differently, and behavior may not be identical in all cases.
|
113
|
+
However, this should be a drop in replacement for most users.
|
114
|
+
|
115
|
+
Deprecated Features To Be Removed in Sequel 3.0
|
116
|
+
-----------------------------------------------
|
117
|
+
|
118
|
+
* Dataset#transform is deprecated without any replacement planned.
|
119
|
+
It was announced on the Sequel mailing list that transforms would
|
120
|
+
be removed unless someone said they needed them, and nobody said
|
121
|
+
that they did.
|
122
|
+
|
123
|
+
* Dataset#multi_insert and Dataset#import are no longer aliases
|
124
|
+
of each other. Dataset#multi_insert now takes an array of hashes,
|
125
|
+
and Dataset#import now takes an array of columns and an array
|
126
|
+
of arrays of values. Using multi_insert with import's API or
|
127
|
+
vice-versa is deprecated.
|
128
|
+
|
129
|
+
* Calling Dataset#[] with no arguments or an integer argument is
|
130
|
+
deprecated.
|
131
|
+
|
132
|
+
* Calling Dataset#map with both an argument and a block is
|
133
|
+
deprecated.
|
134
|
+
|
135
|
+
* Database#multi_threaded? and Database#logger are both deprecated.
|
136
|
+
|
137
|
+
* Calling Database#transaction with a symbol to specify which server
|
138
|
+
to use is deprecated. You should now call it with an option hash
|
139
|
+
with a :server key.
|
140
|
+
|
141
|
+
* Array#extract_options! and Object#is_one_of? are both deprecated.
|
142
|
+
|
143
|
+
* The metaprogramming methods taken from metaid are deprecated and
|
144
|
+
have been moved into Sequel::Metaprogramming. If you want them
|
145
|
+
available to specific objects/classes, just include or extend with
|
146
|
+
Sequel::Metaprogramming. If you want all objects to have access to
|
147
|
+
the metaprogramming methods, install metaid. Note that the
|
148
|
+
class_def method from metaid doesn't exist in
|
149
|
+
Sequel::Metaprogramming, since it really isn't different from
|
150
|
+
define_method (except it is public instead of private).
|
151
|
+
|
152
|
+
* Module#class_attr_overridable, #class_attr_reader, and
|
153
|
+
#metaalias are deprecated.
|
154
|
+
|
155
|
+
* Using Model#set or #update when the columns for the model are not
|
156
|
+
set and you provide a hash with symbol keys is deprecated.
|
157
|
+
Basically, you must have setter methods now for any columns used in
|
158
|
+
#set or #update.
|
159
|
+
|
160
|
+
* Model#set_with_params and #update_with_params are deprecated, use
|
161
|
+
#set and #update instead.
|
162
|
+
|
163
|
+
* Model#save! is deprecated, use #save(:validate=>false).
|
164
|
+
|
165
|
+
* Model.is and Model.is_a are deprecated, use Model.plugin.
|
166
|
+
|
167
|
+
* Model.str_columns, Model#str_columns, #set_values, and
|
168
|
+
#update_values are deprecated. You should use #set and
|
169
|
+
#update instead of #set_values and #update_values, though they
|
170
|
+
operate differently.
|
171
|
+
|
172
|
+
* Model.delete_all, Model.destroy_all, Model.size, and Model.uniq
|
173
|
+
are deprecated, use .delete, .destroy, .count, and .distinct.
|
174
|
+
|
175
|
+
* Model.belongs_to, Model.has_many, and Model.has_and_belongs_to_many
|
176
|
+
are deprecated, use .many_to_one, .one_to_many, and .many_to_many.
|
177
|
+
|
178
|
+
* Model#dataset is deprecated, use Model.dataset.
|
179
|
+
|
180
|
+
* SQL::CastMethods#cast_as is deprecated, use #cast.
|
181
|
+
|
182
|
+
* Calling Database#schema without a table argument is deprecated.
|
183
|
+
|
184
|
+
* Dataset#uniq is deprecated, use Dataset#distinct.
|
185
|
+
|
186
|
+
* Dataset#symbol_to_column_ref is deprecated, use #literal.
|
187
|
+
|
188
|
+
* Dataset#quote_column_ref is deprecated, use #quote_identifier.
|
189
|
+
|
190
|
+
* Dataset#size is deprecated, use #count.
|
191
|
+
|
192
|
+
* Passing options to Dataset#each, #all, #single_record,
|
193
|
+
#single_value, #sql, #select_sql, #update, #update_sql, #delete,
|
194
|
+
#delete_sql, and #exists is deprecated. Modify the options first
|
195
|
+
using clone or a related method, then call one of the above
|
196
|
+
methods.
|
197
|
+
|
198
|
+
* Dataset#create_view and #create_or_replace_view are deprecated,
|
199
|
+
use the database methods instead.
|
200
|
+
|
201
|
+
* Dataset.dataset_classes, #model_classes, #polymorphic_key, and
|
202
|
+
#set_model are deprecated.
|
203
|
+
|
204
|
+
* Database#>> is deprecated.
|
205
|
+
|
206
|
+
* String#to_blob and SQL::Blob#to_blob are deprecated, use
|
207
|
+
#to_sequel_blob.
|
208
|
+
|
209
|
+
* The use of Symbol#| to create array subscripts is deprecated,
|
210
|
+
use Symbol#sql_subscript.
|
211
|
+
|
212
|
+
* Symbol#to_column_ref is deprecated, use Dataset#literal.
|
213
|
+
|
214
|
+
* String#expr is deprecated, use String#lit.
|
215
|
+
|
216
|
+
* Array#to_sql, String#to_sql, and String#split_sql are deprecated.
|
217
|
+
|
218
|
+
* Passing an array to Database#<< is deprecated.
|
219
|
+
|
220
|
+
* Range#interval is deprecated.
|
221
|
+
|
222
|
+
* Enumerable#send_each is deprecated.
|
223
|
+
|
224
|
+
* When using ruby 1.8, Hash#key is deprecated.
|
225
|
+
|
226
|
+
* Sequel.open is deprecated, use Sequel.connect.
|
227
|
+
|
228
|
+
* Sequel.use_parse_tree and Sequel.use_parse_tree= are deprecated.
|
229
|
+
|
230
|
+
* All upcase_identifier methods and the :upcase_identifiers database
|
231
|
+
option are deprecated, use identifier_input_method = :upcase
|
232
|
+
instead.
|
233
|
+
|
234
|
+
* Using a virtual row block without an argument is deprecated, see
|
235
|
+
Sequel.virtual_row_instance_eval= under New Features.
|
236
|
+
|
237
|
+
* When using the JDBC adapter, Java::JavaSQL::Timestamp#usec is
|
238
|
+
deprecated. Sequel has returned Java::JavaSQL::Timestamp as
|
239
|
+
DateTime or Time for a few versions, so this shouldn't affect most
|
240
|
+
people.
|
241
|
+
|
242
|
+
* Sequel will no longer require bigdecimal/util, enumerator, or yaml
|
243
|
+
in 3.0. If you need them in your code, make sure you require
|
244
|
+
them yourself. Using features added by requiring these standard
|
245
|
+
libaries will not bring up a deprecation warning, for obvious
|
246
|
+
reasons.
|
247
|
+
|
248
|
+
* Sequel::Error::InvalidTransform, Sequel::Error::NoExistingFilter,
|
249
|
+
and Sequel::Error::InvalidStatement exceptions will be removed in
|
250
|
+
Sequel 3.0. You will not get a deprecation message if you reference
|
251
|
+
them in 2.12.
|
252
|
+
|
253
|
+
* Sequel::Model::Validation::Errors is deprecated, use
|
254
|
+
Sequel::Model::Errors instead. Referencing the old name will not
|
255
|
+
bring up a deprecation message.
|
256
|
+
|
257
|
+
New Features
|
258
|
+
------------
|
259
|
+
|
260
|
+
* Sequel.virtual_row_instance_eval= was added, which lets you give
|
261
|
+
Sequel 2.12 the behavior that will be the standard in 3.0.
|
262
|
+
It changes blocks passed to Dataset#filter, #select, or #order that
|
263
|
+
don't accept arguments (or accept any number of arguments) to
|
264
|
+
instance eval the block in the context of a new VirtualRow
|
265
|
+
instance instead of passing a new VirtualRow instance to the block.
|
266
|
+
It allows you to change code that looks like this:
|
267
|
+
|
268
|
+
dataset.filter{|o| (o.number > 10) & (o.name > 'M')}
|
269
|
+
|
270
|
+
to:
|
271
|
+
|
272
|
+
dataset.filter{(number > 10) & (name > 'M')}
|
273
|
+
|
274
|
+
When instance_eval is used, only local variables are available
|
275
|
+
to the block. Any calls to instance methods will be interpreted
|
276
|
+
as calling VirtualRow#method_missing, which generates identifiers
|
277
|
+
or functions. When virtual_row_instance_eval is enabled, the
|
278
|
+
following type of code will break:
|
279
|
+
|
280
|
+
# amount is a instance method
|
281
|
+
dataset.filter{:number + amount > 0}
|
282
|
+
|
283
|
+
Just like this example, the only type of code that should break is
|
284
|
+
when a virtual row block was used when it wasn't necessary (since
|
285
|
+
it doesn't use the VirtualRow argument).
|
286
|
+
|
287
|
+
When Sequel.virtual_row_instance_eval = false, using a virtual row
|
288
|
+
block that doesn't accept an argument will cause a deprecation
|
289
|
+
message.
|
290
|
+
|
291
|
+
Here's a regular expression that should catch most places where you
|
292
|
+
are using a virtual row block without an argument.
|
293
|
+
|
294
|
+
egrep -nr '[^A-Za-z0-9_](filter|select|select_more|order|order_more|get|where|having|from|first|and|or|exclude|find|subset|constraint|check)( *(\([^)]*\) *)?){*[^|]' *
|
295
|
+
|
296
|
+
An RDoc page explaining virtual row blocks was added as well.
|
297
|
+
|
298
|
+
* A validation_helpers model plugin was added that allows you to do
|
299
|
+
validations similar to the old class level validations inside
|
300
|
+
the Model#validate instance method. The API has changed, but it's
|
301
|
+
capable of most of the same validations. It doesn't handle
|
302
|
+
acceptance_of or confirmation_of validations, as those shouldn't be
|
303
|
+
handled in the model.
|
304
|
+
|
305
|
+
# Old class level validations
|
306
|
+
validates_format_of :col, :with=>/.../
|
307
|
+
validates_length_of :col, :maximum=>5
|
308
|
+
validates_length_of :col, :minimum=>3
|
309
|
+
validates_length_of :col, :is=>4
|
310
|
+
validates_length_of :col, :within=>3..5
|
311
|
+
validates_not_string :col
|
312
|
+
validates_numericality_of :col
|
313
|
+
validates_numericality_of :col, :only_integer=>true
|
314
|
+
validates_presence_of :col
|
315
|
+
validates_inclusion_of :col, :in=>[3, 4, 5]
|
316
|
+
validates_uniqueness_of :col, :col2
|
317
|
+
validates_uniqueness_of([:col, :col2])
|
318
|
+
|
319
|
+
# New instance level validations
|
320
|
+
def validate
|
321
|
+
validates_format /.../, :col
|
322
|
+
validates_max_length 5, :col
|
323
|
+
validates_min_length 3, :col
|
324
|
+
validates_exact_length 4, :col
|
325
|
+
validates_length_range 3..5, :col
|
326
|
+
validates_not_string :col
|
327
|
+
validates_numeric :col
|
328
|
+
validates_integer :col
|
329
|
+
validates_presence :col
|
330
|
+
validates_includes([3,4,5], :col)
|
331
|
+
validates_unique :col, :col2
|
332
|
+
validates_unique([:col, :col2])
|
333
|
+
end
|
334
|
+
|
335
|
+
Another change made is to specify the same type of validation on
|
336
|
+
multiple attributes, you must use an array:
|
337
|
+
|
338
|
+
# Old
|
339
|
+
validates_length_of :name, :password, :within=>3..5
|
340
|
+
|
341
|
+
# New
|
342
|
+
def validate
|
343
|
+
validates_length_range 3..5, [:name, :password]
|
344
|
+
end
|
345
|
+
|
346
|
+
The :message, :allow_blank, :allow_missing, and :allow_nil options
|
347
|
+
are still respected. The :tag option is not needed as instance level
|
348
|
+
validations work with code reloading without workarounds. The :if
|
349
|
+
option is also not needed for instance level validations:
|
350
|
+
|
351
|
+
# Old
|
352
|
+
validates_presence_of :name, :if=>:new?
|
353
|
+
validates_presence_of :pass, :if=>{flag > 3}
|
354
|
+
|
355
|
+
# New
|
356
|
+
def validate
|
357
|
+
validates_presence(:name) if new?
|
358
|
+
validates_presence(:pass) if flag > 3
|
359
|
+
end
|
360
|
+
|
361
|
+
The validates_each also doesn't have an equivalent instance method,
|
362
|
+
since it is much easier to just write your own validation:
|
363
|
+
|
364
|
+
# Old
|
365
|
+
validates_each(:date) do |o,a,v|
|
366
|
+
o.errors.add(a, '...') unless v > Date.today
|
367
|
+
end
|
368
|
+
|
369
|
+
# New
|
370
|
+
def validate
|
371
|
+
errors.add(:date, '...') unless date > Date.today
|
372
|
+
end
|
373
|
+
|
374
|
+
* MySQL adapter datasets now have on_duplicate_key_update and
|
375
|
+
insert_ignore methods which modify the SQL used to support
|
376
|
+
ON DUPLICATE KEY UPDATE and INSERT INGORE syntax in multi_insert
|
377
|
+
and import.
|
378
|
+
|
379
|
+
* If you use the MySQL native adapter, you can set:
|
380
|
+
|
381
|
+
Sequel::MySQL.convert_invalid_date_time = nil
|
382
|
+
|
383
|
+
to return dates like "0000-00-00" and times like "25:00:00" as
|
384
|
+
nil values instead of raising an error. You can also set it
|
385
|
+
to :string to return the values as strings.
|
386
|
+
|
387
|
+
* You can now use Sequel without modifying any core classes, by
|
388
|
+
defining a SEQUEL_NO_CORE_EXTENSIONS constant or environment
|
389
|
+
variable. In 2.12, this may still add some deprecated methods to
|
390
|
+
the core classes, but in 3.0 no methods will be added to the core
|
391
|
+
classes if you use this.
|
392
|
+
|
393
|
+
* You can now use Sequel::Model without the associations
|
394
|
+
implementation by defining a SEQUEL_NO_ASSOCIATIONS constant or
|
395
|
+
environment variable.
|
396
|
+
|
397
|
+
Other Improvements
|
398
|
+
------------------
|
399
|
+
|
400
|
+
* Model column accessors have been made faster and the overhead of
|
401
|
+
creating them has been reduced significantly.
|
402
|
+
|
403
|
+
* ~{:bool_col=>true} now generates an bool_col IS NOT TRUE filter
|
404
|
+
instead of bool_col != TRUE. This makes it return records with
|
405
|
+
NULL values. If you only want to have false records, you should
|
406
|
+
use {:bool_col=>false}. This works better with SQL's 3 valued
|
407
|
+
boolean logic.
|
408
|
+
|
409
|
+
It is slightly inconsistent with ~{:col=>1}, since that won't
|
410
|
+
return values where col is NULL, but it gives the user the ability
|
411
|
+
to create an IS [NOT] (TRUE|FALSE) filter, which Sequel previously
|
412
|
+
did not support.
|
413
|
+
|
414
|
+
If you really want the old behavior, you can change it to
|
415
|
+
~{true=>:bool_col}.
|
416
|
+
|
417
|
+
* Model.use_transactions was added for setting whether model objects
|
418
|
+
should use transactions when destroying or saving records. Like
|
419
|
+
most Sequel options, it's settable on a global, per model, and
|
420
|
+
per object basis:
|
421
|
+
|
422
|
+
Sequel::Model.use_transactions = false
|
423
|
+
MyModel.use_transactions = true
|
424
|
+
my_model.use_transactions = false
|
425
|
+
|
426
|
+
You can also turn it on or off for specific save calls:
|
427
|
+
|
428
|
+
my_model.save(:transaction=>true)
|
429
|
+
|
430
|
+
* The Oracle adapter now supports schema parsing.
|
431
|
+
|
432
|
+
* When using Model.db=, all current dataset options are copied to
|
433
|
+
a new dataset created with the new db.
|
434
|
+
|
435
|
+
* Model::Errors#count was refactored to improve performance.
|
436
|
+
|
437
|
+
* Most exception classes that were located under Sequel::Error are
|
438
|
+
now located directly under Sequel. The old names are not
|
439
|
+
deprecated (unless mentioned above), but their use is now
|
440
|
+
discouraged. The exceptions have the same name except that
|
441
|
+
Sequel::Error::PoolTimeoutError changed to Sequel::PoolTimeout.
|
442
|
+
|
443
|
+
* Dataset#where now always affects the WHERE clause. Before, it
|
444
|
+
was just an alias of filter, so it modified the HAVING clause
|
445
|
+
if the dataset already had a HAVING clause.
|
446
|
+
|
447
|
+
* The optimization of Model.[] introduced in 2.11.0 broke on
|
448
|
+
databases that didn't support LIMIT. The optimization now works
|
449
|
+
on those databases.
|
450
|
+
|
451
|
+
* All of the the RDoc documentation was reviewed and many updates
|
452
|
+
were made, resulting in significantly improved documentation
|
453
|
+
quality.
|
454
|
+
|
455
|
+
* Model.def_dataset_method now works when the model doesn't have an
|
456
|
+
associated dataset, as it will add the method to a dataset
|
457
|
+
given to set_dataset in the future.
|
458
|
+
|
459
|
+
* Database#get and #select now take a block that is passed to
|
460
|
+
the dataset they create.
|
461
|
+
|
462
|
+
* You can disable the use of INSERT RETURNING in the shared
|
463
|
+
PostgreSQL adapter using disable_insert_returning. This is mostly
|
464
|
+
useful if you are inserting a large number of records.
|
465
|
+
|
466
|
+
* A bug relating to aliasing columns in the JDBC adapter has been
|
467
|
+
fixed.
|
468
|
+
|
469
|
+
* Sequel can now create and drop schema-qualified views.
|
470
|
+
|
471
|
+
* Performance of Dataset#destroy for model datasets was improved.
|
472
|
+
|
473
|
+
* The specs now run on Rspec 1.2.
|
474
|
+
|
475
|
+
* Internal dependence on the methods that Sequel adds to core
|
476
|
+
classes has been eliminated, any internal use of methods that
|
477
|
+
Sequel adds to the core classes is now considered a bug.
|
478
|
+
|
479
|
+
* A possible bug where Database#rename_table would not remove a
|
480
|
+
cached schema entry has been fixed.
|
481
|
+
|
482
|
+
* The Oracle and MySQL adapters now raise an error as soon as you
|
483
|
+
call distinct on a dataset, instead of waiting until the SQL is
|
484
|
+
generated.
|
485
|
+
|
486
|
+
Backwards Compatibilty
|
487
|
+
----------------------
|
488
|
+
|
489
|
+
* Saving a newly inserted record in an after_create or after_save
|
490
|
+
hook is no longer broken. It broke in 2.10 as a side effect of
|
491
|
+
allowing the hook to check whether or not the record was a new
|
492
|
+
record. The code has been changed so that a @was_new instance
|
493
|
+
variable will be defined to true if the record was just created.
|
494
|
+
|
495
|
+
Similarly, instead of not modifying changed_columns until after
|
496
|
+
the after hooks run, a @columns_updated instance variable will
|
497
|
+
be available in the after hooks that is a hash of exactly what
|
498
|
+
attribute keys and values were used in the update.
|
499
|
+
|
500
|
+
These changes break compatibility with 2.11.0 and 2.10.0, but
|
501
|
+
restore compatibility with 2.9.0 and previous versions.
|
502
|
+
|
503
|
+
* PostgreSQL no longer uses savepoints for nested transactions by
|
504
|
+
default. If you want to use a savepoint, you have to pass the
|
505
|
+
:savepoint option to the transaction method. Using savepoints
|
506
|
+
by default broke expectations when a method raised Rollback to
|
507
|
+
rollback the transaction, and it only rolled back to the last
|
508
|
+
savepoint.
|
509
|
+
|
510
|
+
* The anonymous model classes created by Sequel::Model() are now
|
511
|
+
stored in Model::ANONYMOUS_MODEL_CLASSES instead of the @models
|
512
|
+
class instance variable of the main module.
|
513
|
+
|
514
|
+
* The mappings of adapter schemes to classes are now stored in
|
515
|
+
Sequel::ADAPTER_MAP instead of the Database @@adapters class
|
516
|
+
variable.
|
517
|
+
|
518
|
+
* Model instances no longer contain a reference to their class's
|
519
|
+
@db_schema.
|
520
|
+
|
521
|
+
* Database schema sql methods (e.g. alter_table_sql) are now private.
|
522
|
+
|
523
|
+
* Database#[] no longer accepts a block. It's not possible to call
|
524
|
+
it with a block in general usage, anyway.
|
525
|
+
|
526
|
+
* The Sequel::Schema::SQL module no longer exists, the methods it
|
527
|
+
included were placed directly in the Sequel::Database class.
|
528
|
+
|
529
|
+
* The Sequel::SQL::SpecificExpression class has been removed,
|
530
|
+
subclasses now inherit from Sequel::SQL::Expression.
|
531
|
+
|
532
|
+
* Sequel now requires its own files with an absolute path.
|
533
|
+
|
534
|
+
* The file hierarchy of the sequel library changed significantly.
|