sequel 2.11.0 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. data/CHANGELOG +168 -0
  2. data/README.rdoc +77 -95
  3. data/Rakefile +100 -80
  4. data/bin/sequel +2 -1
  5. data/doc/advanced_associations.rdoc +23 -32
  6. data/doc/cheat_sheet.rdoc +23 -40
  7. data/doc/dataset_filtering.rdoc +6 -6
  8. data/doc/prepared_statements.rdoc +22 -22
  9. data/doc/release_notes/2.12.0.txt +534 -0
  10. data/doc/schema.rdoc +3 -1
  11. data/doc/sharding.rdoc +8 -8
  12. data/doc/virtual_rows.rdoc +65 -0
  13. data/lib/sequel.rb +1 -1
  14. data/lib/{sequel_core → sequel}/adapters/ado.rb +3 -3
  15. data/lib/{sequel_core → sequel}/adapters/db2.rb +0 -0
  16. data/lib/{sequel_core → sequel}/adapters/dbi.rb +1 -1
  17. data/lib/{sequel_core → sequel}/adapters/do.rb +9 -5
  18. data/lib/{sequel_core → sequel}/adapters/do/mysql.rb +1 -1
  19. data/lib/{sequel_core → sequel}/adapters/do/postgres.rb +1 -1
  20. data/lib/{sequel_core → sequel}/adapters/do/sqlite.rb +1 -1
  21. data/lib/{sequel_core → sequel}/adapters/firebird.rb +84 -80
  22. data/lib/{sequel_core → sequel}/adapters/informix.rb +1 -1
  23. data/lib/{sequel_core → sequel}/adapters/jdbc.rb +21 -14
  24. data/lib/{sequel_core → sequel}/adapters/jdbc/h2.rb +14 -13
  25. data/lib/{sequel_core → sequel}/adapters/jdbc/mysql.rb +1 -1
  26. data/lib/{sequel_core → sequel}/adapters/jdbc/oracle.rb +1 -1
  27. data/lib/{sequel_core → sequel}/adapters/jdbc/postgresql.rb +1 -1
  28. data/lib/{sequel_core → sequel}/adapters/jdbc/sqlite.rb +1 -1
  29. data/lib/{sequel_core → sequel}/adapters/mysql.rb +60 -39
  30. data/lib/{sequel_core → sequel}/adapters/odbc.rb +8 -4
  31. data/lib/{sequel_core → sequel}/adapters/openbase.rb +0 -0
  32. data/lib/{sequel_core → sequel}/adapters/oracle.rb +38 -7
  33. data/lib/{sequel_core → sequel}/adapters/postgres.rb +24 -24
  34. data/lib/{sequel_core → sequel}/adapters/shared/mssql.rb +5 -5
  35. data/lib/{sequel_core → sequel}/adapters/shared/mysql.rb +126 -71
  36. data/lib/{sequel_core → sequel}/adapters/shared/oracle.rb +7 -10
  37. data/lib/{sequel_core → sequel}/adapters/shared/postgres.rb +159 -125
  38. data/lib/{sequel_core → sequel}/adapters/shared/progress.rb +1 -2
  39. data/lib/{sequel_core → sequel}/adapters/shared/sqlite.rb +72 -67
  40. data/lib/{sequel_core → sequel}/adapters/sqlite.rb +11 -7
  41. data/lib/{sequel_core → sequel}/adapters/utils/date_format.rb +0 -0
  42. data/lib/{sequel_core → sequel}/adapters/utils/stored_procedures.rb +0 -0
  43. data/lib/{sequel_core → sequel}/adapters/utils/unsupported.rb +19 -0
  44. data/lib/{sequel_core → sequel}/connection_pool.rb +7 -5
  45. data/lib/sequel/core.rb +221 -0
  46. data/lib/{sequel_core → sequel}/core_sql.rb +91 -49
  47. data/lib/{sequel_core → sequel}/database.rb +264 -149
  48. data/lib/{sequel_core/schema/generator.rb → sequel/database/schema_generator.rb} +6 -2
  49. data/lib/{sequel_core/database/schema.rb → sequel/database/schema_methods.rb} +12 -12
  50. data/lib/sequel/database/schema_sql.rb +224 -0
  51. data/lib/{sequel_core → sequel}/dataset.rb +78 -236
  52. data/lib/{sequel_core → sequel}/dataset/convenience.rb +99 -61
  53. data/lib/{sequel_core/object_graph.rb → sequel/dataset/graph.rb} +16 -14
  54. data/lib/{sequel_core → sequel}/dataset/prepared_statements.rb +1 -1
  55. data/lib/{sequel_core → sequel}/dataset/sql.rb +150 -99
  56. data/lib/sequel/deprecated.rb +593 -0
  57. data/lib/sequel/deprecated_migration.rb +91 -0
  58. data/lib/sequel/exceptions.rb +48 -0
  59. data/lib/sequel/extensions/blank.rb +42 -0
  60. data/lib/{sequel_model → sequel/extensions}/inflector.rb +8 -1
  61. data/lib/{sequel_core → sequel/extensions}/migration.rb +1 -1
  62. data/lib/{sequel_core/dataset → sequel/extensions}/pagination.rb +0 -0
  63. data/lib/{sequel_core → sequel/extensions}/pretty_table.rb +7 -0
  64. data/lib/{sequel_core/dataset → sequel/extensions}/query.rb +7 -0
  65. data/lib/sequel/extensions/string_date_time.rb +47 -0
  66. data/lib/sequel/metaprogramming.rb +43 -0
  67. data/lib/sequel/model.rb +110 -0
  68. data/lib/sequel/model/associations.rb +1300 -0
  69. data/lib/sequel/model/base.rb +937 -0
  70. data/lib/sequel/model/deprecated.rb +204 -0
  71. data/lib/sequel/model/deprecated_hooks.rb +103 -0
  72. data/lib/sequel/model/deprecated_inflector.rb +335 -0
  73. data/lib/sequel/model/deprecated_validations.rb +388 -0
  74. data/lib/sequel/model/errors.rb +39 -0
  75. data/lib/{sequel_model → sequel/model}/exceptions.rb +4 -4
  76. data/lib/sequel/model/inflections.rb +208 -0
  77. data/lib/sequel/model/plugins.rb +76 -0
  78. data/lib/sequel/plugins/caching.rb +122 -0
  79. data/lib/sequel/plugins/hook_class_methods.rb +122 -0
  80. data/lib/sequel/plugins/schema.rb +53 -0
  81. data/lib/sequel/plugins/serialization.rb +117 -0
  82. data/lib/sequel/plugins/single_table_inheritance.rb +63 -0
  83. data/lib/sequel/plugins/validation_class_methods.rb +384 -0
  84. data/lib/sequel/plugins/validation_helpers.rb +150 -0
  85. data/lib/{sequel_core → sequel}/sql.rb +125 -190
  86. data/lib/{sequel_core → sequel}/version.rb +2 -1
  87. data/lib/sequel_core.rb +1 -172
  88. data/lib/sequel_model.rb +1 -91
  89. data/spec/adapters/firebird_spec.rb +5 -5
  90. data/spec/adapters/informix_spec.rb +1 -1
  91. data/spec/adapters/mysql_spec.rb +128 -42
  92. data/spec/adapters/oracle_spec.rb +47 -19
  93. data/spec/adapters/postgres_spec.rb +64 -52
  94. data/spec/adapters/spec_helper.rb +1 -1
  95. data/spec/adapters/sqlite_spec.rb +12 -17
  96. data/spec/{sequel_core → core}/connection_pool_spec.rb +10 -10
  97. data/spec/{sequel_core → core}/core_ext_spec.rb +19 -19
  98. data/spec/{sequel_core → core}/core_sql_spec.rb +68 -71
  99. data/spec/{sequel_core → core}/database_spec.rb +135 -99
  100. data/spec/{sequel_core → core}/dataset_spec.rb +398 -242
  101. data/spec/{sequel_core → core}/expression_filters_spec.rb +13 -13
  102. data/spec/core/migration_spec.rb +263 -0
  103. data/spec/{sequel_core → core}/object_graph_spec.rb +10 -10
  104. data/spec/{sequel_core → core}/pretty_table_spec.rb +2 -2
  105. data/spec/{sequel_core → core}/schema_generator_spec.rb +0 -0
  106. data/spec/{sequel_core → core}/schema_spec.rb +8 -10
  107. data/spec/{sequel_core → core}/spec_helper.rb +29 -2
  108. data/spec/{sequel_core → core}/version_spec.rb +0 -0
  109. data/spec/extensions/blank_spec.rb +67 -0
  110. data/spec/extensions/caching_spec.rb +201 -0
  111. data/spec/{sequel_model/hooks_spec.rb → extensions/hook_class_methods_spec.rb} +8 -23
  112. data/spec/{sequel_model → extensions}/inflector_spec.rb +3 -0
  113. data/spec/{sequel_core → extensions}/migration_spec.rb +4 -4
  114. data/spec/extensions/pagination_spec.rb +99 -0
  115. data/spec/extensions/pretty_table_spec.rb +91 -0
  116. data/spec/extensions/query_spec.rb +85 -0
  117. data/spec/{sequel_model → extensions}/schema_spec.rb +22 -1
  118. data/spec/extensions/serialization_spec.rb +109 -0
  119. data/spec/extensions/single_table_inheritance_spec.rb +53 -0
  120. data/spec/{sequel_model → extensions}/spec_helper.rb +13 -4
  121. data/spec/extensions/string_date_time_spec.rb +93 -0
  122. data/spec/{sequel_model/validations_spec.rb → extensions/validation_class_methods_spec.rb} +15 -103
  123. data/spec/extensions/validation_helpers_spec.rb +291 -0
  124. data/spec/integration/dataset_test.rb +31 -0
  125. data/spec/integration/eager_loader_test.rb +17 -30
  126. data/spec/integration/schema_test.rb +8 -5
  127. data/spec/integration/spec_helper.rb +17 -0
  128. data/spec/integration/transaction_test.rb +68 -0
  129. data/spec/{sequel_model → model}/association_reflection_spec.rb +0 -0
  130. data/spec/{sequel_model → model}/associations_spec.rb +23 -10
  131. data/spec/{sequel_model → model}/base_spec.rb +29 -20
  132. data/spec/{sequel_model → model}/caching_spec.rb +16 -14
  133. data/spec/{sequel_model → model}/dataset_methods_spec.rb +0 -0
  134. data/spec/{sequel_model → model}/eager_loading_spec.rb +8 -8
  135. data/spec/model/hooks_spec.rb +472 -0
  136. data/spec/model/inflector_spec.rb +126 -0
  137. data/spec/{sequel_model → model}/model_spec.rb +25 -20
  138. data/spec/model/plugins_spec.rb +142 -0
  139. data/spec/{sequel_model → model}/record_spec.rb +121 -62
  140. data/spec/model/schema_spec.rb +92 -0
  141. data/spec/model/spec_helper.rb +124 -0
  142. data/spec/model/validations_spec.rb +1080 -0
  143. metadata +136 -107
  144. data/lib/sequel_core/core_ext.rb +0 -217
  145. data/lib/sequel_core/dataset/callback.rb +0 -13
  146. data/lib/sequel_core/dataset/schema.rb +0 -15
  147. data/lib/sequel_core/deprecated.rb +0 -26
  148. data/lib/sequel_core/exceptions.rb +0 -44
  149. data/lib/sequel_core/schema.rb +0 -2
  150. data/lib/sequel_core/schema/sql.rb +0 -325
  151. data/lib/sequel_model/association_reflection.rb +0 -267
  152. data/lib/sequel_model/associations.rb +0 -499
  153. data/lib/sequel_model/base.rb +0 -539
  154. data/lib/sequel_model/caching.rb +0 -82
  155. data/lib/sequel_model/dataset_methods.rb +0 -26
  156. data/lib/sequel_model/eager_loading.rb +0 -370
  157. data/lib/sequel_model/hooks.rb +0 -101
  158. data/lib/sequel_model/plugins.rb +0 -62
  159. data/lib/sequel_model/record.rb +0 -568
  160. data/lib/sequel_model/schema.rb +0 -49
  161. data/lib/sequel_model/validations.rb +0 -429
  162. data/spec/sequel_model/plugins_spec.rb +0 -80
@@ -4,7 +4,7 @@ Sequel offers unparalleled flexibility when it comes to filtering records. You c
4
4
 
5
5
  == Filtering using a custom filter string
6
6
 
7
- If you do not wish to lose control over your SQL WHERE clauses, you can just supply it to the dataset's #filter method:
7
+ If you wish to write your SQL by hand, you can just supply it to the dataset's #filter method:
8
8
 
9
9
  items.filter('x < 10').sql
10
10
  #=> "SELECT * FROM items WHERE x < 10"
@@ -52,12 +52,12 @@ Ranges (both inclusive and exclusive) can also be used:
52
52
 
53
53
  == Filtering using expressions
54
54
 
55
- Sequel allows you to use ruby expressions directly in the call to filter, without using a block:
55
+ Sequel allows you to use ruby expressions directly in the call to filter:
56
56
 
57
57
  items.filter(:price * 2 < 50).sql
58
58
  #=> "SELECT * FROM items WHERE ((price * 2) < 50)
59
59
 
60
- This works for the standard inequality and arithmetic operators:
60
+ This works for the standard inequality and arithmetic operators (though you can't use the inequality operators directly on a symbol in ruby 1.9):
61
61
 
62
62
  items.filter(:price + 100 < 200).sql
63
63
  #=> "SELECT * FROM items WHERE ((price + 100) < 200)
@@ -99,7 +99,7 @@ You can use the negation operator (~) in most cases:
99
99
  items.filter(~{:category => 'ruby'}).sql
100
100
  #=> "SELECT * FROM items WHERE (category != 'ruby')"
101
101
 
102
- items.filter {~:active}.sql
102
+ items.filter{~:active}.sql
103
103
  #=> "SELECT * FROM items WHERE NOT active"
104
104
 
105
105
  items.filter(~(:price / 100 >= 200)).sql
@@ -151,8 +151,8 @@ Array#sql_string_join also takes a join argument:
151
151
 
152
152
  One of the best features of Sequel is the ability to use datasets as sub-queries. Sub-queries can be very useful for filtering records, and many times provide a simpler alternative to table joins. Sub-queries can be used in all forms of filters:
153
153
 
154
- refs = consumer_refs.filter(:logged_in => true).select(:consumer_id)
154
+ refs = consumer_refs.filter(:logged_in).select(:consumer_id)
155
155
  consumers.filter(:id => refs).sql
156
- #=> "SELECT * FROM consumers WHERE (id IN (SELECT consumer_id FROM consumer_refs WHERE (logged_in = 't')))"
156
+ #=> "SELECT * FROM consumers WHERE (id IN (SELECT consumer_id FROM consumer_refs WHERE logged_in))"
157
157
 
158
158
  Note that if you compare against a sub-query, you must select a single column in the sub-query.
@@ -1,17 +1,17 @@
1
1
  = Prepared Statements and Bound Variables
2
2
 
3
- Starting with version 2.4.0, Sequel has support for prepared statements and
4
- bound variables. No matter which database you are using, the Sequel prepared
5
- statement/bound variable API remains exactly the same. There is native support
6
- for prepared statements/bound variables on the following databases:
3
+ Sequel has support for prepared statements and bound variables. No matter which
4
+ database you are using, the Sequel prepared statement/bound variable API remains
5
+ the same. There is native support for prepared statements/bound variables on
6
+ the following databases:
7
7
 
8
8
  * PostgreSQL (using the pg driver, requires type specifiers)
9
9
  * MySQL (prepared statements only, as the ruby mysql driver doesn't support
10
10
  bound variables)
11
11
  * SQLite (a new native prepared statement is used for each call, though)
12
- * JDBC (using the postgresql, mysql, or sqlite databases, and possibly others)
12
+ * JDBC
13
13
 
14
- Support on other databases is emulated via the usual string interpolation.
14
+ Support on other databases is emulated via string interpolation.
15
15
 
16
16
  == Placeholders
17
17
 
@@ -22,51 +22,51 @@ significantly for placeholders (e.g. :name, $1, ?). Sequel abstracts all of
22
22
  that and allows you to specify placeholders by using the :$name format for
23
23
  placeholders, e.g.:
24
24
 
25
- ds = DB[:items].filter(:name=>:$name)
25
+ ds = DB[:items].filter(:name=>:$n)
26
26
 
27
27
  == Bound Variables
28
28
 
29
29
  Using bound variables for this query is simple:
30
30
 
31
- ds.call(:select, :name=>'Jim')
31
+ ds.call(:select, :n=>'Jim')
32
32
 
33
33
  This will do the equivalent of selecting records that have the name 'Jim'. It
34
34
  returns all records, and can take a block that is passed to Dataset#all.
35
35
 
36
36
  Deleting or returning the first record works similarly:
37
37
 
38
- ds.call(:first, :name=>'Jim') # First record with name 'Jim'
39
- ds.call(:delete, :name=>'Jim') # Delete records with name 'Jim'
38
+ ds.call(:first, :n=>'Jim') # First record with name 'Jim'
39
+ ds.call(:delete, :n=>'Jim') # Delete records with name 'Jim'
40
40
 
41
41
  For inserting/updating records, you should also specify a value hash, which
42
42
  may itself contain placeholders:
43
43
 
44
44
  # Insert record with 'Jim', note that the previous filter is ignored
45
- ds.call(:insert, {:name=>'Jim'}, :name=>:$name)
45
+ ds.call(:insert, {:n=>'Jim'}, :name=>:$n)
46
46
  # Change name to 'Bob' for all records with name of 'Jim'
47
- ds.call(:update, {:name=>'Jim', :new_name=>'Bob'}, :name=>$:new_name)
47
+ ds.call(:update, {:n=>'Jim', :new_n=>'Bob'}, :name=>$:new_n)
48
48
 
49
49
  == Prepared Statements
50
50
 
51
51
  Prepared statement support is similar to bound variable support, but you
52
52
  use Dataset#prepare with a name, and Dataset#call later with the values:
53
53
 
54
- ds = DB[:items].filter(:name=>:$name)
54
+ ds = DB[:items].filter(:name=>:$n)
55
55
  ps = ds.prepare(:select, :select_by_name)
56
- ps.call(:name=>'Jim')
57
- DB.call(:select_by_name, :name=>'Jim') # same as above
56
+ ps.call(:n=>'Jim')
57
+ DB.call(:select_by_name, :n=>'Jim') # same as above
58
58
 
59
59
  The Dataset#prepare method returns a prepared statement, and also stores a
60
60
  copy of the prepared statement in the database for later use. For insert
61
61
  and update queries, the hash to insert/update is passed to prepare:
62
62
 
63
- ps1 = DB[:items].prepare(:insert, :insert_with_name, :name=>:$name)
64
- ps1.call(:name=>'Jim')
65
- DB.call(:insert_with_name, :name=>'Jim') # same as above
66
- ds = DB[:items].filter(:name=>:$name)
67
- ps2 = ds.prepare(:update, :update_name, :name=>:$new_name)
68
- ps2.call(:name=>'Jim', :new_name=>'Bob')
69
- DB.call(:update_name, :name=>'Jim', :new_name=>'Bob') # same as above
63
+ ps1 = DB[:items].prepare(:insert, :insert_with_name, :name=>:$n)
64
+ ps1.call(:n=>'Jim')
65
+ DB.call(:insert_with_name, :n=>'Jim') # same as above
66
+ ds = DB[:items].filter(:name=>:$n)
67
+ ps2 = ds.prepare(:update, :update_name, :name=>:$new_n)
68
+ ps2.call(:n=>'Jim', :new_n=>'Bob')
69
+ DB.call(:update_name, :n=>'Jim', :new_n=>'Bob') # same as above
70
70
 
71
71
  == Database support
72
72
 
@@ -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.