sequel 3.21.0 → 3.29.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 (200) hide show
  1. data/CHANGELOG +413 -3
  2. data/README.rdoc +20 -6
  3. data/Rakefile +23 -16
  4. data/bin/sequel +1 -5
  5. data/doc/association_basics.rdoc +210 -43
  6. data/doc/dataset_basics.rdoc +4 -4
  7. data/doc/mass_assignment.rdoc +54 -0
  8. data/doc/migration.rdoc +15 -538
  9. data/doc/model_hooks.rdoc +72 -27
  10. data/doc/opening_databases.rdoc +86 -50
  11. data/doc/prepared_statements.rdoc +40 -13
  12. data/doc/reflection.rdoc +8 -2
  13. data/doc/release_notes/3.22.0.txt +39 -0
  14. data/doc/release_notes/3.23.0.txt +172 -0
  15. data/doc/release_notes/3.24.0.txt +420 -0
  16. data/doc/release_notes/3.25.0.txt +88 -0
  17. data/doc/release_notes/3.26.0.txt +88 -0
  18. data/doc/release_notes/3.27.0.txt +82 -0
  19. data/doc/release_notes/3.28.0.txt +304 -0
  20. data/doc/release_notes/3.29.0.txt +459 -0
  21. data/doc/schema_modification.rdoc +547 -0
  22. data/doc/sharding.rdoc +7 -1
  23. data/doc/testing.rdoc +115 -0
  24. data/doc/transactions.rdoc +137 -0
  25. data/doc/virtual_rows.rdoc +2 -2
  26. data/lib/sequel/adapters/ado/mssql.rb +18 -6
  27. data/lib/sequel/adapters/ado.rb +40 -18
  28. data/lib/sequel/adapters/amalgalite.rb +15 -7
  29. data/lib/sequel/adapters/db2.rb +175 -86
  30. data/lib/sequel/adapters/dbi.rb +15 -15
  31. data/lib/sequel/adapters/do/mysql.rb +0 -5
  32. data/lib/sequel/adapters/do/postgres.rb +0 -5
  33. data/lib/sequel/adapters/do/sqlite.rb +0 -5
  34. data/lib/sequel/adapters/do.rb +17 -36
  35. data/lib/sequel/adapters/firebird.rb +27 -208
  36. data/lib/sequel/adapters/ibmdb.rb +448 -0
  37. data/lib/sequel/adapters/informix.rb +6 -23
  38. data/lib/sequel/adapters/jdbc/as400.rb +5 -31
  39. data/lib/sequel/adapters/jdbc/db2.rb +44 -0
  40. data/lib/sequel/adapters/jdbc/derby.rb +217 -0
  41. data/lib/sequel/adapters/jdbc/firebird.rb +29 -0
  42. data/lib/sequel/adapters/jdbc/h2.rb +26 -17
  43. data/lib/sequel/adapters/jdbc/hsqldb.rb +166 -0
  44. data/lib/sequel/adapters/jdbc/informix.rb +26 -0
  45. data/lib/sequel/adapters/jdbc/jtds.rb +29 -0
  46. data/lib/sequel/adapters/jdbc/mssql.rb +0 -32
  47. data/lib/sequel/adapters/jdbc/mysql.rb +9 -10
  48. data/lib/sequel/adapters/jdbc/oracle.rb +67 -25
  49. data/lib/sequel/adapters/jdbc/postgresql.rb +6 -11
  50. data/lib/sequel/adapters/jdbc/sqlite.rb +0 -5
  51. data/lib/sequel/adapters/jdbc/sqlserver.rb +41 -0
  52. data/lib/sequel/adapters/jdbc/transactions.rb +83 -0
  53. data/lib/sequel/adapters/jdbc.rb +107 -38
  54. data/lib/sequel/adapters/mock.rb +315 -0
  55. data/lib/sequel/adapters/mysql.rb +78 -182
  56. data/lib/sequel/adapters/mysql2.rb +24 -23
  57. data/lib/sequel/adapters/odbc/db2.rb +17 -0
  58. data/lib/sequel/adapters/odbc/mssql.rb +0 -5
  59. data/lib/sequel/adapters/odbc.rb +28 -9
  60. data/lib/sequel/adapters/openbase.rb +2 -4
  61. data/lib/sequel/adapters/oracle.rb +349 -51
  62. data/lib/sequel/adapters/postgres.rb +169 -21
  63. data/lib/sequel/adapters/shared/access.rb +21 -6
  64. data/lib/sequel/adapters/shared/db2.rb +288 -0
  65. data/lib/sequel/adapters/shared/firebird.rb +214 -0
  66. data/lib/sequel/adapters/shared/informix.rb +45 -0
  67. data/lib/sequel/adapters/shared/mssql.rb +108 -65
  68. data/lib/sequel/adapters/shared/mysql.rb +56 -13
  69. data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +149 -0
  70. data/lib/sequel/adapters/shared/oracle.rb +185 -34
  71. data/lib/sequel/adapters/shared/postgres.rb +107 -58
  72. data/lib/sequel/adapters/shared/progress.rb +0 -6
  73. data/lib/sequel/adapters/shared/sqlite.rb +168 -41
  74. data/lib/sequel/adapters/sqlite.rb +27 -18
  75. data/lib/sequel/adapters/swift/mysql.rb +9 -5
  76. data/lib/sequel/adapters/swift/postgres.rb +0 -5
  77. data/lib/sequel/adapters/swift/sqlite.rb +6 -4
  78. data/lib/sequel/adapters/swift.rb +5 -5
  79. data/lib/sequel/adapters/tinytds.rb +152 -17
  80. data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +63 -0
  81. data/lib/sequel/ast_transformer.rb +190 -0
  82. data/lib/sequel/connection_pool/threaded.rb +3 -2
  83. data/lib/sequel/connection_pool.rb +1 -1
  84. data/lib/sequel/core.rb +46 -5
  85. data/lib/sequel/database/connecting.rb +5 -6
  86. data/lib/sequel/database/dataset.rb +4 -4
  87. data/lib/sequel/database/dataset_defaults.rb +59 -1
  88. data/lib/sequel/database/logging.rb +1 -1
  89. data/lib/sequel/database/misc.rb +100 -19
  90. data/lib/sequel/database/query.rb +153 -58
  91. data/lib/sequel/database/schema_generator.rb +8 -5
  92. data/lib/sequel/database/schema_methods.rb +59 -29
  93. data/lib/sequel/dataset/actions.rb +194 -57
  94. data/lib/sequel/dataset/features.rb +81 -8
  95. data/lib/sequel/dataset/graph.rb +8 -7
  96. data/lib/sequel/dataset/misc.rb +50 -23
  97. data/lib/sequel/dataset/mutation.rb +5 -6
  98. data/lib/sequel/dataset/prepared_statements.rb +32 -15
  99. data/lib/sequel/dataset/query.rb +223 -42
  100. data/lib/sequel/dataset/sql.rb +58 -61
  101. data/lib/sequel/dataset.rb +8 -0
  102. data/lib/sequel/exceptions.rb +4 -0
  103. data/lib/sequel/extensions/columns_introspection.rb +61 -0
  104. data/lib/sequel/extensions/migration.rb +6 -4
  105. data/lib/sequel/extensions/named_timezones.rb +5 -0
  106. data/lib/sequel/extensions/thread_local_timezones.rb +1 -1
  107. data/lib/sequel/extensions/to_dot.rb +95 -83
  108. data/lib/sequel/model/associations.rb +997 -331
  109. data/lib/sequel/model/base.rb +386 -129
  110. data/lib/sequel/model/errors.rb +1 -1
  111. data/lib/sequel/model/exceptions.rb +5 -1
  112. data/lib/sequel/model.rb +15 -8
  113. data/lib/sequel/plugins/association_pks.rb +22 -4
  114. data/lib/sequel/plugins/class_table_inheritance.rb +4 -4
  115. data/lib/sequel/plugins/dataset_associations.rb +100 -0
  116. data/lib/sequel/plugins/defaults_setter.rb +58 -0
  117. data/lib/sequel/plugins/force_encoding.rb +6 -6
  118. data/lib/sequel/plugins/identity_map.rb +114 -7
  119. data/lib/sequel/plugins/many_through_many.rb +65 -7
  120. data/lib/sequel/plugins/prepared_statements.rb +151 -0
  121. data/lib/sequel/plugins/prepared_statements_associations.rb +84 -0
  122. data/lib/sequel/plugins/prepared_statements_safe.rb +82 -0
  123. data/lib/sequel/plugins/prepared_statements_with_pk.rb +59 -0
  124. data/lib/sequel/plugins/rcte_tree.rb +29 -15
  125. data/lib/sequel/plugins/serialization.rb +6 -1
  126. data/lib/sequel/plugins/serialization_modification_detection.rb +51 -0
  127. data/lib/sequel/plugins/sharding.rb +12 -25
  128. data/lib/sequel/plugins/single_table_inheritance.rb +3 -1
  129. data/lib/sequel/plugins/typecast_on_load.rb +9 -12
  130. data/lib/sequel/plugins/update_primary_key.rb +2 -2
  131. data/lib/sequel/plugins/xml_serializer.rb +3 -3
  132. data/lib/sequel/sql.rb +107 -51
  133. data/lib/sequel/timezones.rb +44 -35
  134. data/lib/sequel/version.rb +1 -1
  135. data/spec/adapters/db2_spec.rb +146 -0
  136. data/spec/adapters/mssql_spec.rb +65 -29
  137. data/spec/adapters/mysql_spec.rb +122 -123
  138. data/spec/adapters/oracle_spec.rb +48 -76
  139. data/spec/adapters/postgres_spec.rb +213 -61
  140. data/spec/adapters/spec_helper.rb +6 -5
  141. data/spec/adapters/sqlite_spec.rb +35 -21
  142. data/spec/core/connection_pool_spec.rb +71 -92
  143. data/spec/core/core_sql_spec.rb +20 -31
  144. data/spec/core/database_spec.rb +729 -508
  145. data/spec/core/dataset_spec.rb +980 -1044
  146. data/spec/core/expression_filters_spec.rb +159 -42
  147. data/spec/core/mock_adapter_spec.rb +378 -0
  148. data/spec/core/object_graph_spec.rb +48 -114
  149. data/spec/core/schema_generator_spec.rb +3 -3
  150. data/spec/core/schema_spec.rb +298 -38
  151. data/spec/core/spec_helper.rb +6 -48
  152. data/spec/extensions/association_pks_spec.rb +38 -0
  153. data/spec/extensions/class_table_inheritance_spec.rb +1 -1
  154. data/spec/extensions/columns_introspection_spec.rb +91 -0
  155. data/spec/extensions/dataset_associations_spec.rb +199 -0
  156. data/spec/extensions/defaults_setter_spec.rb +64 -0
  157. data/spec/extensions/identity_map_spec.rb +162 -0
  158. data/spec/extensions/instance_hooks_spec.rb +71 -0
  159. data/spec/extensions/many_through_many_spec.rb +195 -20
  160. data/spec/extensions/migration_spec.rb +17 -17
  161. data/spec/extensions/named_timezones_spec.rb +22 -2
  162. data/spec/extensions/nested_attributes_spec.rb +4 -0
  163. data/spec/extensions/prepared_statements_associations_spec.rb +126 -0
  164. data/spec/extensions/prepared_statements_safe_spec.rb +79 -0
  165. data/spec/extensions/prepared_statements_spec.rb +72 -0
  166. data/spec/extensions/prepared_statements_with_pk_spec.rb +38 -0
  167. data/spec/extensions/schema_dumper_spec.rb +2 -2
  168. data/spec/extensions/schema_spec.rb +13 -21
  169. data/spec/extensions/serialization_modification_detection_spec.rb +37 -0
  170. data/spec/extensions/serialization_spec.rb +5 -8
  171. data/spec/extensions/single_table_inheritance_spec.rb +11 -0
  172. data/spec/extensions/spec_helper.rb +7 -1
  173. data/spec/extensions/thread_local_timezones_spec.rb +22 -2
  174. data/spec/extensions/to_dot_spec.rb +3 -5
  175. data/spec/extensions/typecast_on_load_spec.rb +1 -6
  176. data/spec/extensions/xml_serializer_spec.rb +16 -4
  177. data/spec/integration/associations_test.rb +522 -21
  178. data/spec/integration/database_test.rb +4 -2
  179. data/spec/integration/dataset_test.rb +375 -62
  180. data/spec/integration/eager_loader_test.rb +19 -21
  181. data/spec/integration/model_test.rb +80 -1
  182. data/spec/integration/plugin_test.rb +304 -116
  183. data/spec/integration/prepared_statement_test.rb +200 -120
  184. data/spec/integration/schema_test.rb +161 -30
  185. data/spec/integration/spec_helper.rb +39 -30
  186. data/spec/integration/timezone_test.rb +38 -12
  187. data/spec/integration/transaction_test.rb +172 -5
  188. data/spec/integration/type_test.rb +17 -3
  189. data/spec/model/association_reflection_spec.rb +174 -7
  190. data/spec/model/associations_spec.rb +849 -661
  191. data/spec/model/base_spec.rb +255 -95
  192. data/spec/model/dataset_methods_spec.rb +7 -27
  193. data/spec/model/eager_loading_spec.rb +640 -676
  194. data/spec/model/hooks_spec.rb +309 -67
  195. data/spec/model/model_spec.rb +207 -167
  196. data/spec/model/plugins_spec.rb +24 -13
  197. data/spec/model/record_spec.rb +321 -218
  198. data/spec/model/spec_helper.rb +13 -71
  199. data/spec/model/validations_spec.rb +11 -0
  200. metadata +95 -38
data/CHANGELOG CHANGED
@@ -1,3 +1,413 @@
1
+ === 3.29.0 (2011-11-01)
2
+
3
+ * Allow Model.dataset_module to take a Module instance (jeremyevans)
4
+
5
+ * Apply Model.[] optimization in more cases (jeremyevans)
6
+
7
+ * Fix Model.[] optimization when dataset uses identifier_input_method different than database (jeremyevans)
8
+
9
+ * Work around pragma bug on jdbc/sqlite when emulating alter table support (jeremyevans)
10
+
11
+ * Database#<< and Dataset#<< now return self so they can be safely chained (jeremyevans)
12
+
13
+ * Fully support using an aliased table name as the :join_table option for a many_to_many association (jeremyevans)
14
+
15
+ * Make like case sensitive on SQLite and Microsoft SQL Server (use ilike for case insensitive matching) (jeremyevans)
16
+
17
+ * Add Database#extend_datasets for the equivalent of extending of the Database object's datasets with a module (jeremyevans)
18
+
19
+ * Speed up Dataset #map, #to_hash, and related methods if an array of symbols is given (jeremyevans)
20
+
21
+ * Add Database#dataset_class for modifying the class used for datasets for a single Database object (jeremyevans)
22
+
23
+ * Plugins that override Model.load should be modified to override Model.call instead (jeremyevans)
24
+
25
+ * Speed up loading model objects from the database by up to 7-16% (jeremyevans)
26
+
27
+ * Create accessor methods for all columns in a model's table, even if the dataset doesn't select the columns (jeremyevans)
28
+
29
+ * Add mock adapter for better mocking of a database connection (jeremyevans)
30
+
31
+ * Have models pass their dataset instead of table name to Database#schema (jeremyevans)
32
+
33
+ * Allow Database#schema to take a dataset as the table argument, and use its identifier input/output methods (jeremyevans)
34
+
35
+ * Significant improvements to the db2 adapter (jeremyevans)
36
+
37
+ * Handle methods with names that can't be called directly in Model.def_dataset_method (jeremyevans)
38
+
39
+ * Add dataset_associations plugin for making dataset methods that return datasets of associated objects (jeremyevans)
40
+
41
+ * Don't allow Model.def_dataset_method to override private model methods (jeremyevans)
42
+
43
+ * Parsing primary key information from system tables in the shared MSSQL adapter (jeremyevans)
44
+
45
+ * Fix handling of composite primary keys when emulating alter table operations on SQLite (jeremyevans)
46
+
47
+ * Emulate add_constraint and drop_constraint alter table operations on SQLite (jeremyevans)
48
+
49
+ * Apply the correct pragmas when connecting to SQLite via the Amalgalite and Swift adapters (jeremyevans)
50
+
51
+ * Fix bound variable usage for some types (e.g. Date) when used outside of prepared statements on SQLite (jeremyevans)
52
+
53
+ * Work around SQLite column naming bug when using subselects (jeremyevans)
54
+
55
+ * Make prepared_statements plugin work with adapters that require type specifiers for variable placeholders, such as oracle (jeremyevans)
56
+
57
+ * Add savepoint support to the generic JDBC transaction support (used by 6 jdbc subadapters) (jeremyevans)
58
+
59
+ * Add native prepared statement support to the oracle adapter (jeremyevans)
60
+
61
+ * Support sharding correctly by default when using transactions in model saving/destroying (jeremyevans)
62
+
63
+ * Add Database#in_transaction? method for checking if you are already in a transaction (jeremyevans)
64
+
65
+ * Add after_commit, after_rollback, after_destroy_commit, and after_destroy_rollback hooks to Model objects (jeremyevans)
66
+
67
+ * Add after_commit and after_rollback hooks to Database objects (jeremyevans)
68
+
69
+ * Support savepoints inside prepared transactions on MySQL (jeremyevans)
70
+
71
+ * Support opening transactions to multiple shards of the same Database object in the same Thread (jeremyevans)
72
+
73
+ * Add Sequel.transaction for running transactions on multiple databases at the same time (jeremyevans)
74
+
75
+ * Support :rollback => :always option in Database#transaction to always rollback the transaction (jeremyevans)
76
+
77
+ * Support :rollback => :reraise option in Database#transaction to reraise the Sequel::Rollback exception (jeremyevans)
78
+
79
+ * Add support for connecting to Apache Derby databases using the jdbc adapter (jeremyevans)
80
+
81
+ * Add support for connecting to HSQLDB databases using the jdbc adapter (jeremyevans)
82
+
83
+ * Fix inserting all default values into a table on DB2 (jeremyevans)
84
+
85
+ * Add :qualify option to many_to_one associations for whether to qualify the primary key column with the associated table (jeremyevans)
86
+
87
+ * Modify rcte_tree plugin to use column aliases if recursive CTEs require them (jeremyevans)
88
+
89
+ * Add Dataset#recursive_cte_requires_column_aliases? method to check if you must provide an argument list for a recursive CTE (jeremyevans)
90
+
91
+ * Much better support for Oracle in both the oci8-based oracle adapter and the jdbc oracle subadapter (jeremyevans)
92
+
93
+ * Handle CTEs in subselects in more places on databases that don't natively support CTEs in subselects (jeremyevans)
94
+
95
+ * Change Dataset#to_hash to not call the row_proc if 2 arguments are given (jeremyevans)
96
+
97
+ * Change Dataset#map to not call the row_proc if an argument is given (jeremyevans)
98
+
99
+ * Make Dataset#select_map and #select_order_map return an array of single element arrays if given an array with a single symbol (jeremyevans)
100
+
101
+ * Make Dataset#columns work correctly on jdbc, odbc, ado, and dbi adapters when using an emulated offset on MSSQL and DB2 (jeremyevans)
102
+
103
+ * Add Database#listen and #notify to the postgres adapter, for LISTEN and NOTIFY support (jeremyevans)
104
+
105
+ * Emulate the bitwise compliment operator on h2 (jeremyevans)
106
+
107
+ * Fix improper handling of emulated bitwise operators with more than two arguments (jeremyevans)
108
+
109
+ * Allow convert_invalid_date_time to be set on a per-Database basis in the mysql adapter (jeremyevans)
110
+
111
+ * Allow convert_tinyint_to_bool to be set on a per-Database basis in the mysql and mysql2 adapters (jeremyevans)
112
+
113
+ * Allow per-Database override of the typeconversion procs on the mysql, sqlite, and ibmdb adapters (jeremyevans)
114
+
115
+ * Add Database#timezone accessor, for overriding Sequel.database_timezone per Database object (jeremyevans)
116
+
117
+ === 3.28.0 (2011-10-03)
118
+
119
+ * Add firebird jdbc subadapter (jeremyevans)
120
+
121
+ * Add SQLTime.create method for easier creation of SQLTime instances (jeremyevans)
122
+
123
+ * Make Dataset#with_pk use a qualified primary key, so it works correctly on joined datasets (jeremyevans)
124
+
125
+ * Support the :limit association option when using eager_graph (jeremyevans)
126
+
127
+ * Fix eager loading via eager_graph of one_to_one associations that match multiple associated objects and use order to pick the first one (jeremyevans)
128
+
129
+ * Make after_load association hooks apply when using eager_graph (jeremyevans)
130
+
131
+ * Make Dataset#with_sql treat a symbol as a first argument as a method name to call to get the SQL (jeremyevans)
132
+
133
+ * Make Dataset #delete, #insert, #update return array of plain hashes if block not given and Dataset#returning is used (jeremyevans)
134
+
135
+ * Allow Dataset #map, #to_hash, #select_map, #select_order_map, and #select_hash to take arrays of columns instead of single columns (jeremyevans)
136
+
137
+ * Make Dataset #delete, #insert, #update yield plain hashes to a block if Dataset#returning is used (jeremyevans)
138
+
139
+ * Add Dataset#returning for setting the columns to return in INSERT/UPDATE/DELETE statements, used by PostgreSQL 9.1 (jeremyevans)
140
+
141
+ * Support WITH clause in INSERT/UPDATE/DELETE on PostgreSQL 9.1+ (jeremyevans)
142
+
143
+ * Add Database#copy_table for PostgreSQL COPY support when using the postgres adapter with pg (jeremyevans)
144
+
145
+ * Support CREATE TABLE IF NOT EXISTS on PostgreSQL 9.1+ (jeremyevans)
146
+
147
+ * Add support for Sequel::Model.default_eager_limit_strategy to set the default :eager_limit_strategy for *_many associations (jeremyevans)
148
+
149
+ * Add support for an :eager_limit_strategy => :correlated_subquery value for limiting using correlated subqueries (jeremyevans)
150
+
151
+ * Allow use of a dataset that uses the emulated offset support on MSSQL and DB2 in an IN subquery by using a nested subquery (jeremyevans)
152
+
153
+ * Allow use of a dataset that uses LIMIT in an IN subquery on MySQL by using a nested subquery (jeremyevans)
154
+
155
+ * Work around serious ActiveSupport bug in Time.=== that breaks literalization of Time values (jeremyevans)
156
+
157
+ * Speed up SQL operator methods by using module_eval instead of define_method (jeremyevans)
158
+
159
+ * Support sql_(boolean,number,string) methods on ComplexExpressions, allowing you do to (x + 1).sql_string + 'a' for (x + 1) || 'a' (jeremyevans)
160
+
161
+ * Don't disallow SQL expression creation based on types, leave that to the database server (jeremyevans)
162
+
163
+ * Make :column [&|] 1 use an SQL bitwise [&|] expression instead of a logical (AND|OR) expression (jeremyevans)
164
+
165
+ * Make :column + 'a' use an SQL string concatenation expression instead of an addition expression (jeremyevans)
166
+
167
+ * Fix :time typecasting from Time to SQLTime for fractional seconds on ruby 1.9 (jeremyevans)
168
+
169
+ * Have Dataset#select_append check supports_select_all_and_column? and select all from all FROM and JOIN tables if no columns selected (jeremyevans)
170
+
171
+ * Add Dataset#supports_select_all_and_column? for checking if you can do SELECT *, column (jeremyevans)
172
+
173
+ * Add support for an :eager_limit_strategy => :window_function value for limiting using window functions (jeremyevans)
174
+
175
+ * Add support for an :eager_limit_strategy => :distinct_on value for one_to_one associations for using DISTINCT ON (jeremyevans)
176
+
177
+ * Add support for an :eager_limit_strategy association option, for manual control over how limiting is done (jeremyevans)
178
+
179
+ * Add Dataset#supports_ordered_distinct_on? for checking if the dataset can use distinct on while respecting order (jeremyevans)
180
+
181
+ * Add support for the association :limit option when eager loading via .eager for *_many associations (jeremyevans)
182
+
183
+ * Add db2 jdbc subadapter (jeremyevans)
184
+
185
+ * Fix the db2 adapter so it actually works (jeremyevans)
186
+
187
+ * Add ibmdb adapter for accessing DB2 (roylez, jeremyevans)
188
+
189
+ * Add much better support for DB2 databases (roylez, jeremyevans)
190
+
191
+ * Handle SQL::AliasedExpressions and SQL::JoinClauses in Dataset#select_all (jeremyevans)
192
+
193
+ * Speed up type translation slightly in mysql, postgres, and sqlite adapters (jeremyevans)
194
+
195
+ * Add Dataset#supports_cte_in_subqueries? for checking whether database supports WITH in subqueries (jeremyevans)
196
+
197
+ * Allow Model.set_dataset to accept Sequel::LiteralString arguments as table names (jeremyevans)
198
+
199
+ * Association :after_load hooks in lazy loading are now called after the associated objects have been cached (jeremyevans)
200
+
201
+ * Emulate handling of extract on MSSQL, using datepart (jeremyevans)
202
+
203
+ * Emulate handling of extract on SQLite, but you need to set Database#use_timestamp_timezones = false (jeremyevans)
204
+
205
+ * Abstract handling of ComplexExpressionMethods#extract so that it can work on databases that don't implement extract (jeremyevans)
206
+
207
+ * Emulate xor operator on SQLite (jeremyevans)
208
+
209
+ * Add Dataset#supports_where_true? for checking if the database supports WHERE true (or WHERE 1 if 1 is true) (jeremyevans)
210
+
211
+ * Fix eager loading via eager of one_to_one associations that match multiple associated objects and use order to pick the first one (jeremyevans)
212
+
213
+ === 3.27.0 (2011-09-01)
214
+
215
+ * Add support for native prepared statements to the tinytds adapter (jeremyevans)
216
+
217
+ * Add support for native prepared statements and stored procedures to the mysql2 adapter (jeremyevans)
218
+
219
+ * Support dropping primary key, foreign key, and unique constraints on MySQL via the drop_constraint :type option (jeremyevans)
220
+
221
+ * Add Sequel::SQLTime class for handling SQL time columns (jeremyevans)
222
+
223
+ * Typecast DateTime objects to Date for date columns (jeremyevans)
224
+
225
+ * When typecasting Date objects to timestamps, make the resulting objects always have no fractional date components (jeremyevans)
226
+
227
+ * Add Model.dataset_module for simplifying many def_dataset_method calls (jeremyevans)
228
+
229
+ * Make prepared_statements_safe plugin work on classes without datasets (jeremyevans)
230
+
231
+ * Make Dataset#hash work correctly when referencing SQL::Expression instances (jeremyevans)
232
+
233
+ * Handle allowed mass assignment methods correctly when including modules in classes or extending instances with modules (jeremyevans)
234
+
235
+ * Fix Model#hash to work correctly with composite primary keys and with no primary key (jeremyevans)
236
+
237
+ * Model#exists? now returns false without issuing a query for new model objects (jeremyevans)
238
+
239
+ === 3.26.0 (2011-08-01)
240
+
241
+ * Fix bug in default connection pool if a disconnect error is raised and the disconnection_proc also raises an error (jeremyevans)
242
+
243
+ * Disallow eager loading via eager of many_*_many associations with :eager_graph option (jeremyevans)
244
+
245
+ * Major speedup in dataset creation (jeremyevans)
246
+
247
+ * Replace internal implementation of eager_graph with much faster version (jeremyevans)
248
+
249
+ * Don't treat strings with leading zeros as octal format in the default typecasting (jeremyevans)
250
+
251
+ * Fix literalization of Date, Time, and DateTime values on Microsoft Access (jeremyevans)
252
+
253
+ * Fix handling of nil values with the pure-Java version of nokogiri in the xml_serializer plugin (jeremyevans)
254
+
255
+ * Make identity_map plugin work with standard eager loading of many_to_many and many_through_many associations (jeremyevans)
256
+
257
+ * Make create_table! only attempt to drop the table if it already exists (jeremyevans)
258
+
259
+ * Remove custom table_exists? implementations in the oracle and postgres adapters (jeremyevans)
260
+
261
+ * Handle another type of disconnection in the postgres adapter (jeremyevans)
262
+
263
+ * Handle disconnections in the ado adapter and do postgres subadapter (jeremyevans)
264
+
265
+ * Recognize disconnections when issuing BEGIN/ROLLBACK/COMMIT statements (jeremyevans) (#368)
266
+
267
+ === 3.25.0 (2011-07-01)
268
+
269
+ * Work with tiny_tds-0.4.5 in the tinytds adapter, older versions are no longer supported (jeremyevans)
270
+
271
+ * Make association_pks plugin typecast provided values to integer if the primary key column type is integer (jeremyevans)
272
+
273
+ * Model.set_dataset now accepts Identifier, QualifiedIdentifier, and AliasedExpression arguments (jeremyevans)
274
+
275
+ * Fix handling of nil values in bound variables and prepared statement and stored procedure arguments in the jdbc adapter (jeremyevans, wei)
276
+
277
+ * Allow treating Datasets as Expressions, e.g. DB[:table1].select(:column1) > DB[:table2].select(:column2) (jeremyevans)
278
+
279
+ * No longer use CASCADE by default when dropping tables on PostgreSQL (jeremyevans)
280
+
281
+ * Support :cascade option to #drop_table, #drop_view, #drop_column, and #drop_constraint for using CASCADE (jeremyevans)
282
+
283
+ * If validation error messages are LiteralStrings, don't add the column name to them in Errors#full_messages (jeremyevans)
284
+
285
+ * Fix bug loading plugins on 1.9 where ::ClassMethods, ::InstanceMethods, or ::DatasetMethods is defined (jeremyevans)
286
+
287
+ * Add Dataset#exclude_where and Dataset#exclude_having methods, so you can force use of having or where clause (jeremyevans)
288
+
289
+ * Allow Dataset#select_all to take table name arguments and select all columns from each given table (jeremyevans)
290
+
291
+ * Add Dataset#select_group method, for selecting and grouping on the same columns (jeremyevans)
292
+
293
+ * Allow Dataset#group and Dataset#group_and_count to accept a virtual row block (jeremyevans)
294
+
295
+ === 3.24.1 (2011-06-03)
296
+
297
+ * Ignore index creation errors if using create_table? with the IF NOT EXISTS syntax (jeremyevans) (#362)
298
+
299
+ === 3.24.0 (2011-06-01)
300
+
301
+ * Add prepared_statements_association plugin, for using prepared statements by default for regular association loading (jeremyevans)
302
+
303
+ * Add prepared_statements_safe plugin, for making prepared statement use with models more safe (jeremyevans)
304
+
305
+ * Add prepared_statements_with_pk plugin, for using prepared statements for dataset lookups by primary key (jeremyevans)
306
+
307
+ * Fix bug in emulated prepared statement support not supporting nil or false as bound values (jeremyevans)
308
+
309
+ * Add Dataset#unbind for unbinding values from a dataset, for use with creating prepared statements (jeremyevans)
310
+
311
+ * Add prepared_statements plugin for using prepared statements for updates, inserts, deletes, and lookups by primary key (jeremyevans)
312
+
313
+ * Make Dataset#[] for model datasets consider a single integer argument as a lookup by primary key (jeremyevans)
314
+
315
+ * Add Dataset#with_pk for model datasets, for finding first record with matching primary key value (jeremyevans)
316
+
317
+ * Add defaults_setter plugin for setting default values when initializing model instances (jeremyevans)
318
+
319
+ * Add around hooks (e.g. around_save) to Sequel::Model (jeremyevans)
320
+
321
+ * Add Model#initialize_set private method to ease extension writing (jeremyevans)
322
+
323
+ * Only typecast bit fields to booleans on MSSQL, the MySQL bit type is a bitfield, not a boolean (jeremyevans)
324
+
325
+ * Set SQL_AUTO_IS_NULL=0 by default when connecting to MySQL via the swift and jdbc adapters (jeremyevans)
326
+
327
+ * Fix bug in multiple column IN/NOT IN emulation when a model dataset is used (jeremyevans)
328
+
329
+ * Add support for filtering and excluding by association datasets (jeremyevans)
330
+
331
+ * Fix literalization of boolean values in filters on SQLite and MSSQL (jeremyevans)
332
+
333
+ * Add support for filtering and excluding by multiple associations (jeremyevans)
334
+
335
+ * Add support for inverting some SQL::Constant instances such as TRUE, FALSE, NULL, and NOTNULL (jeremyevans)
336
+
337
+ * Add support for excluding by associations to model datasets (jeremyevans)
338
+
339
+ * The Sequel::Postgres.use_iso_date_format setting now only affects future Database objects (jeremyevans)
340
+
341
+ * Add Sequel::Postgres::PG_NAMED_TYPES hash for extensions to register type conversions for non-standard types (jeremyevans, pvh)
342
+
343
+ * Make create_table? use IF NOT EXISTS instead of using SELECT to determine existence, if supported (jeremyevans)
344
+
345
+ * Fix bug in association_pks plugin when associated table has a different primary key column name (jfirebaugh)
346
+
347
+ * Fix limiting rows when connecting to DB2 (semmons99)
348
+
349
+ * Exclude columns from tables in the INFORMATION_SCHEMA when parsing table schema on JDBC (jeremyevans)
350
+
351
+ * Fix limiting rows when connecting to Microsoft Access (jeremyevans)
352
+
353
+ * Add Database#views for getting an array of symbols of view names for the database (jeremyevans, christian.michon)
354
+
355
+ * Make Datbase#tables no longer include view names on MySQL (jeremyevans)
356
+
357
+ * Convert Java CLOB objects to ruby strings when using the JDBC JTDS subadapter (christian.michon)
358
+
359
+ * If Thread#kill is called on a thread with an open transaction, roll the transaction back on ruby 1.8 and rubinius (jeremyevans)
360
+
361
+ * Split informix adapter into shared/specific parts, add JDBC informix subadapter (jeremyevans)
362
+
363
+ === 3.23.0 (2011-05-02)
364
+
365
+ * Migrate issue tracker from Google Code to GitHub Issues (jeremyevans)
366
+
367
+ * Add support for filtering by associations to model datasets (jeremyevans)
368
+
369
+ * Don't call insert_select when saving a model that doesn't select all columns of the table (jeremyevans)
370
+
371
+ * Fix bug when using :select=>[] option for a many_to_many association (jeremyevans)
372
+
373
+ * Add a columns_introspection extension that attempts to skip database queries by introspecting selected columns (jeremyevans)
374
+
375
+ * When combining old integer migrations and new timestamp migrations, make sure old integer migrations are all applied first (jeremyevans)
376
+
377
+ * Support dynamic callbacks to customize regular association loading at query time (jeremyevans)
378
+
379
+ * Support cascading of eager loading with dynamic callbacks for both eager and eager_graph (jeremyevans)
380
+
381
+ * Make the xml_serializer plugin handle namespaced models by using __ instead of / as a separator (jeremyevans)
382
+
383
+ * Allow the :eager_grapher association proc to accept a single hash instead of 3 arguments (jfirebaugh)
384
+
385
+ * Support dynamic callbacks to customize eager loading at query time (jfirebaugh, jeremyevans)
386
+
387
+ * Fix bug in the identity_map plugin for many_to_one associations when the association reflection hadn't been filled in yet (funny-falcon)
388
+
389
+ * Add serialization_modification_detection plugin for detecting changes in serialized columns (jeremyevans) (#333)
390
+
391
+ === 3.22.0 (2011-04-01)
392
+
393
+ * Add disconnect detection to tinytds adapter, though correct behavior may require an update to tiny_tds (cult_hero)
394
+
395
+ * Add Dataset/Database#mssql_unicode_strings accessor when connecting to MSSQL to control string literalization (semmons99, jeremyevans)
396
+
397
+ * Fix ODBC::Time instance handling in the odbc adapter (jeremyevans)
398
+
399
+ * Use Sequel.application_timezone when connecting in the oracle adapter to set the connection's session's timezone (jmthomas)
400
+
401
+ * In the ADO adapter, assume access to SQL Server if a :conn_string option is given that doesn't indicate Access/Jet (damir.si) (#332)
402
+
403
+ * Use the correct class when loading instances for descendents of model classes that use single table inheritance (jeremyevans)
404
+
405
+ * Support for COLLATE in column definitions (jfirebaugh)
406
+
407
+ * Don't use a schema when creating a temporary table (jeremyevans)
408
+
409
+ * Make migrator work correctly when a default_schema is set (jeremyevans) (#331)
410
+
1
411
  === 3.21.0 (2011-03-01)
2
412
 
3
413
  * Make symbol splitting (:table__column___alias) work correctly for identifiers that are not in the \w character class (authorNari)
@@ -2954,9 +3364,9 @@
2954
3364
 
2955
3365
  === 0.1.9.3 (2007-08-10)
2956
3366
 
2957
- * Added support for specifying field size in schema definitions (thanks Florian Aßmann.)
3367
+ * Added support for specifying field size in schema definitions (thanks Florian Assmann.)
2958
3368
 
2959
- * Added migration code based on work by Florian Aßmann.
3369
+ * Added migration code based on work by Florian Assmann.
2960
3370
 
2961
3371
  * Reintroduced metaid dependency. No need to keep a local copy of it.
2962
3372
 
@@ -3034,7 +3444,7 @@
3034
3444
 
3035
3445
  * Fixed Dataset#first to include a LIMIT clause for a single record.
3036
3446
 
3037
- * Small fix to Postgres driver to return a primary_key value for the inserted record if it is specified in the insertion values (thanks Florian Aßmann and Pedro Gutierrez).
3447
+ * Small fix to Postgres driver to return a primary_key value for the inserted record if it is specified in the insertion values (thanks Florian Assmann and Pedro Gutierrez).
3038
3448
 
3039
3449
  * Fixed Symbol#DESC to support qualified notation (thanks Pedro Gutierrez).
3040
3450
 
data/README.rdoc CHANGED
@@ -12,15 +12,15 @@ toolkit for Ruby.
12
12
  two-phase commit, transaction isolation, master/slave
13
13
  configurations, and database sharding.
14
14
  * Sequel currently has adapters for ADO, Amalgalite, DataObjects,
15
- DB2, DBI, Firebird, Informix, JDBC, MySQL, Mysql2, ODBC, OpenBase,
16
- Oracle, PostgreSQL, SQLite3, Swift, and TinyTDS.
15
+ DB2, DBI, Firebird, IBM_DB, Informix, JDBC, MySQL, Mysql2, ODBC,
16
+ OpenBase, Oracle, PostgreSQL, SQLite3, Swift, and TinyTDS.
17
17
 
18
18
  == Resources
19
19
 
20
20
  * {Website}[http://sequel.rubyforge.org]
21
21
  * {Blog}[http://sequel.heroku.com]
22
22
  * {Source code}[http://github.com/jeremyevans/sequel]
23
- * {Bug tracking}[http://code.google.com/p/ruby-sequel/issues/list]
23
+ * {Bug tracking}[http://github.com/jeremyevans/sequel/issues]
24
24
  * {Google group}[http://groups.google.com/group/sequel-talk]
25
25
  * {RDoc}[http://sequel.rubyforge.org/rdoc]
26
26
 
@@ -573,7 +573,7 @@ You can execute custom code when creating, updating, or deleting records by defi
573
573
 
574
574
  Note the use of +super+ if you define your own hook methods. Almost all <tt>Sequel::Model</tt> class and instance methods (not just hook methods) can be overridden safely, but you have to make sure to call +super+ when doing so, otherwise you risk breaking things.
575
575
 
576
- For the example above, you should probably use a database trigger if you can. Hooks can be used for data integrity, but they will only enforce that integrity when you are modifying the database through model instances. If you plan on allowing any other access to the database, it's best to use database triggers for data integrity.
576
+ For the example above, you should probably use a database trigger if you can. Hooks can be used for data integrity, but they will only enforce that integrity when you are modifying the database through model instances. If you plan on allowing any other access to the database, it's best to use database triggers and constraints for data integrity.
577
577
 
578
578
  === Deleting records
579
579
 
@@ -681,9 +681,23 @@ Associations can be eagerly loaded via +eager+ and the <tt>:eager</tt> associati
681
681
  # Loads all people, their posts, their posts' tags, replies to those posts,
682
682
  # the person for each reply, the tag for each reply, and all posts and
683
683
  # replies that have that tag. Uses a total of 8 queries.
684
- Person.eager(:posts=>{:replies=>[:person, {:tags=>{:posts, :replies}}]}).all
684
+ Person.eager(:posts=>{:replies=>[:person, {:tags=>[:posts, :replies]}]}).all
685
685
 
686
- In addition to using +eager+, you can also use +eager_graph+, which will use a single query to get the object and all associated objects. This may be necessary if you want to filter or order the result set based on columns in associated tables. It works with cascading as well, the syntax is exactly the same. Note that using eager_graph to eagerly load multiple *_to_many associations will cause the result set to be a cartesian product, so you should be very careful with your filters when using it in that case.
686
+ In addition to using +eager+, you can also use +eager_graph+, which will use a single query to get the object and all associated objects. This may be necessary if you want to filter or order the result set based on columns in associated tables. It works with cascading as well, the API is very similar. Note that using +eager_graph+ to eagerly load multiple <tt>*_to_many</tt> associations will cause the result set to be a cartesian product, so you should be very careful with your filters when using it in that case.
687
+
688
+ You can dynamically customize the eagerly loaded dataset by using using a proc. This proc is passed the dataset used for eager loading, and should return a modified copy of that dataset:
689
+
690
+ # Eagerly load only replies containing 'foo'
691
+ Post.eager(:replies=>proc{|ds| ds.filter(text.like('%foo%'))}).all
692
+
693
+ This also works when using +eager_graph+, in which case the proc is called with dataset to graph into the current dataset:
694
+
695
+ Post.eager_graph(:replies=>proc{|ds| ds.filter(text.like('%foo%'))}).all
696
+
697
+ You can dynamically customize eager loads for both +eager+ and +eager_graph+ while also cascading, by making the value a single entry hash with the proc as a key, and the cascaded associations as the value:
698
+
699
+ # Eagerly load only replies containing 'foo', and the person and tags for those replies
700
+ Post.eager(:replies=>{proc{|ds| ds.filter(text.like('%foo%'))}=>[:person, :tags]}).all
687
701
 
688
702
  === Extending the underlying dataset
689
703
 
data/Rakefile CHANGED
@@ -1,11 +1,5 @@
1
1
  require "rake"
2
2
  require "rake/clean"
3
- require "rake/gempackagetask"
4
- begin
5
- require "hanna/rdoctask"
6
- rescue LoadError
7
- require "rake/rdoctask"
8
- end
9
3
 
10
4
  NAME = 'sequel'
11
5
  VERS = lambda do
@@ -13,8 +7,6 @@ VERS = lambda do
13
7
  Sequel.version
14
8
  end
15
9
  CLEAN.include ["**/.*.sw?", "sequel-*.gem", ".config", "rdoc", "coverage", "www/public/*.html", "www/public/rdoc*", '**/*.rbc']
16
- RDOC_DEFAULT_OPTS = ["--quiet", "--line-numbers", "--inline-source", '--title', 'Sequel: The Database Toolkit for Ruby']
17
- RDOC_OPTS = RDOC_DEFAULT_OPTS + ['--main', 'README.rdoc']
18
10
 
19
11
  # Gem Packaging and Release
20
12
 
@@ -40,7 +32,20 @@ end
40
32
 
41
33
  ### RDoc
42
34
 
43
- Rake::RDocTask.new do |rdoc|
35
+ RDOC_DEFAULT_OPTS = ["--quiet", "--line-numbers", "--inline-source", '--title', 'Sequel: The Database Toolkit for Ruby']
36
+
37
+ rdoc_task_class = begin
38
+ require "rdoc/task"
39
+ RDOC_DEFAULT_OPTS.concat(['-f', 'hanna'])
40
+ RDoc::Task
41
+ rescue LoadError
42
+ require "rake/rdoctask"
43
+ Rake::RDocTask
44
+ end
45
+
46
+ RDOC_OPTS = RDOC_DEFAULT_OPTS + ['--main', 'README.rdoc']
47
+
48
+ rdoc_task_class.new do |rdoc|
44
49
  rdoc.rdoc_dir = "rdoc"
45
50
  rdoc.options += RDOC_OPTS
46
51
  rdoc.rdoc_files.add %w"README.rdoc CHANGELOG MIT-LICENSE lib/**/*.rb doc/*.rdoc doc/release_notes/*.txt"
@@ -50,25 +55,25 @@ end
50
55
 
51
56
  desc "Make local version of website"
52
57
  task :website do
53
- sh %{www/make_www.rb}
58
+ sh %{#{FileUtils::RUBY} www/make_www.rb}
54
59
  end
55
60
 
56
61
  desc "Make rdoc for website"
57
62
  task :website_rdoc=>[:website_rdoc_main, :website_rdoc_adapters, :website_rdoc_plugins]
58
63
 
59
- Rake::RDocTask.new(:website_rdoc_main) do |rdoc|
64
+ rdoc_task_class.new(:website_rdoc_main) do |rdoc|
60
65
  rdoc.rdoc_dir = "www/public/rdoc"
61
66
  rdoc.options += RDOC_OPTS
62
67
  rdoc.rdoc_files.add %w"README.rdoc CHANGELOG MIT-LICENSE lib/*.rb lib/sequel/*.rb lib/sequel/{connection_pool,dataset,database,model}/*.rb doc/*.rdoc doc/release_notes/*.txt lib/sequel/extensions/migration.rb"
63
68
  end
64
69
 
65
- Rake::RDocTask.new(:website_rdoc_adapters) do |rdoc|
70
+ rdoc_task_class.new(:website_rdoc_adapters) do |rdoc|
66
71
  rdoc.rdoc_dir = "www/public/rdoc-adapters"
67
72
  rdoc.options += RDOC_DEFAULT_OPTS + %w'--main Sequel'
68
73
  rdoc.rdoc_files.add %w"lib/sequel/adapters/**/*.rb"
69
74
  end
70
75
 
71
- Rake::RDocTask.new(:website_rdoc_plugins) do |rdoc|
76
+ rdoc_task_class.new(:website_rdoc_plugins) do |rdoc|
72
77
  rdoc.rdoc_dir = "www/public/rdoc-plugins"
73
78
  rdoc.options += RDOC_DEFAULT_OPTS + %w'--main Sequel'
74
79
  rdoc.rdoc_files.add %w"lib/sequel/{extensions,plugins}/**/*.rb"
@@ -92,11 +97,13 @@ begin
92
97
  require "spec/rake/spectask"
93
98
  spec_class = Spec::Rake::SpecTask
94
99
  spec_files_meth = :spec_files=
100
+ spec_opts_meth = :spec_opts=
95
101
  rescue LoadError
96
102
  # RSpec 2
97
103
  require "rspec/core/rake_task"
98
104
  spec_class = RSpec::Core::RakeTask
99
105
  spec_files_meth = :pattern=
106
+ spec_opts_meth = :rspec_opts=
100
107
  end
101
108
 
102
109
  spec = lambda do |name, files, d|
@@ -105,7 +112,7 @@ begin
105
112
  desc d
106
113
  spec_class.new(name) do |t|
107
114
  t.send spec_files_meth, files
108
- t.spec_opts = ENV['SEQUEL_SPEC_OPTS'].split if ENV['SEQUEL_SPEC_OPTS']
115
+ t.send spec_opts_meth, ENV['SEQUEL_SPEC_OPTS'].split if ENV['SEQUEL_SPEC_OPTS']
109
116
  end
110
117
  end
111
118
 
@@ -123,7 +130,7 @@ begin
123
130
  spec_with_cov.call("spec_plugin", Dir["spec/extensions/*_spec.rb"], "Run extension/plugin specs")
124
131
  spec_with_cov.call("spec_integration", Dir["spec/integration/*_test.rb"], "Run integration tests")
125
132
 
126
- %w'postgres sqlite mysql informix oracle firebird mssql'.each do |adapter|
133
+ %w'postgres sqlite mysql informix oracle firebird mssql db2'.each do |adapter|
127
134
  spec_with_cov.call("spec_#{adapter}", ["spec/adapters/#{adapter}_spec.rb"] + Dir["spec/integration/*_test.rb"], "Run #{adapter} specs")
128
135
  end
129
136
  rescue LoadError
@@ -154,5 +161,5 @@ end
154
161
 
155
162
  desc "Check syntax of all .rb files"
156
163
  task :check_syntax do
157
- Dir['**/*.rb'].each{|file| print `#{ENV['RUBY'] || :ruby} -c #{file} | fgrep -v "Syntax OK"`}
164
+ Dir['**/*.rb'].each{|file| print `#{FileUtils::RUBY} -c #{file} | fgrep -v "Syntax OK"`}
158
165
  end
data/bin/sequel CHANGED
@@ -112,11 +112,7 @@ end
112
112
 
113
113
  connect_proc = lambda do |database|
114
114
  db = if database.nil? || database.empty?
115
- db = Sequel::Database.new(:quote_identifiers=>false)
116
- def db.connect(*args); Object.new; end
117
- db.identifier_input_method = nil
118
- db.identifier_output_method = nil
119
- db
115
+ Sequel.connect('mock:///', db_opts)
120
116
  elsif File.exist?(database)
121
117
  require 'yaml'
122
118
  env ||= "development"