sequel 3.35.0 → 3.36.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.
- data/CHANGELOG +78 -0
- data/Rakefile +3 -3
- data/bin/sequel +3 -1
- data/doc/advanced_associations.rdoc +154 -11
- data/doc/migration.rdoc +18 -0
- data/doc/object_model.rdoc +541 -0
- data/doc/opening_databases.rdoc +4 -1
- data/doc/release_notes/3.36.0.txt +245 -0
- data/doc/schema_modification.rdoc +0 -6
- data/lib/sequel/adapters/do/mysql.rb +7 -0
- data/lib/sequel/adapters/jdbc.rb +11 -3
- data/lib/sequel/adapters/jdbc/mysql.rb +3 -5
- data/lib/sequel/adapters/jdbc/postgresql.rb +10 -8
- data/lib/sequel/adapters/jdbc/progress.rb +21 -0
- data/lib/sequel/adapters/mock.rb +2 -6
- data/lib/sequel/adapters/mysql.rb +3 -9
- data/lib/sequel/adapters/mysql2.rb +12 -11
- data/lib/sequel/adapters/postgres.rb +32 -40
- data/lib/sequel/adapters/shared/mssql.rb +15 -11
- data/lib/sequel/adapters/shared/mysql.rb +28 -3
- data/lib/sequel/adapters/shared/oracle.rb +5 -0
- data/lib/sequel/adapters/shared/postgres.rb +59 -5
- data/lib/sequel/adapters/shared/sqlite.rb +3 -13
- data/lib/sequel/adapters/sqlite.rb +0 -7
- data/lib/sequel/adapters/swift/mysql.rb +2 -5
- data/lib/sequel/adapters/tinytds.rb +1 -2
- data/lib/sequel/connection_pool/sharded_threaded.rb +5 -1
- data/lib/sequel/connection_pool/threaded.rb +9 -1
- data/lib/sequel/database/dataset_defaults.rb +3 -1
- data/lib/sequel/database/misc.rb +7 -1
- data/lib/sequel/database/query.rb +11 -3
- data/lib/sequel/database/schema_generator.rb +40 -9
- data/lib/sequel/database/schema_methods.rb +6 -1
- data/lib/sequel/dataset/actions.rb +5 -5
- data/lib/sequel/dataset/prepared_statements.rb +3 -1
- data/lib/sequel/dataset/query.rb +1 -1
- data/lib/sequel/extensions/migration.rb +28 -0
- data/lib/sequel/extensions/pg_auto_parameterize.rb +0 -9
- data/lib/sequel/extensions/pg_inet.rb +89 -0
- data/lib/sequel/extensions/pg_json.rb +178 -0
- data/lib/sequel/extensions/schema_dumper.rb +24 -6
- data/lib/sequel/model/associations.rb +19 -15
- data/lib/sequel/model/base.rb +11 -12
- data/lib/sequel/plugins/composition.rb +1 -2
- data/lib/sequel/plugins/eager_each.rb +59 -0
- data/lib/sequel/plugins/json_serializer.rb +41 -4
- data/lib/sequel/plugins/nested_attributes.rb +72 -52
- data/lib/sequel/plugins/optimistic_locking.rb +8 -0
- data/lib/sequel/plugins/tactical_eager_loading.rb +7 -7
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/postgres_spec.rb +271 -1
- data/spec/adapters/sqlite_spec.rb +11 -0
- data/spec/core/connection_pool_spec.rb +26 -1
- data/spec/core/database_spec.rb +19 -0
- data/spec/core/dataset_spec.rb +45 -5
- data/spec/core/expression_filters_spec.rb +31 -67
- data/spec/core/mock_adapter_spec.rb +4 -0
- data/spec/extensions/core_extensions_spec.rb +83 -0
- data/spec/extensions/eager_each_spec.rb +34 -0
- data/spec/extensions/inflector_spec.rb +0 -4
- data/spec/extensions/json_serializer_spec.rb +32 -1
- data/spec/extensions/migration_spec.rb +28 -0
- data/spec/extensions/nested_attributes_spec.rb +134 -1
- data/spec/extensions/optimistic_locking_spec.rb +15 -1
- data/spec/extensions/pg_hstore_spec.rb +1 -1
- data/spec/extensions/pg_inet_spec.rb +44 -0
- data/spec/extensions/pg_json_spec.rb +101 -0
- data/spec/extensions/prepared_statements_spec.rb +30 -0
- data/spec/extensions/rcte_tree_spec.rb +9 -0
- data/spec/extensions/schema_dumper_spec.rb +195 -7
- data/spec/extensions/serialization_spec.rb +4 -0
- data/spec/extensions/spec_helper.rb +9 -1
- data/spec/extensions/tactical_eager_loading_spec.rb +8 -0
- data/spec/integration/database_test.rb +5 -1
- data/spec/integration/prepared_statement_test.rb +20 -2
- data/spec/model/associations_spec.rb +27 -0
- data/spec/model/base_spec.rb +54 -0
- data/spec/model/model_spec.rb +6 -0
- data/spec/model/record_spec.rb +18 -0
- data/spec/rcov.opts +2 -0
- metadata +14 -3
data/doc/opening_databases.rdoc
CHANGED
@@ -68,7 +68,7 @@ These options are shared by all adapters unless otherwise noted.
|
|
68
68
|
|
69
69
|
:adapter :: The adapter to use
|
70
70
|
:database :: The name of the database to which to connect
|
71
|
-
:default_schema :: The database schema to use
|
71
|
+
:default_schema :: The database schema to use in schema_modification and introspection.
|
72
72
|
:host :: The hostname of the database server to which to connect
|
73
73
|
:logger :: An array of SQL loggers to log to
|
74
74
|
:loggers :: An array of SQL loggers to log to
|
@@ -265,6 +265,7 @@ Example connection strings:
|
|
265
265
|
jdbc:oracle:thin:user/password@localhost:1521:database
|
266
266
|
jdbc:db2://localhost:3700/database:user=user;password=password;
|
267
267
|
jdbc:firebirdsql:localhost/3050:/path/to/database.fdb
|
268
|
+
jdbc:jdbcprogress:T:hostname:port:database
|
268
269
|
|
269
270
|
You can also use JNDI connection strings:
|
270
271
|
|
@@ -294,6 +295,8 @@ The following additional options are supported:
|
|
294
295
|
:config_local_infile :: If provided, sets the Mysql::OPT_LOCAL_INFILE option on the connection with the given value.
|
295
296
|
:encoding :: Specify the encoding/character set to use for the connection.
|
296
297
|
:socket :: Can be used to specify a Unix socket file to connect to instead of a TCP host and port.
|
298
|
+
:sql_mode :: Set the sql_mode(s) for a given connection. Can be single symbol or string,
|
299
|
+
or an array of symbols or strings (e.g. <tt>:sql_mode=>[:no_zero_date, :pipes_as_concat]</tt>).
|
297
300
|
:timeout :: Sets the wait_timeout for the connection, defaults to 1 month.
|
298
301
|
:read_timeout :: Set the timeout in seconds for reading back results to a query.
|
299
302
|
:connect_timeout :: Set the timeout in seconds before a connection attempt is abandoned.
|
@@ -0,0 +1,245 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* An eager_each plugin has been added, which automatically makes
|
4
|
+
eagerly loaded datasets do eager loading if you call #each (or
|
5
|
+
another Enumerable method) instead of #all. By default, if you
|
6
|
+
call #each on an eager dataset, it will not do eager loading,
|
7
|
+
and if you call #each on an eager_graph dataset, you will
|
8
|
+
get plain hashes with columns from all joined tables instead of
|
9
|
+
model objects. With this plugin, #each on both eager and
|
10
|
+
eager_graph datasets will do eager loading.
|
11
|
+
|
12
|
+
* The nested attributes plugin now supports composite primary keys
|
13
|
+
in associated records. Additionally, it now deals better with
|
14
|
+
natural primary keys in associated records. There is a new
|
15
|
+
:unmatched_pk option that can be set to :create if you want to
|
16
|
+
create new associated records when the input hash contains
|
17
|
+
primary key information that doesn't match one of the existing
|
18
|
+
associated objects.
|
19
|
+
|
20
|
+
The nested attributes plugin now also supports a :transform option.
|
21
|
+
If given, this option is called with the parent object and the
|
22
|
+
input hash given for each associated record passed into the
|
23
|
+
nested atttributes setter. The callable should return the hash
|
24
|
+
of attributes to use.
|
25
|
+
|
26
|
+
* Model#from_json in the json_serializer plugin now takes an options
|
27
|
+
hash and recognizes the :fields option. If the :fields option is
|
28
|
+
given, it should be an array of field names, and set_fields is
|
29
|
+
called with the array instead of using set. This allows you to
|
30
|
+
easily filter which fields in the hash are set in the model
|
31
|
+
instance. The entire options hash is also passed to set_fields
|
32
|
+
if :fields is present, so you can additionally use the :missing =>
|
33
|
+
:raise or :missing => :skip options that set_fields supports.
|
34
|
+
|
35
|
+
* The Dataset#to_json method in the json_serializer plugin now
|
36
|
+
respects :root=>:collection and :root=>:instance options. If
|
37
|
+
:root=>:collection is given, only the collection is wrapped in a
|
38
|
+
hash, and if :root=>:instance is given, only the instances are
|
39
|
+
wrapped in a hash. For backwards compatibility, both the
|
40
|
+
instances and collection are wrapped in a hash:
|
41
|
+
|
42
|
+
Model.to_json(:root=>true)
|
43
|
+
# {"models":[{"model":{"id":1}}]}
|
44
|
+
|
45
|
+
Model.to_json(:root=>:collection)
|
46
|
+
# {"models":[{"id":1}]}
|
47
|
+
|
48
|
+
Model.to_json(:root=>:instance)
|
49
|
+
# [{"model":{"id":1}}]
|
50
|
+
|
51
|
+
Wrapping both the collection and instance in a root by default
|
52
|
+
is probably an undesired behavior, so the default for :root=>true
|
53
|
+
may change in the next major version of Sequel. Users who want
|
54
|
+
the current behavior should switch to using :root=>:both.
|
55
|
+
|
56
|
+
* The schema_dumper extension now respects an :index_names option
|
57
|
+
when dumping. This option can be set to false to never dump the
|
58
|
+
index names. It can also be set to :namespace, in which case if
|
59
|
+
the database does not have a global index namespace, it will
|
60
|
+
automatically prefix the name of the index with the name of the
|
61
|
+
table.
|
62
|
+
|
63
|
+
Database#global_index_namespace? was added to check if the
|
64
|
+
database uses a global index namespace. If false, index names are
|
65
|
+
probably namespaced per table (MySQL, MSSQL, Oracle).
|
66
|
+
|
67
|
+
* :each is now a valid prepared statement type. This prepared
|
68
|
+
statement type requires a block when you call the statement, and
|
69
|
+
iterates over the records of the statement a row at a time.
|
70
|
+
Previously, there wasn't a way to iterate over the records of a
|
71
|
+
prepared statement a row at a time, since the :select and :all
|
72
|
+
types collect all rows into an array before iterating over them.
|
73
|
+
|
74
|
+
* A :connection_handling=>:queue option is now respected for
|
75
|
+
database objects, and changes the threaded connection pools to use
|
76
|
+
a queue instead of a stack as the data structure for storing
|
77
|
+
available connections. A queue does not perform as well as a
|
78
|
+
stack, but reduces the likelihood of stale connections.
|
79
|
+
|
80
|
+
It is possible that Sequel will change in the future from using a
|
81
|
+
stack by default to using a queue by default, so any users who
|
82
|
+
specifically desire a stack to be used should specify the
|
83
|
+
:connection_handling=>:stack option.
|
84
|
+
|
85
|
+
* Sequel::Migrator now supports is_current? class method to check
|
86
|
+
if there are no outstanding migrations to apply. It also supports
|
87
|
+
a check_current class method, which raises an exception if there
|
88
|
+
are outstanding migrations to apply.
|
89
|
+
|
90
|
+
* A pg_json extension has been added, supporting PostgreSQL's 9.2
|
91
|
+
json type, similarly to the pg_array and pg_hstore extensions.
|
92
|
+
Note that with the current PostgreSQL json code, the root object
|
93
|
+
can be a string or number, but ruby's json library requires the
|
94
|
+
root json value to be an object or array. So you will probably
|
95
|
+
get an exception if you attempt to retrieve a PostgreSQL json
|
96
|
+
value that ruby's JSON library won't parse.
|
97
|
+
|
98
|
+
* A pg_inet extension has been added, which automatically typecasts
|
99
|
+
PostgreSQL inet and cidr types to ruby IPAddr objects on retrieval.
|
100
|
+
|
101
|
+
* Database#transaction on PostgreSQL now recognizes :read_only and
|
102
|
+
:deferrable options, and can use them to set the READ ONLY and
|
103
|
+
DEFERRABLE transaction flags. A :synchronous option is also
|
104
|
+
recognized, which can be set to true, false, :local, or
|
105
|
+
:remote_write, and sets the value of synchronous_commit just for
|
106
|
+
that transaction.
|
107
|
+
|
108
|
+
* When adding and dropping indexes on PostgreSQL, a :concurrently
|
109
|
+
option can be used to create or drop the index CONCURRENTLY, which
|
110
|
+
doesn't require a full write table lock.
|
111
|
+
|
112
|
+
* When dropping indexes on PostgreSQL, :if_exists and :cascade options
|
113
|
+
are now recognized.
|
114
|
+
|
115
|
+
* When using alter_table set_column_type on PostgreSQL, the :using
|
116
|
+
option is respected, and can be used to force a specific conversion
|
117
|
+
from the previous value to the new value with the USING syntax.
|
118
|
+
|
119
|
+
* On MySQL, you can now set an :sql_mode option when connecting. This
|
120
|
+
can be a string or symbol or an array of them, and each should match
|
121
|
+
one of MySQL's sql_modes. MySQL's default SQL mode is fairly loose,
|
122
|
+
and using one of the strict sql modes is recommended, but for
|
123
|
+
backwards compatibility, Sequel will not set a specific SQL mode by
|
124
|
+
default. However, that may change in the next major version of
|
125
|
+
Sequel, so to be forwards compatible you should set :sql_mode=>nil
|
126
|
+
if you do not desire a strict SQL mode to be set automatically.
|
127
|
+
|
128
|
+
* Partial indexes are now supported on Microsoft SQL Server 2008
|
129
|
+
(SQL Server refers to them as filtered indexes). Attempting to
|
130
|
+
use a partial index on an earlier version of SQL Server will
|
131
|
+
result in the database raising an exception.
|
132
|
+
|
133
|
+
* A jdbc/progress adapter has been added, supporting the Progress
|
134
|
+
database via the jdbc adapter.
|
135
|
+
|
136
|
+
= Other Improvements
|
137
|
+
|
138
|
+
* Dataset#get now works correctly if you pass it a nil or false
|
139
|
+
argument. Previously, it ignored the argument and used the block
|
140
|
+
instead. If you want to use the block argument, you should not
|
141
|
+
pass in a regular argument.
|
142
|
+
|
143
|
+
* Database#call now passes any blocks given to it to the underlying
|
144
|
+
prepared statement object. Before, a passed block was ignored.
|
145
|
+
|
146
|
+
* Sequel::Model.db is no longer set automatically when creating
|
147
|
+
an anonymous class with an associated database object. This fixes
|
148
|
+
cases where a library would create namespaced models, and the
|
149
|
+
database used by the library would be set as the default for the
|
150
|
+
user's application code.
|
151
|
+
|
152
|
+
* Model *_to_one association setters are now no-ops if you pass a
|
153
|
+
value that is the same as the cached value. This fixes issues with
|
154
|
+
reciprocal associations getting reordered, and is better
|
155
|
+
for performance.
|
156
|
+
|
157
|
+
For cases where the old behavior is desired, the
|
158
|
+
set_associated_object_if_same? method can be overridden to return
|
159
|
+
true for object. If you are manually setting objects in the
|
160
|
+
associations cache before calling the setter method, you may want
|
161
|
+
to set that.
|
162
|
+
|
163
|
+
* The dirty plugin no longer affects the return value of refresh
|
164
|
+
and lock!. Internal changes should now help ensure that plugins
|
165
|
+
don't affect the return values of these methods.
|
166
|
+
|
167
|
+
* Sequel now supports JRuby 1.7's new exception handling, fixing
|
168
|
+
exception handling when connecting in the jdbc adapter.
|
169
|
+
|
170
|
+
* When dumping unsigned integer types in the schema dumper, if the
|
171
|
+
unsigned values could overflow a 32-bit signed integer type,
|
172
|
+
the generic Bignum class is used as the type. This should fix
|
173
|
+
issues when copying a database containing an unsigned 32-bit
|
174
|
+
integer column with values between 2^31 and 2^32-1.
|
175
|
+
|
176
|
+
* In the optimistic_locking plugin, attempting to refresh and
|
177
|
+
save after a failed save now works correctly. Before, the second
|
178
|
+
save would never modify a row.
|
179
|
+
|
180
|
+
* Time types on jdbc/postgres are now typecasted accurately on
|
181
|
+
retrieval, before they could be off by up to a millisecond due to
|
182
|
+
floating point issues.
|
183
|
+
|
184
|
+
* Disconnect detection in the mysql2 adapter has been improved.
|
185
|
+
|
186
|
+
* The jdbc/mysql, do/mysql, and swift/mysql adapters all now support
|
187
|
+
the :timeout option to set the MySQL wait_timeout.
|
188
|
+
|
189
|
+
* Savepoints in prepared transactions are now supported on MySQL
|
190
|
+
5.5.23+, since the bug that caused them to be unsupported starting
|
191
|
+
in 5.5.13 has been fixed.
|
192
|
+
|
193
|
+
* Parsing foreign key metadata for tables with an explicit
|
194
|
+
schema now works correctly on PostgreSQL.
|
195
|
+
|
196
|
+
* bin/sequel -C now namespaces indexes automatically when copying
|
197
|
+
from a database without a global index namespace to a database
|
198
|
+
with a global index namespace.
|
199
|
+
|
200
|
+
* Indexes are now dropped in reverse order that they were added in
|
201
|
+
the schema_dumper.
|
202
|
+
|
203
|
+
* The Model typecasting code works around bugs in objects where
|
204
|
+
object.==('') would raise an exception instead of returning false.
|
205
|
+
|
206
|
+
* A better error message is used if an invalid JDBC URL is
|
207
|
+
provided and the JDBC driver's new.connect method returns NULL.
|
208
|
+
|
209
|
+
* A document describing Sequel's object model has been added,
|
210
|
+
describing the objects Sequel uses to represent SQL concepts.
|
211
|
+
|
212
|
+
* Most adapter specific options to Database methods are now mentioned
|
213
|
+
in the main Database method RDoc.
|
214
|
+
|
215
|
+
= Backwards Compatibility
|
216
|
+
|
217
|
+
* The nested_attributes plugin internals changed significantly. If
|
218
|
+
you were overriding one of the nested_attributes* private methods
|
219
|
+
and calling super to get the default behavior, you may have to
|
220
|
+
update your code.
|
221
|
+
|
222
|
+
* Database#case_sensitive_like has been removed on SQLite. This
|
223
|
+
method never worked correctly, it always returned false even if
|
224
|
+
the case_sensitive_like PRAGMA was set. That's because SQLite
|
225
|
+
doesn't offer a getter for this PRAGMA, only a setter. Note that
|
226
|
+
Database#case_sensitive_like= still exists and works correctly.
|
227
|
+
|
228
|
+
* Database#single_value has been removed from the native SQLite
|
229
|
+
adapter. This method was designed for internal use, and hasn't
|
230
|
+
been used for some time. Any current users of the method should
|
231
|
+
switch to Dataset#single_value.
|
232
|
+
|
233
|
+
* The private Database#defined_columns_for method in the SQLite
|
234
|
+
adapter no longer takes an options hash.
|
235
|
+
|
236
|
+
* A couple jdbc/postgres adapter methods are now private. Previously,
|
237
|
+
the jdbc/postgres adapter overrode some private superclass methods
|
238
|
+
but left the methods public.
|
239
|
+
|
240
|
+
* When using the optimistic_locking plugin, refreshing inside a
|
241
|
+
before_update method after calling super will now result in the
|
242
|
+
lock checking being skipped.
|
243
|
+
|
244
|
+
* The private Model#_refresh no longer returns self, so external
|
245
|
+
plugins should no longer rely on that behavior.
|
@@ -85,14 +85,8 @@ method, the fourth argument is the options hash. The following options are supp
|
|
85
85
|
:null :: Mark the column as allowing NULL values (if true),
|
86
86
|
or not allowing NULL values (if false). If unspecified, will default
|
87
87
|
to whatever the database default is.
|
88
|
-
:size :: The size of the column, generally used with string
|
89
|
-
columns to specify the maximum number of characters the column will hold.
|
90
|
-
An array of two integers can be provided to set the size and the
|
91
|
-
precision, respectively, of decimal columns.
|
92
88
|
:unique :: Mark the column as unique, generally has the same effect as
|
93
89
|
creating a unique index on the column.
|
94
|
-
:unsigned :: Make the column type unsigned, only useful for integer
|
95
|
-
columns.
|
96
90
|
|
97
91
|
=== Other methods
|
98
92
|
|
@@ -18,9 +18,16 @@ module Sequel
|
|
18
18
|
(m = /\/(.*)/.match(URI.parse(uri).path)) && m[1]
|
19
19
|
end
|
20
20
|
|
21
|
+
# Recognize the tinyint(1) column as boolean.
|
21
22
|
def schema_column_type(db_type)
|
22
23
|
db_type == 'tinyint(1)' ? :boolean : super
|
23
24
|
end
|
25
|
+
|
26
|
+
# Apply the connectiong setting SQLs for every new connection.
|
27
|
+
def setup_connection(conn)
|
28
|
+
mysql_connection_setting_sqls.each{|sql| log_yield(sql){conn.create_command(sql).execute_non_query}}
|
29
|
+
super
|
30
|
+
end
|
24
31
|
end
|
25
32
|
|
26
33
|
# Dataset class for MySQL datasets accessed via DataObjects.
|
data/lib/sequel/adapters/jdbc.rb
CHANGED
@@ -116,6 +116,12 @@ module Sequel
|
|
116
116
|
db.extend(Sequel::JDBC::Firebird::DatabaseMethods)
|
117
117
|
db.extend_datasets Sequel::Firebird::DatasetMethods
|
118
118
|
org.firebirdsql.jdbc.FBDriver
|
119
|
+
end,
|
120
|
+
:jdbcprogress=>proc do |db|
|
121
|
+
Sequel.ts_require 'adapters/jdbc/progress'
|
122
|
+
db.extend(Sequel::JDBC::Progress::DatabaseMethods)
|
123
|
+
db.extend_datasets Sequel::Progress::DatasetMethods
|
124
|
+
com.progress.sql.jdbc.JdbcProgressDriver
|
119
125
|
end
|
120
126
|
}
|
121
127
|
|
@@ -205,7 +211,7 @@ module Sequel
|
|
205
211
|
begin
|
206
212
|
JavaSQL::DriverManager.setLoginTimeout(opts[:login_timeout]) if opts[:login_timeout]
|
207
213
|
JavaSQL::DriverManager.getConnection(*args)
|
208
|
-
rescue => e
|
214
|
+
rescue JavaSQL::SQLException, NativeException, StandardError => e
|
209
215
|
raise e unless driver
|
210
216
|
# If the DriverManager can't get the connection - use the connect
|
211
217
|
# method of the driver. (This happens under Tomcat for instance)
|
@@ -217,7 +223,9 @@ module Sequel
|
|
217
223
|
opts[:jdbc_properties].each{|k,v| props.setProperty(k.to_s, v)} if opts[:jdbc_properties]
|
218
224
|
begin
|
219
225
|
driver.new.connect(args[0], props)
|
220
|
-
|
226
|
+
raise(Sequel::DatabaseError, 'driver.new.connect returned nil: probably bad JDBC connection string') unless c
|
227
|
+
c
|
228
|
+
rescue JavaSQL::SQLException, NativeException, StandardError => e2
|
221
229
|
e.message << "\n#{e2.class.name}: #{e2.message}"
|
222
230
|
raise e
|
223
231
|
end
|
@@ -632,7 +640,7 @@ module Sequel
|
|
632
640
|
# Handle type conversions for common Java types.
|
633
641
|
class TYPE_TRANSLATOR
|
634
642
|
LF = "\n".freeze
|
635
|
-
def time(v) Sequel.string_to_time(v.to_string
|
643
|
+
def time(v) Sequel.string_to_time("#{v.to_string}.#{sprintf('%03i', v.getTime.divmod(1000).last)}") end
|
636
644
|
def date(v) Date.civil(v.getYear + 1900, v.getMonth + 1, v.getDate) end
|
637
645
|
def decimal(v) BigDecimal.new(v.to_string) end
|
638
646
|
def byte_array(v) Sequel::SQL::Blob.new(String.from_java_bytes(v)) end
|
@@ -53,13 +53,11 @@ module Sequel
|
|
53
53
|
db_type == 'tinyint(1)' ? :boolean : super
|
54
54
|
end
|
55
55
|
|
56
|
-
#
|
57
|
-
#
|
56
|
+
# Run the default connection setting SQL statements.
|
57
|
+
# Apply the connectiong setting SQLs for every new connection.
|
58
58
|
def setup_connection(conn)
|
59
|
+
mysql_connection_setting_sqls.each{|sql| statement(conn){|s| log_yield(sql){s.execute(sql)}}}
|
59
60
|
super
|
60
|
-
sql = "SET SQL_AUTO_IS_NULL=0"
|
61
|
-
statement(conn){|s| log_yield(sql){s.execute(sql)}} unless opts[:auto_is_null]
|
62
|
-
conn
|
63
61
|
end
|
64
62
|
end
|
65
63
|
end
|
@@ -43,7 +43,7 @@ module Sequel
|
|
43
43
|
class Dataset < JDBC::Dataset
|
44
44
|
include Sequel::Postgres::DatasetMethods
|
45
45
|
APOS = Dataset::APOS
|
46
|
-
|
46
|
+
|
47
47
|
class ::Sequel::JDBC::Dataset::TYPE_TRANSLATOR
|
48
48
|
# Convert Java::OrgPostgresqlJdbc4::Jdbc4Array to ruby arrays
|
49
49
|
def pg_array(v)
|
@@ -73,6 +73,15 @@ module Sequel
|
|
73
73
|
PG_ARRAY_METHOD = TYPE_TRANSLATOR_INSTANCE.method(:pg_array)
|
74
74
|
PG_OBJECT_METHOD = TYPE_TRANSLATOR_INSTANCE.method(:pg_object)
|
75
75
|
|
76
|
+
# Add the shared PostgreSQL prepared statement methods
|
77
|
+
def prepare(*args)
|
78
|
+
ps = super
|
79
|
+
ps.extend(::Sequel::Postgres::DatasetMethods::PreparedStatementMethods)
|
80
|
+
ps
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
76
85
|
# Handle PostgreSQL array and object types. Object types are just
|
77
86
|
# turned into strings, similarly to how the native adapter treats
|
78
87
|
# the types.
|
@@ -87,13 +96,6 @@ module Sequel
|
|
87
96
|
end
|
88
97
|
end
|
89
98
|
|
90
|
-
# Add the shared PostgreSQL prepared statement methods
|
91
|
-
def prepare(*args)
|
92
|
-
ps = super
|
93
|
-
ps.extend(::Sequel::Postgres::DatasetMethods::PreparedStatementMethods)
|
94
|
-
ps
|
95
|
-
end
|
96
|
-
|
97
99
|
# Literalize strings similar to the native postgres adapter
|
98
100
|
def literal_string_append(sql, v)
|
99
101
|
sql << APOS << db.synchronize{|c| c.escape_string(v)} << APOS
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Sequel.require 'adapters/shared/progress'
|
2
|
+
Sequel.require 'adapters/jdbc/transactions'
|
3
|
+
|
4
|
+
module Sequel
|
5
|
+
module JDBC
|
6
|
+
# Database and Dataset instance methods for Progress v9 specific
|
7
|
+
# support via JDBC.
|
8
|
+
module Progress
|
9
|
+
# Database instance methods for Progress databases accessed via JDBC.
|
10
|
+
module DatabaseMethods
|
11
|
+
include Sequel::Progress::DatabaseMethods
|
12
|
+
include Sequel::JDBC::Transactions
|
13
|
+
|
14
|
+
# Progress DatabaseMetaData doesn't even implement supportsSavepoints()
|
15
|
+
def supports_savepoints?
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/sequel/adapters/mock.rb
CHANGED
@@ -22,7 +22,7 @@ module Sequel
|
|
22
22
|
|
23
23
|
# Delegate to the db's #_execute method.
|
24
24
|
def execute(sql)
|
25
|
-
@db.send(:_execute, self, sql)
|
25
|
+
@db.send(:_execute, self, sql, :log=>false)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -200,7 +200,7 @@ module Sequel
|
|
200
200
|
sql += " -- args: #{opts[:arguments].inspect}" if opts[:arguments]
|
201
201
|
sql += " -- #{@opts[:append]}" if @opts[:append]
|
202
202
|
sql += " -- #{c.server.is_a?(Symbol) ? c.server : c.server.inspect}" if c.server != :default
|
203
|
-
log_info(sql)
|
203
|
+
log_info(sql) unless opts[:log] == false
|
204
204
|
@sqls << sql
|
205
205
|
|
206
206
|
ds = opts[:dataset]
|
@@ -298,10 +298,6 @@ module Sequel
|
|
298
298
|
def disconnect_connection(c)
|
299
299
|
end
|
300
300
|
|
301
|
-
def log_connection_execute(c, sql)
|
302
|
-
c.execute(sql)
|
303
|
-
end
|
304
|
-
|
305
301
|
def quote_identifiers_default
|
306
302
|
shared_adapter? ? super : false
|
307
303
|
end
|