sequel 3.46.0 → 3.47.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +96 -0
  3. data/Rakefile +7 -1
  4. data/bin/sequel +6 -4
  5. data/doc/active_record.rdoc +1 -1
  6. data/doc/advanced_associations.rdoc +14 -35
  7. data/doc/association_basics.rdoc +66 -4
  8. data/doc/migration.rdoc +4 -0
  9. data/doc/opening_databases.rdoc +6 -0
  10. data/doc/postgresql.rdoc +302 -0
  11. data/doc/release_notes/3.47.0.txt +270 -0
  12. data/doc/security.rdoc +6 -0
  13. data/lib/sequel/adapters/ibmdb.rb +9 -9
  14. data/lib/sequel/adapters/jdbc.rb +22 -7
  15. data/lib/sequel/adapters/jdbc/postgresql.rb +7 -2
  16. data/lib/sequel/adapters/mock.rb +2 -0
  17. data/lib/sequel/adapters/postgres.rb +44 -13
  18. data/lib/sequel/adapters/shared/mssql.rb +1 -1
  19. data/lib/sequel/adapters/shared/mysql.rb +2 -2
  20. data/lib/sequel/adapters/shared/postgres.rb +94 -55
  21. data/lib/sequel/adapters/shared/sqlite.rb +3 -1
  22. data/lib/sequel/adapters/sqlite.rb +2 -2
  23. data/lib/sequel/adapters/utils/pg_types.rb +1 -14
  24. data/lib/sequel/adapters/utils/split_alter_table.rb +3 -3
  25. data/lib/sequel/connection_pool/threaded.rb +1 -1
  26. data/lib/sequel/core.rb +1 -1
  27. data/lib/sequel/database/connecting.rb +2 -2
  28. data/lib/sequel/database/features.rb +5 -0
  29. data/lib/sequel/database/misc.rb +47 -5
  30. data/lib/sequel/database/query.rb +2 -2
  31. data/lib/sequel/dataset/actions.rb +4 -2
  32. data/lib/sequel/dataset/misc.rb +1 -1
  33. data/lib/sequel/dataset/prepared_statements.rb +1 -1
  34. data/lib/sequel/dataset/query.rb +8 -6
  35. data/lib/sequel/dataset/sql.rb +8 -6
  36. data/lib/sequel/extensions/constraint_validations.rb +5 -2
  37. data/lib/sequel/extensions/migration.rb +10 -8
  38. data/lib/sequel/extensions/pagination.rb +3 -0
  39. data/lib/sequel/extensions/pg_array.rb +85 -25
  40. data/lib/sequel/extensions/pg_hstore.rb +8 -1
  41. data/lib/sequel/extensions/pg_hstore_ops.rb +4 -1
  42. data/lib/sequel/extensions/pg_inet.rb +16 -13
  43. data/lib/sequel/extensions/pg_interval.rb +6 -2
  44. data/lib/sequel/extensions/pg_json.rb +18 -11
  45. data/lib/sequel/extensions/pg_range.rb +17 -2
  46. data/lib/sequel/extensions/pg_range_ops.rb +7 -5
  47. data/lib/sequel/extensions/pg_row.rb +29 -12
  48. data/lib/sequel/extensions/pretty_table.rb +3 -0
  49. data/lib/sequel/extensions/query.rb +3 -0
  50. data/lib/sequel/extensions/schema_caching.rb +2 -0
  51. data/lib/sequel/extensions/schema_dumper.rb +3 -1
  52. data/lib/sequel/extensions/select_remove.rb +3 -0
  53. data/lib/sequel/model.rb +8 -2
  54. data/lib/sequel/model/associations.rb +39 -27
  55. data/lib/sequel/model/base.rb +99 -38
  56. data/lib/sequel/model/plugins.rb +25 -0
  57. data/lib/sequel/plugins/association_autoreloading.rb +27 -22
  58. data/lib/sequel/plugins/association_dependencies.rb +1 -7
  59. data/lib/sequel/plugins/auto_validations.rb +110 -0
  60. data/lib/sequel/plugins/boolean_readers.rb +1 -6
  61. data/lib/sequel/plugins/caching.rb +6 -13
  62. data/lib/sequel/plugins/class_table_inheritance.rb +1 -0
  63. data/lib/sequel/plugins/composition.rb +14 -7
  64. data/lib/sequel/plugins/constraint_validations.rb +2 -13
  65. data/lib/sequel/plugins/defaults_setter.rb +1 -6
  66. data/lib/sequel/plugins/dirty.rb +8 -0
  67. data/lib/sequel/plugins/error_splitter.rb +54 -0
  68. data/lib/sequel/plugins/force_encoding.rb +1 -5
  69. data/lib/sequel/plugins/hook_class_methods.rb +1 -6
  70. data/lib/sequel/plugins/input_transformer.rb +79 -0
  71. data/lib/sequel/plugins/instance_filters.rb +7 -1
  72. data/lib/sequel/plugins/instance_hooks.rb +7 -1
  73. data/lib/sequel/plugins/json_serializer.rb +5 -10
  74. data/lib/sequel/plugins/lazy_attributes.rb +20 -7
  75. data/lib/sequel/plugins/list.rb +1 -6
  76. data/lib/sequel/plugins/many_through_many.rb +1 -2
  77. data/lib/sequel/plugins/many_to_one_pk_lookup.rb +23 -39
  78. data/lib/sequel/plugins/optimistic_locking.rb +1 -5
  79. data/lib/sequel/plugins/pg_row.rb +4 -2
  80. data/lib/sequel/plugins/pg_typecast_on_load.rb +3 -7
  81. data/lib/sequel/plugins/prepared_statements.rb +1 -5
  82. data/lib/sequel/plugins/prepared_statements_safe.rb +2 -11
  83. data/lib/sequel/plugins/rcte_tree.rb +2 -2
  84. data/lib/sequel/plugins/serialization.rb +11 -13
  85. data/lib/sequel/plugins/serialization_modification_detection.rb +13 -1
  86. data/lib/sequel/plugins/single_table_inheritance.rb +4 -4
  87. data/lib/sequel/plugins/static_cache.rb +67 -19
  88. data/lib/sequel/plugins/string_stripper.rb +7 -27
  89. data/lib/sequel/plugins/subclasses.rb +3 -5
  90. data/lib/sequel/plugins/tactical_eager_loading.rb +2 -2
  91. data/lib/sequel/plugins/timestamps.rb +2 -7
  92. data/lib/sequel/plugins/touch.rb +5 -8
  93. data/lib/sequel/plugins/tree.rb +1 -6
  94. data/lib/sequel/plugins/typecast_on_load.rb +1 -5
  95. data/lib/sequel/plugins/update_primary_key.rb +26 -14
  96. data/lib/sequel/plugins/validation_class_methods.rb +31 -16
  97. data/lib/sequel/plugins/validation_helpers.rb +50 -26
  98. data/lib/sequel/plugins/xml_serializer.rb +3 -6
  99. data/lib/sequel/sql.rb +1 -1
  100. data/lib/sequel/version.rb +1 -1
  101. data/spec/adapters/postgres_spec.rb +131 -15
  102. data/spec/adapters/sqlite_spec.rb +1 -1
  103. data/spec/core/connection_pool_spec.rb +16 -17
  104. data/spec/core/database_spec.rb +111 -40
  105. data/spec/core/dataset_spec.rb +65 -74
  106. data/spec/core/expression_filters_spec.rb +6 -5
  107. data/spec/core/object_graph_spec.rb +0 -1
  108. data/spec/core/schema_spec.rb +23 -23
  109. data/spec/core/spec_helper.rb +5 -1
  110. data/spec/extensions/association_dependencies_spec.rb +1 -1
  111. data/spec/extensions/association_proxies_spec.rb +1 -1
  112. data/spec/extensions/auto_validations_spec.rb +90 -0
  113. data/spec/extensions/caching_spec.rb +6 -0
  114. data/spec/extensions/class_table_inheritance_spec.rb +8 -1
  115. data/spec/extensions/composition_spec.rb +12 -5
  116. data/spec/extensions/constraint_validations_spec.rb +4 -4
  117. data/spec/extensions/core_refinements_spec.rb +29 -79
  118. data/spec/extensions/dirty_spec.rb +14 -0
  119. data/spec/extensions/error_splitter_spec.rb +18 -0
  120. data/spec/extensions/identity_map_spec.rb +0 -1
  121. data/spec/extensions/input_transformer_spec.rb +54 -0
  122. data/spec/extensions/instance_filters_spec.rb +6 -0
  123. data/spec/extensions/instance_hooks_spec.rb +12 -1
  124. data/spec/extensions/json_serializer_spec.rb +0 -1
  125. data/spec/extensions/lazy_attributes_spec.rb +64 -55
  126. data/spec/extensions/looser_typecasting_spec.rb +1 -1
  127. data/spec/extensions/many_through_many_spec.rb +3 -4
  128. data/spec/extensions/many_to_one_pk_lookup_spec.rb +53 -15
  129. data/spec/extensions/migration_spec.rb +16 -0
  130. data/spec/extensions/null_dataset_spec.rb +1 -1
  131. data/spec/extensions/pg_array_spec.rb +48 -1
  132. data/spec/extensions/pg_hstore_ops_spec.rb +10 -2
  133. data/spec/extensions/pg_hstore_spec.rb +5 -0
  134. data/spec/extensions/pg_inet_spec.rb +5 -0
  135. data/spec/extensions/pg_interval_spec.rb +7 -3
  136. data/spec/extensions/pg_json_spec.rb +6 -1
  137. data/spec/extensions/pg_range_ops_spec.rb +4 -1
  138. data/spec/extensions/pg_range_spec.rb +5 -0
  139. data/spec/extensions/pg_row_plugin_spec.rb +13 -0
  140. data/spec/extensions/pg_row_spec.rb +28 -19
  141. data/spec/extensions/pg_typecast_on_load_spec.rb +6 -1
  142. data/spec/extensions/prepared_statements_associations_spec.rb +1 -1
  143. data/spec/extensions/query_literals_spec.rb +1 -1
  144. data/spec/extensions/rcte_tree_spec.rb +2 -2
  145. data/spec/extensions/schema_spec.rb +2 -2
  146. data/spec/extensions/serialization_modification_detection_spec.rb +8 -0
  147. data/spec/extensions/serialization_spec.rb +15 -1
  148. data/spec/extensions/sharding_spec.rb +1 -1
  149. data/spec/extensions/single_table_inheritance_spec.rb +1 -1
  150. data/spec/extensions/static_cache_spec.rb +59 -9
  151. data/spec/extensions/tactical_eager_loading_spec.rb +19 -4
  152. data/spec/extensions/update_primary_key_spec.rb +17 -1
  153. data/spec/extensions/validation_class_methods_spec.rb +25 -0
  154. data/spec/extensions/validation_helpers_spec.rb +59 -3
  155. data/spec/integration/associations_test.rb +5 -5
  156. data/spec/integration/eager_loader_test.rb +32 -63
  157. data/spec/integration/model_test.rb +2 -2
  158. data/spec/integration/plugin_test.rb +88 -56
  159. data/spec/integration/prepared_statement_test.rb +1 -1
  160. data/spec/integration/schema_test.rb +1 -1
  161. data/spec/integration/timezone_test.rb +0 -1
  162. data/spec/integration/transaction_test.rb +0 -1
  163. data/spec/model/association_reflection_spec.rb +1 -1
  164. data/spec/model/associations_spec.rb +106 -84
  165. data/spec/model/base_spec.rb +4 -4
  166. data/spec/model/eager_loading_spec.rb +8 -8
  167. data/spec/model/model_spec.rb +27 -9
  168. data/spec/model/plugins_spec.rb +71 -0
  169. data/spec/model/record_spec.rb +99 -13
  170. metadata +12 -2
@@ -0,0 +1,270 @@
1
+ = New Plugins
2
+
3
+ * An auto_validations plugin has been added, which automatically
4
+ adds not null, type, and unique validations based on information
5
+ obtained from parsing the database schema. If you don't
6
+ require customization of the validation error message per
7
+ column, this can significantly DRY up validation code. Currently
8
+ this plugin requires the database support index parsing; that
9
+ restriction will be removed in Sequel 4.
10
+
11
+ * An input_transformer plugin has been added, for automatically
12
+ running a transformation proc on all model column setter
13
+ input before use. This is a generalization of the
14
+ string_stripper plugin, allowing arbitrary modifications
15
+ to the input.
16
+
17
+ * An error_splitter plugin has been added, for splitting validation
18
+ errors applying to multiple columns into a separate validation
19
+ error per column. This is useful if you want to to include such
20
+ errors when using Errors#on to get all errors on the column. In
21
+ general, only uniqueness errors apply to multiple columns, so
22
+ those are the only errors likely to be affected.
23
+
24
+ = Other New Features
25
+
26
+ * Database.extension has been added, allowing you to load an
27
+ extension into all future databases. This is similar to loading a
28
+ plugin into Sequel::Model itself. For example, if you want all
29
+ Database instances to use the query_literals extension, run the
30
+ following before creating your Database instances:
31
+
32
+ Sequel::Database.extension :query_literals
33
+
34
+ * Database.after_initialize has been added for running a hook
35
+ on all new databases created.
36
+
37
+ * Model.default_set_fields_options has been added, allowing you
38
+ to set the default options for the #set_fields and #update_fields
39
+ methods. This is useful if you want to make :missing=>:raise
40
+ or :missing=>:skip the default behavior.
41
+
42
+ * The :setter, :adder, :remover, and :clearer association options
43
+ have been added. These allow you to override the default
44
+ implementation used to modify the association. :setter affects
45
+ the *_to_one setter method, :adder the *_to_many add_* method,
46
+ :remover the *_to_many remove_* method, and :clearer the
47
+ *_to_many remove_all_* method.
48
+
49
+ Previously, you had to override a private method to get the same
50
+ behavior, this just offers a nicer API for that.
51
+
52
+ * A :keep_reference Database option has been added. When set to
53
+ false, a reference to the Database instance is not kept in
54
+ Sequel::DATABASES. This is designed for Database instances
55
+ created by libraries, so they don't accidentally get chosen as
56
+ the default Sequel::Model database.
57
+
58
+ * Model#modified! now accepts a column and marks that column
59
+ as changed. This is useful if you plan on mutating the column
60
+ value as opposed to reassigning it.
61
+
62
+ * Model#modified? now accepts a column and returns whether the
63
+ column has been changed.
64
+
65
+ * The migrators now support an :allow_missing_migration_files
66
+ option, which makes them silently ignore errors related to
67
+ missing migration files.
68
+
69
+ * validates_schema_types has been added to validation_helpers,
70
+ which validates that the column values are instances of the
71
+ expected ruby type for the given database schema type. This
72
+ is a more robust version of the validates_not_string
73
+ extension, and users of validates_not_string are encouraged
74
+ to switch soon, as validates_not_string is going away in
75
+ Sequel 4.
76
+
77
+ validates_schema_type has been added to validation_class_methods,
78
+ which preforms the same validation, but it requires the columns
79
+ be listed explicitly.
80
+
81
+ validates_type in validation_helpers has been expanded to
82
+ accept an array of allowable classes.
83
+
84
+ Related to this is the addition of Database#schema_type_class for
85
+ returning the type class(es) for the given schema type symbol.
86
+
87
+ * validates_not_null has been added to the validation_helpers
88
+ plugin. This is similar to the validates_presence validation,
89
+ but only checks for nil values, allowing empty/blank strings.
90
+
91
+ * In the caching plugin, when the :ignore_exceptions option is true,
92
+ exceptions raised when deleting an object from the cache are now
93
+ ignored correctly.
94
+
95
+ * On PostgreSQL, Sequel now supports a :search_path Database
96
+ option to automatically set the client connection search_path.
97
+ This allows you to control which schemas do no require
98
+ qualification, and in which order to check schemas when
99
+ referencing unqualified objects. If you were using the
100
+ default_schema setting, it is recommended that you switch
101
+ to using :search_path instead.
102
+
103
+ * The pg_array extension can now register array types on a
104
+ per-Database basis via Database#register_array_type. Previously,
105
+ only global registration of array types was allowed. Additionally,
106
+ when registering array types on a per-Database basis, the oids can
107
+ be looked up automatically, making it possible to register array
108
+ types with just a type name:
109
+
110
+ DB.register_array_type(:interval)
111
+
112
+ * The pg_array extension now automatically creates conversion
113
+ procs for array types of all named types used by the
114
+ database. This means that if you use the pg_array and
115
+ pg_hstore extensions, the hstore[] type is now handled
116
+ correctly.
117
+
118
+ * The postgres adapter now supports :use_iso_date_format and
119
+ :convert_infinite_timestamps Database options. Previously,
120
+ use_iso_date_format was only a global setting, and
121
+ convert_infinite_timestamps could only be set after
122
+ initialization.
123
+
124
+ * Database#supports_schema_parsing? has been added to check
125
+ if schema parsing via the Database#schema method is
126
+ supported.
127
+
128
+ = Other Improvements
129
+
130
+ * A race condition related to prepared_sql for newly prepared
131
+ statements has been fixed.
132
+
133
+ * Dataset#get now works correctly if given an array with multiple
134
+ columns if there were no returned rows.
135
+
136
+ * The plugins that ship with Sequel now handle frozen model instances
137
+ correctly.
138
+
139
+ * Freezing of model instances now works correctly for models without
140
+ primary keys.
141
+
142
+ * Database constraints added with the constraint_validations
143
+ plugin now handle NULL values correctly if the :allow_nil=>true
144
+ setting is used.
145
+
146
+ * The pagination, pretty_table, query, schema_caching,
147
+ schema_dumper, and select_remove extensions can now be
148
+ loaded by Database#extension. If you are loading them
149
+ globally via Sequel.extension, switch to using
150
+ Database#extension, since that will be required starting
151
+ in Sequel 4.
152
+
153
+ * The lazy_attributes plugin no longer uses the identity_map plugin
154
+ internally, and eager loading lazy attributes now works correctly
155
+ without an active identity map.
156
+
157
+ * The many_to_one_pk_lookup plugin now handles many more corner
158
+ cases, and should be safe to enable by default.
159
+
160
+ * The static_cache plugin now has optimized implementations of
161
+ Model.map, .to_hash, and .to_hash_groups which work without a
162
+ database query. Model.count without arguments has also been
163
+ optimized to not require a database query.
164
+
165
+ * Fetching new records has been made faster when using the
166
+ update_primary_key plugin, since it was changed to cache the primary
167
+ key values lazily.
168
+
169
+ * When using the update_primary_key plugin, if the primary key
170
+ changes, clear the associations cache of all non-many_to_one
171
+ associations (since those will likely be based on the primary
172
+ key).
173
+
174
+ * The pg_typecast_on_load plugin no longer errors if given a
175
+ column that doesn't have a matching oid conversion proc.
176
+
177
+ * Handling of domain types on PostgreSQL has been significantly
178
+ improved. Domain type columns now have correct model
179
+ typecasting, and the pg_row extension correctly sets up
180
+ conversion procs for domain types inside composite types.
181
+
182
+ * Postgres::HStoreOp#- now automatically casts string input to
183
+ text, so that PostgreSQL doesn't assume the string is an
184
+ hstore.
185
+
186
+ * Postgres::PGRangeOp#starts_before and #ends_after have been
187
+ renamed to #ends_before and #starts_after. The previous
188
+ names were misleading. The old names are still available
189
+ for backwards compatibility, but they will be removed in the
190
+ Sequel 4.
191
+
192
+ * The pg_row plugin now handles aliased tables correctly.
193
+
194
+ * Model#validate in the validation_class_methods plugin no
195
+ longer skips validate methods in superclasses or previously
196
+ loaded plugins.
197
+
198
+ * Loading the touch plugin into a model subclass after it has
199
+ been loaded into a model superclass no longer ignores
200
+ inherited touched associations.
201
+
202
+ * Sequel no longer resets the conversion procs for the
203
+ Database instance when using Databaset#extension to load a
204
+ pg_* extension that adds global conversion procs. Instead,
205
+ the global conversion procs are added to the instance-specific
206
+ conversion procs. The result of this is that manually added
207
+ conversion procs will not be lost if an extension is loaded
208
+ afterward.
209
+
210
+ * The jdbc adapter now references the driver class before loading
211
+ subadapter specific code, which can fix issues if the database
212
+ tries to connect on initialization (such as the jdbc/postgres
213
+ adapter if the pg_hstore extension is loaded previously).
214
+
215
+ * A guide describing Sequel's support for advanced PostgreSQL
216
+ features has been added.
217
+
218
+ = Backwards Compatibility
219
+
220
+ * If you have already used the constraint_validations plugin to
221
+ create validations with the :allow_nil=>true option, you should
222
+ drop and regenerate those constraints to ensure they handle NULL
223
+ values correctly.
224
+
225
+ * The change to make PostgreSQL automatically handle domain
226
+ types can break previous code that set up special conversions
227
+ and typecasts per domain type. In the schema parsing, if you
228
+ want to get the domain type information, it will be contained
229
+ in the :db_domain_type and :domain_oid schema entries.
230
+
231
+ * Sequel::Postgres.use_iso_date_format is now only defined if
232
+ you are using the postgres adapter. Previously, it could
233
+ be defined when using other adapters with a pg_* extension,
234
+ even though the setting had no effect in that case.
235
+
236
+ * The validation_class_methods plugin now copies validations into
237
+ the subclass upon inheritance, instead of recursing into the
238
+ superclass on validation. This makes it more similar to how
239
+ all the other Sequel plugins work. However, it also means that
240
+ if you add validations to a superclass after creating a
241
+ subclass, the subclass won't have those validations. Additionally
242
+ if you skip superclass validations in a child class after creating
243
+ a grandchild class, the grandchild class could still have the
244
+ parent class's validations.
245
+
246
+ * The validates_unique validation in validation_helpers no longer
247
+ attempts to do the uniqueness query if the underlying columns
248
+ have validation errors. The reasoning behind this is that if the
249
+ underlying columns are not valid, the uniqueness query can cause
250
+ a DatabaseError.
251
+
252
+ * If you were passing strings in hstore format to
253
+ Postgres::HStoreOp#-, you should manually cast them to hstore:
254
+
255
+ hstore_op - Sequel.cast('a=>b', :hstore)
256
+
257
+ * The default validation error message for validates_type has been
258
+ modified.
259
+
260
+ * Database#schema_column_type was made public accidently by an
261
+ adapter and a few extensions. That has been fixed, but if you
262
+ were calling it with an explicit receiver and it happened to
263
+ work by accident before, you'll need to update your code.
264
+
265
+ = Sequel 4 Implementation Planning
266
+
267
+ * Sequel 4 implementation work will begin shortly. All Sequel users
268
+ are encouraged to read about the proposed changes and provide
269
+ feedback on the implementation plan. For details, see
270
+ https://github.com/jeremyevans/sequel-4-plans.
@@ -19,6 +19,7 @@ could conceivably be abused to do so:
19
19
  * Sequel::Schema::CreateTableGenerator.add_type_method
20
20
  * Sequel::Dataset.def_mutation_method
21
21
  * Sequel::Dataset.def_append_methods
22
+ * Sequel::Model::Plugins.def_dataset_methods
22
23
  * Sequel.def_adapter_method (private)
23
24
  * Sequel::Model::InstanceMethods.class_attr_overridable (private)
24
25
  * Sequel::Model::InstanceMethods.class_attr_reader (private)
@@ -165,6 +166,11 @@ Instead, you should do:
165
166
 
166
167
  DB[:table].update(:column => params[:value].to_s) # Safe
167
168
 
169
+ ==== SQL Fragment passed to Dataset#lock_style
170
+
171
+ The Sequel::Dataset#lock_style method also treats an input string
172
+ as SQL code. This method should not be called with user input.
173
+
168
174
  === SQL Identifier Injections
169
175
 
170
176
  Usually, Sequel treats ruby symbols as SQL identifiers, and ruby
@@ -264,15 +264,6 @@ module Sequel
264
264
  end
265
265
  end
266
266
 
267
- # Convert smallint type to boolean if convert_smallint_to_bool is true
268
- def schema_column_type(db_type)
269
- if Sequel::IBMDB.convert_smallint_to_bool && db_type =~ /smallint/i
270
- :boolean
271
- else
272
- super
273
- end
274
- end
275
-
276
267
  # On DB2, a table might need to be REORGed if you are testing existence
277
268
  # of it. This REORGs automatically if the database raises a specific
278
269
  # error that indicates it should be REORGed.
@@ -364,6 +355,15 @@ module Sequel
364
355
  def rollback_transaction(conn, opts={})
365
356
  log_yield(TRANSACTION_ROLLBACK){conn.rollback}
366
357
  end
358
+
359
+ # Convert smallint type to boolean if convert_smallint_to_bool is true
360
+ def schema_column_type(db_type)
361
+ if Sequel::IBMDB.convert_smallint_to_bool && db_type =~ /smallint/i
362
+ :boolean
363
+ else
364
+ super
365
+ end
366
+ end
367
367
  end
368
368
 
369
369
  class Dataset < Sequel::Dataset
@@ -30,34 +30,39 @@ module Sequel
30
30
  # Contains procs keyed on sub adapter type that extend the
31
31
  # given database object so it supports the correct database type.
32
32
  DATABASE_SETUP = {:postgresql=>proc do |db|
33
+ JDBC.load_gem(:Postgres)
34
+ org.postgresql.Driver
33
35
  Sequel.ts_require 'adapters/jdbc/postgresql'
34
36
  db.extend(Sequel::JDBC::Postgres::DatabaseMethods)
35
37
  db.dataset_class = Sequel::JDBC::Postgres::Dataset
36
- JDBC.load_gem(:Postgres)
37
38
  org.postgresql.Driver
38
39
  end,
39
40
  :mysql=>proc do |db|
41
+ JDBC.load_gem(:MySQL)
42
+ com.mysql.jdbc.Driver
40
43
  Sequel.ts_require 'adapters/jdbc/mysql'
41
44
  db.extend(Sequel::JDBC::MySQL::DatabaseMethods)
42
45
  db.extend_datasets Sequel::MySQL::DatasetMethods
43
- JDBC.load_gem(:MySQL)
44
46
  com.mysql.jdbc.Driver
45
47
  end,
46
48
  :sqlite=>proc do |db|
49
+ JDBC.load_gem(:SQLite3)
50
+ org.sqlite.JDBC
47
51
  Sequel.ts_require 'adapters/jdbc/sqlite'
48
52
  db.extend(Sequel::JDBC::SQLite::DatabaseMethods)
49
53
  db.extend_datasets Sequel::SQLite::DatasetMethods
50
54
  db.set_integer_booleans
51
- JDBC.load_gem(:SQLite3)
52
55
  org.sqlite.JDBC
53
56
  end,
54
57
  :oracle=>proc do |db|
58
+ Java::oracle.jdbc.driver.OracleDriver
55
59
  Sequel.ts_require 'adapters/jdbc/oracle'
56
60
  db.extend(Sequel::JDBC::Oracle::DatabaseMethods)
57
61
  db.dataset_class = Sequel::JDBC::Oracle::Dataset
58
62
  Java::oracle.jdbc.driver.OracleDriver
59
63
  end,
60
64
  :sqlserver=>proc do |db|
65
+ com.microsoft.sqlserver.jdbc.SQLServerDriver
61
66
  Sequel.ts_require 'adapters/jdbc/sqlserver'
62
67
  db.extend(Sequel::JDBC::SQLServer::DatabaseMethods)
63
68
  db.extend_datasets Sequel::MSSQL::DatasetMethods
@@ -65,65 +70,75 @@ module Sequel
65
70
  com.microsoft.sqlserver.jdbc.SQLServerDriver
66
71
  end,
67
72
  :jtds=>proc do |db|
73
+ JDBC.load_gem(:JTDS)
74
+ Java::net.sourceforge.jtds.jdbc.Driver
68
75
  Sequel.ts_require 'adapters/jdbc/jtds'
69
76
  db.extend(Sequel::JDBC::JTDS::DatabaseMethods)
70
77
  db.dataset_class = Sequel::JDBC::JTDS::Dataset
71
78
  db.send(:set_mssql_unicode_strings)
72
- JDBC.load_gem(:JTDS)
73
79
  Java::net.sourceforge.jtds.jdbc.Driver
74
80
  end,
75
81
  :h2=>proc do |db|
82
+ JDBC.load_gem(:H2)
83
+ org.h2.Driver
76
84
  Sequel.ts_require 'adapters/jdbc/h2'
77
85
  db.extend(Sequel::JDBC::H2::DatabaseMethods)
78
86
  db.dataset_class = Sequel::JDBC::H2::Dataset
79
- JDBC.load_gem(:H2)
80
87
  org.h2.Driver
81
88
  end,
82
89
  :hsqldb=>proc do |db|
90
+ JDBC.load_gem(:HSQLDB)
91
+ org.hsqldb.jdbcDriver
83
92
  Sequel.ts_require 'adapters/jdbc/hsqldb'
84
93
  db.extend(Sequel::JDBC::HSQLDB::DatabaseMethods)
85
94
  db.dataset_class = Sequel::JDBC::HSQLDB::Dataset
86
- JDBC.load_gem(:HSQLDB)
87
95
  org.hsqldb.jdbcDriver
88
96
  end,
89
97
  :derby=>proc do |db|
98
+ JDBC.load_gem(:Derby)
99
+ org.apache.derby.jdbc.EmbeddedDriver
90
100
  Sequel.ts_require 'adapters/jdbc/derby'
91
101
  db.extend(Sequel::JDBC::Derby::DatabaseMethods)
92
102
  db.dataset_class = Sequel::JDBC::Derby::Dataset
93
- JDBC.load_gem(:Derby)
94
103
  org.apache.derby.jdbc.EmbeddedDriver
95
104
  end,
96
105
  :as400=>proc do |db|
106
+ com.ibm.as400.access.AS400JDBCDriver
97
107
  Sequel.ts_require 'adapters/jdbc/as400'
98
108
  db.extend(Sequel::JDBC::AS400::DatabaseMethods)
99
109
  db.dataset_class = Sequel::JDBC::AS400::Dataset
100
110
  com.ibm.as400.access.AS400JDBCDriver
101
111
  end,
102
112
  :"informix-sqli"=>proc do |db|
113
+ com.informix.jdbc.IfxDriver
103
114
  Sequel.ts_require 'adapters/jdbc/informix'
104
115
  db.extend(Sequel::JDBC::Informix::DatabaseMethods)
105
116
  db.extend_datasets Sequel::Informix::DatasetMethods
106
117
  com.informix.jdbc.IfxDriver
107
118
  end,
108
119
  :db2=>proc do |db|
120
+ com.ibm.db2.jcc.DB2Driver
109
121
  Sequel.ts_require 'adapters/jdbc/db2'
110
122
  db.extend(Sequel::JDBC::DB2::DatabaseMethods)
111
123
  db.dataset_class = Sequel::JDBC::DB2::Dataset
112
124
  com.ibm.db2.jcc.DB2Driver
113
125
  end,
114
126
  :firebirdsql=>proc do |db|
127
+ org.firebirdsql.jdbc.FBDriver
115
128
  Sequel.ts_require 'adapters/jdbc/firebird'
116
129
  db.extend(Sequel::JDBC::Firebird::DatabaseMethods)
117
130
  db.extend_datasets Sequel::Firebird::DatasetMethods
118
131
  org.firebirdsql.jdbc.FBDriver
119
132
  end,
120
133
  :jdbcprogress=>proc do |db|
134
+ com.progress.sql.jdbc.JdbcProgressDriver
121
135
  Sequel.ts_require 'adapters/jdbc/progress'
122
136
  db.extend(Sequel::JDBC::Progress::DatabaseMethods)
123
137
  db.extend_datasets Sequel::Progress::DatasetMethods
124
138
  com.progress.sql.jdbc.JdbcProgressDriver
125
139
  end,
126
140
  :cubrid=>proc do |db|
141
+ Java::cubrid.jdbc.driver.CUBRIDDriver
127
142
  Sequel.ts_require 'adapters/jdbc/cubrid'
128
143
  db.extend(Sequel::JDBC::Cubrid::DatabaseMethods)
129
144
  db.extend_datasets Sequel::Cubrid::DatasetMethods
@@ -150,9 +150,14 @@ module Sequel
150
150
  PG_OBJECT_METHOD = TYPE_TRANSLATOR_INSTANCE.method(:pg_object)
151
151
 
152
152
  # Add the shared PostgreSQL prepared statement methods
153
- def prepare(*args)
154
- ps = super
153
+ def prepare(type, name=nil, *values)
154
+ ps = to_prepared_statement(type, values)
155
+ ps.extend(JDBC::Dataset::PreparedStatementMethods)
155
156
  ps.extend(::Sequel::Postgres::DatasetMethods::PreparedStatementMethods)
157
+ if name
158
+ ps.prepared_statement_name = name
159
+ db.set_prepared_statement(name, ps)
160
+ end
156
161
  ps
157
162
  end
158
163