sequel 3.34.1 → 3.35.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 +52 -0
- data/README.rdoc +3 -1
- data/Rakefile +2 -10
- data/doc/active_record.rdoc +1 -0
- data/doc/migration.rdoc +18 -7
- data/doc/model_hooks.rdoc +6 -0
- data/doc/opening_databases.rdoc +3 -0
- data/doc/prepared_statements.rdoc +0 -1
- data/doc/release_notes/3.35.0.txt +144 -0
- data/doc/schema_modification.rdoc +16 -1
- data/doc/thread_safety.rdoc +17 -0
- data/lib/sequel/adapters/do.rb +2 -2
- data/lib/sequel/adapters/do/postgres.rb +1 -52
- data/lib/sequel/adapters/do/sqlite.rb +0 -5
- data/lib/sequel/adapters/firebird.rb +1 -1
- data/lib/sequel/adapters/ibmdb.rb +2 -2
- data/lib/sequel/adapters/jdbc.rb +23 -19
- data/lib/sequel/adapters/jdbc/db2.rb +0 -5
- data/lib/sequel/adapters/jdbc/derby.rb +29 -2
- data/lib/sequel/adapters/jdbc/firebird.rb +0 -5
- data/lib/sequel/adapters/jdbc/h2.rb +1 -1
- data/lib/sequel/adapters/jdbc/hsqldb.rb +7 -0
- data/lib/sequel/adapters/jdbc/informix.rb +0 -5
- data/lib/sequel/adapters/jdbc/jtds.rb +0 -5
- data/lib/sequel/adapters/jdbc/mysql.rb +0 -5
- data/lib/sequel/adapters/jdbc/postgresql.rb +4 -35
- data/lib/sequel/adapters/jdbc/sqlite.rb +0 -5
- data/lib/sequel/adapters/jdbc/sqlserver.rb +0 -5
- data/lib/sequel/adapters/jdbc/transactions.rb +4 -4
- data/lib/sequel/adapters/mysql2.rb +1 -1
- data/lib/sequel/adapters/odbc.rb +3 -3
- data/lib/sequel/adapters/odbc/mssql.rb +14 -1
- data/lib/sequel/adapters/oracle.rb +6 -18
- data/lib/sequel/adapters/postgres.rb +36 -53
- data/lib/sequel/adapters/shared/db2.rb +16 -2
- data/lib/sequel/adapters/shared/mssql.rb +40 -9
- data/lib/sequel/adapters/shared/mysql.rb +16 -4
- data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +2 -2
- data/lib/sequel/adapters/shared/oracle.rb +2 -0
- data/lib/sequel/adapters/shared/postgres.rb +135 -211
- data/lib/sequel/adapters/sqlite.rb +2 -2
- data/lib/sequel/adapters/swift.rb +1 -1
- data/lib/sequel/adapters/swift/postgres.rb +1 -71
- data/lib/sequel/adapters/tinytds.rb +3 -3
- data/lib/sequel/core.rb +27 -4
- data/lib/sequel/database/connecting.rb +7 -8
- data/lib/sequel/database/logging.rb +6 -1
- data/lib/sequel/database/misc.rb +20 -4
- data/lib/sequel/database/query.rb +38 -18
- data/lib/sequel/database/schema_generator.rb +5 -2
- data/lib/sequel/database/schema_methods.rb +34 -8
- data/lib/sequel/dataset/prepared_statements.rb +1 -1
- data/lib/sequel/dataset/sql.rb +18 -24
- data/lib/sequel/extensions/core_extensions.rb +0 -23
- data/lib/sequel/extensions/migration.rb +22 -8
- data/lib/sequel/extensions/pg_auto_parameterize.rb +4 -0
- data/lib/sequel/extensions/schema_dumper.rb +1 -1
- data/lib/sequel/model.rb +2 -2
- data/lib/sequel/model/associations.rb +95 -70
- data/lib/sequel/model/base.rb +16 -18
- data/lib/sequel/plugins/dirty.rb +214 -0
- data/lib/sequel/plugins/identity_map.rb +1 -1
- data/lib/sequel/plugins/json_serializer.rb +16 -1
- data/lib/sequel/plugins/many_through_many.rb +22 -32
- data/lib/sequel/plugins/many_to_one_pk_lookup.rb +2 -2
- data/lib/sequel/plugins/prepared_statements.rb +22 -8
- data/lib/sequel/plugins/prepared_statements_associations.rb +2 -3
- data/lib/sequel/plugins/prepared_statements_with_pk.rb +1 -1
- data/lib/sequel/plugins/single_table_inheritance.rb +1 -1
- data/lib/sequel/plugins/subclasses.rb +10 -2
- data/lib/sequel/plugins/timestamps.rb +1 -1
- data/lib/sequel/plugins/xml_serializer.rb +12 -1
- data/lib/sequel/sql.rb +1 -1
- data/lib/sequel/version.rb +2 -2
- data/spec/adapters/postgres_spec.rb +30 -79
- data/spec/core/database_spec.rb +46 -2
- data/spec/core/dataset_spec.rb +28 -22
- data/spec/core/schema_generator_spec.rb +1 -1
- data/spec/core/schema_spec.rb +51 -0
- data/spec/extensions/arbitrary_servers_spec.rb +0 -4
- data/spec/extensions/association_autoreloading_spec.rb +17 -0
- data/spec/extensions/association_proxies_spec.rb +4 -4
- data/spec/extensions/core_extensions_spec.rb +1 -24
- data/spec/extensions/dirty_spec.rb +155 -0
- data/spec/extensions/json_serializer_spec.rb +13 -0
- data/spec/extensions/migration_spec.rb +28 -15
- data/spec/extensions/named_timezones_spec.rb +6 -8
- data/spec/extensions/pg_auto_parameterize_spec.rb +6 -5
- data/spec/extensions/schema_dumper_spec.rb +3 -1
- data/spec/extensions/xml_serializer_spec.rb +13 -0
- data/spec/files/{transactionless_migrations → transaction_specified_migrations}/001_create_alt_basic.rb +1 -1
- data/spec/files/{transactionless_migrations → transaction_specified_migrations}/002_create_basic.rb +0 -0
- data/spec/files/{transaction_migrations → transaction_unspecified_migrations}/001_create_alt_basic.rb +0 -0
- data/spec/files/{transaction_migrations → transaction_unspecified_migrations}/002_create_basic.rb +0 -0
- data/spec/integration/associations_test.rb +5 -7
- data/spec/integration/dataset_test.rb +25 -7
- data/spec/integration/plugin_test.rb +1 -1
- data/spec/integration/schema_test.rb +16 -1
- data/spec/model/associations_spec.rb +2 -2
- metadata +14 -9
- data/lib/sequel/adapters/odbc/db2.rb +0 -17
|
@@ -31,7 +31,7 @@ module Sequel
|
|
|
31
31
|
def execute(sql, opts={})
|
|
32
32
|
begin
|
|
33
33
|
synchronize(opts[:server]) do |conn|
|
|
34
|
-
if conn.transaction_started &&
|
|
34
|
+
if conn.transaction_started && !_trans(conn)
|
|
35
35
|
conn.rollback
|
|
36
36
|
raise DatabaseDisconnectError, "transaction accidently left open, rolling back and disconnecting"
|
|
37
37
|
end
|
|
@@ -227,7 +227,7 @@ module Sequel
|
|
|
227
227
|
# Execute a prepared statement named by name on the database.
|
|
228
228
|
def execute_prepared_statement(ps_name, opts)
|
|
229
229
|
args = opts[:arguments]
|
|
230
|
-
ps =
|
|
230
|
+
ps = prepared_statement(ps_name)
|
|
231
231
|
sql = ps.prepared_sql
|
|
232
232
|
synchronize(opts[:server]) do |conn|
|
|
233
233
|
unless conn.prepared_statements.fetch(ps_name, []).first == sql
|
|
@@ -444,7 +444,7 @@ module Sequel
|
|
|
444
444
|
ps.extend(PreparedStatementMethods)
|
|
445
445
|
if name
|
|
446
446
|
ps.prepared_statement_name = name
|
|
447
|
-
db.
|
|
447
|
+
db.set_prepared_statement(name, ps)
|
|
448
448
|
end
|
|
449
449
|
ps
|
|
450
450
|
end
|
data/lib/sequel/adapters/jdbc.rb
CHANGED
|
@@ -39,14 +39,14 @@ module Sequel
|
|
|
39
39
|
:mysql=>proc do |db|
|
|
40
40
|
Sequel.ts_require 'adapters/jdbc/mysql'
|
|
41
41
|
db.extend(Sequel::JDBC::MySQL::DatabaseMethods)
|
|
42
|
-
db.
|
|
42
|
+
db.extend_datasets Sequel::MySQL::DatasetMethods
|
|
43
43
|
JDBC.load_gem('mysql')
|
|
44
44
|
com.mysql.jdbc.Driver
|
|
45
45
|
end,
|
|
46
46
|
:sqlite=>proc do |db|
|
|
47
47
|
Sequel.ts_require 'adapters/jdbc/sqlite'
|
|
48
48
|
db.extend(Sequel::JDBC::SQLite::DatabaseMethods)
|
|
49
|
-
db.
|
|
49
|
+
db.extend_datasets Sequel::SQLite::DatasetMethods
|
|
50
50
|
db.set_integer_booleans
|
|
51
51
|
JDBC.load_gem('sqlite3')
|
|
52
52
|
org.sqlite.JDBC
|
|
@@ -60,13 +60,13 @@ module Sequel
|
|
|
60
60
|
:sqlserver=>proc do |db|
|
|
61
61
|
Sequel.ts_require 'adapters/jdbc/sqlserver'
|
|
62
62
|
db.extend(Sequel::JDBC::SQLServer::DatabaseMethods)
|
|
63
|
-
db.
|
|
63
|
+
db.extend_datasets Sequel::MSSQL::DatasetMethods
|
|
64
64
|
db.send(:set_mssql_unicode_strings)
|
|
65
65
|
com.microsoft.sqlserver.jdbc.SQLServerDriver
|
|
66
66
|
end,
|
|
67
67
|
:jtds=>proc do |db|
|
|
68
68
|
Sequel.ts_require 'adapters/jdbc/jtds'
|
|
69
|
-
db.extend(Sequel::JDBC::
|
|
69
|
+
db.extend(Sequel::JDBC::MSSQL::DatabaseMethods)
|
|
70
70
|
db.dataset_class = Sequel::JDBC::JTDS::Dataset
|
|
71
71
|
db.send(:set_mssql_unicode_strings)
|
|
72
72
|
JDBC.load_gem('jtds')
|
|
@@ -102,19 +102,19 @@ module Sequel
|
|
|
102
102
|
:"informix-sqli"=>proc do |db|
|
|
103
103
|
Sequel.ts_require 'adapters/jdbc/informix'
|
|
104
104
|
db.extend(Sequel::JDBC::Informix::DatabaseMethods)
|
|
105
|
-
db.
|
|
105
|
+
db.extend_datasets Sequel::Informix::DatasetMethods
|
|
106
106
|
com.informix.jdbc.IfxDriver
|
|
107
107
|
end,
|
|
108
108
|
:db2=>proc do |db|
|
|
109
109
|
Sequel.ts_require 'adapters/jdbc/db2'
|
|
110
110
|
db.extend(Sequel::JDBC::DB2::DatabaseMethods)
|
|
111
|
-
db.
|
|
111
|
+
db.extend_datasets Sequel::DB2::DatasetMethods
|
|
112
112
|
com.ibm.db2.jcc.DB2Driver
|
|
113
113
|
end,
|
|
114
114
|
:firebirdsql=>proc do |db|
|
|
115
115
|
Sequel.ts_require 'adapters/jdbc/firebird'
|
|
116
116
|
db.extend(Sequel::JDBC::Firebird::DatabaseMethods)
|
|
117
|
-
db.
|
|
117
|
+
db.extend_datasets Sequel::Firebird::DatasetMethods
|
|
118
118
|
org.firebirdsql.jdbc.FBDriver
|
|
119
119
|
end
|
|
120
120
|
}
|
|
@@ -151,6 +151,8 @@ module Sequel
|
|
|
151
151
|
# uri, since JDBC requires one.
|
|
152
152
|
def initialize(opts)
|
|
153
153
|
super
|
|
154
|
+
@connection_prepared_statements = {}
|
|
155
|
+
@connection_prepared_statements_mutex = Mutex.new
|
|
154
156
|
@convert_types = typecast_value_boolean(@opts.fetch(:convert_types, true))
|
|
155
157
|
raise(Error, "No connection string specified") unless uri
|
|
156
158
|
|
|
@@ -312,8 +314,15 @@ module Sequel
|
|
|
312
314
|
|
|
313
315
|
private
|
|
314
316
|
|
|
315
|
-
#
|
|
317
|
+
# Yield the native prepared statements hash for the given connection
|
|
318
|
+
# to the block in a thread-safe manner.
|
|
319
|
+
def cps_sync(conn, &block)
|
|
320
|
+
@connection_prepared_statements_mutex.synchronize{yield(@connection_prepared_statements[conn] ||= {})}
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# Close given adapter connections, and delete any related prepared statements.
|
|
316
324
|
def disconnect_connection(c)
|
|
325
|
+
@connection_prepared_statements_mutex.synchronize{@connection_prepared_statements.delete(c)}
|
|
317
326
|
c.close
|
|
318
327
|
end
|
|
319
328
|
|
|
@@ -336,16 +345,16 @@ module Sequel
|
|
|
336
345
|
ps = name
|
|
337
346
|
name = ps.prepared_statement_name
|
|
338
347
|
else
|
|
339
|
-
ps =
|
|
348
|
+
ps = prepared_statement(name)
|
|
340
349
|
end
|
|
341
350
|
sql = ps.prepared_sql
|
|
342
351
|
synchronize(opts[:server]) do |conn|
|
|
343
|
-
if name and cps = conn
|
|
352
|
+
if name and cps = cps_sync(conn){|cpsh| cpsh[name]} and cps[0] == sql
|
|
344
353
|
cps = cps[1]
|
|
345
354
|
else
|
|
346
355
|
log_yield("CLOSE #{name}"){cps[1].close} if cps
|
|
347
356
|
cps = log_yield("PREPARE#{" #{name}:" if name} #{sql}"){conn.prepareStatement(sql)}
|
|
348
|
-
conn
|
|
357
|
+
cps_sync(conn){|cpsh| cpsh[name] = [sql, cps]} if name
|
|
349
358
|
end
|
|
350
359
|
i = 0
|
|
351
360
|
args.each{|arg| set_ps_arg(cps, arg, i+=1)}
|
|
@@ -476,14 +485,9 @@ module Sequel
|
|
|
476
485
|
end
|
|
477
486
|
end
|
|
478
487
|
|
|
479
|
-
#
|
|
480
|
-
#
|
|
481
|
-
# adapter specific prepared statements.
|
|
488
|
+
# Return the connection. Used to do configuration on the
|
|
489
|
+
# connection object before adding it to the connection pool.
|
|
482
490
|
def setup_connection(conn)
|
|
483
|
-
class << conn
|
|
484
|
-
attr_accessor :prepared_statements
|
|
485
|
-
end
|
|
486
|
-
conn.prepared_statements = {}
|
|
487
491
|
conn
|
|
488
492
|
end
|
|
489
493
|
|
|
@@ -608,7 +612,7 @@ module Sequel
|
|
|
608
612
|
ps.extend(PreparedStatementMethods)
|
|
609
613
|
if name
|
|
610
614
|
ps.prepared_statement_name = name
|
|
611
|
-
db.
|
|
615
|
+
db.set_prepared_statement(name, ps)
|
|
612
616
|
end
|
|
613
617
|
ps
|
|
614
618
|
end
|
|
@@ -37,6 +37,11 @@ module Sequel
|
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
+
# Derby supports transaction DDL statements.
|
|
41
|
+
def supports_transactional_ddl?
|
|
42
|
+
true
|
|
43
|
+
end
|
|
44
|
+
|
|
40
45
|
private
|
|
41
46
|
|
|
42
47
|
# Derby optimizes away Sequel's default check of SELECT NULL FROM table,
|
|
@@ -70,10 +75,30 @@ module Sequel
|
|
|
70
75
|
sql << " NOT NULL" if column.fetch(:null, column[:allow_null]) == false
|
|
71
76
|
end
|
|
72
77
|
|
|
73
|
-
#
|
|
78
|
+
# Add NOT LOGGED for temporary tables to improve performance.
|
|
74
79
|
def create_table_sql(name, generator, options)
|
|
80
|
+
s = super
|
|
81
|
+
s << ' NOT LOGGED' if options[:temp]
|
|
82
|
+
s
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Insert data from the current table into the new table after
|
|
86
|
+
# creating the table, since it is not possible to do it in one step.
|
|
87
|
+
def create_table_as(name, sql, options)
|
|
88
|
+
super
|
|
89
|
+
from(name).insert(sql.is_a?(Dataset) ? sql : dataset.with_sql(sql))
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Derby currently only requires WITH NO DATA, with a separate insert
|
|
93
|
+
# to import data.
|
|
94
|
+
def create_table_as_sql(name, sql, options)
|
|
95
|
+
"#{create_table_prefix_sql(name, options)} AS #{sql} WITH NO DATA"
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Temporary table creation on Derby uses DECLARE instead of CREATE.
|
|
99
|
+
def create_table_prefix_sql(name, options)
|
|
75
100
|
if options[:temp]
|
|
76
|
-
"DECLARE GLOBAL TEMPORARY TABLE #{quote_identifier(name)}
|
|
101
|
+
"DECLARE GLOBAL TEMPORARY TABLE #{quote_identifier(name)}"
|
|
77
102
|
else
|
|
78
103
|
super
|
|
79
104
|
end
|
|
@@ -167,6 +192,8 @@ module Sequel
|
|
|
167
192
|
super(sql, :LIKE, [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1))])
|
|
168
193
|
when :"NOT ILIKE"
|
|
169
194
|
super(sql, :"NOT LIKE", [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1))])
|
|
195
|
+
when :%
|
|
196
|
+
sql << complex_expression_arg_pairs(args){|a, b| "MOD(#{literal(a)}, #{literal(b)})"}
|
|
170
197
|
when :&, :|, :^, :<<, :>>
|
|
171
198
|
raise Error, "Derby doesn't support the #{op} operator"
|
|
172
199
|
when :'B~'
|
|
@@ -48,7 +48,7 @@ module Sequel
|
|
|
48
48
|
# If the :prepare option is given and we aren't in a savepoint,
|
|
49
49
|
# prepare the transaction for a two-phase commit.
|
|
50
50
|
def commit_transaction(conn, opts={})
|
|
51
|
-
if (s = opts[:prepare]) &&
|
|
51
|
+
if (s = opts[:prepare]) && _trans(conn)[:savepoint_level] <= 1
|
|
52
52
|
log_connection_execute(conn, "PREPARE COMMIT #{s}")
|
|
53
53
|
else
|
|
54
54
|
super
|
|
@@ -47,6 +47,11 @@ module Sequel
|
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
+
# HSQLDB requires parens around the SELECT, and the WITH DATA syntax.
|
|
51
|
+
def create_table_as_sql(name, sql, options)
|
|
52
|
+
"#{create_table_prefix_sql(name, options)} AS (#{sql}) WITH DATA"
|
|
53
|
+
end
|
|
54
|
+
|
|
50
55
|
# Use IDENTITY() to get the last inserted id.
|
|
51
56
|
def last_insert_id(conn, opts={})
|
|
52
57
|
statement(conn) do |stmt|
|
|
@@ -112,6 +117,8 @@ module Sequel
|
|
|
112
117
|
sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} * POWER(2, #{literal(b)}))"}
|
|
113
118
|
when :>>
|
|
114
119
|
sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} / POWER(2, #{literal(b)}))"}
|
|
120
|
+
when :%
|
|
121
|
+
sql << complex_expression_arg_pairs(args){|a, b| "MOD(#{literal(a)}, #{literal(b)})"}
|
|
115
122
|
when :'B~'
|
|
116
123
|
sql << BITCOMP_OPEN
|
|
117
124
|
literal_append(sql, args.at(0))
|
|
@@ -5,11 +5,6 @@ module Sequel
|
|
|
5
5
|
# Database and Dataset instance methods for JTDS specific
|
|
6
6
|
# support via JDBC.
|
|
7
7
|
module JTDS
|
|
8
|
-
# Database instance methods for JTDS databases accessed via JDBC.
|
|
9
|
-
module DatabaseMethods
|
|
10
|
-
include Sequel::JDBC::MSSQL::DatabaseMethods
|
|
11
|
-
end
|
|
12
|
-
|
|
13
8
|
# Dataset class for JTDS datasets accessed via JDBC.
|
|
14
9
|
class Dataset < JDBC::Dataset
|
|
15
10
|
include Sequel::MSSQL::DatasetMethods
|
|
@@ -7,32 +7,6 @@ module Sequel
|
|
|
7
7
|
# Adapter, Database, and Dataset support for accessing a PostgreSQL
|
|
8
8
|
# database via JDBC.
|
|
9
9
|
module Postgres
|
|
10
|
-
# Methods to add to the JDBC adapter/connection to allow it to work
|
|
11
|
-
# with the shared PostgreSQL code.
|
|
12
|
-
module AdapterMethods
|
|
13
|
-
include Sequel::Postgres::AdapterMethods
|
|
14
|
-
|
|
15
|
-
# Give the JDBC adapter a direct execute method, which creates
|
|
16
|
-
# a statement with the given sql and executes it.
|
|
17
|
-
def execute(sql, args=nil)
|
|
18
|
-
method = block_given? ? :executeQuery : :execute
|
|
19
|
-
@db.send(:statement, self) do |stmt|
|
|
20
|
-
rows = @db.log_yield(sql){stmt.send(method, sql)}
|
|
21
|
-
yield(rows) if block_given?
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
# JDBC specific method of getting specific values from a result set.
|
|
28
|
-
def single_value(r)
|
|
29
|
-
unless r.nil?
|
|
30
|
-
r.next
|
|
31
|
-
r.getString(1) unless r.getRow == 0
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
10
|
# Methods to add to Database instances that access PostgreSQL via
|
|
37
11
|
# JDBC.
|
|
38
12
|
module DatabaseMethods
|
|
@@ -55,19 +29,14 @@ module Sequel
|
|
|
55
29
|
arg.nil? ? cps.setNull(i, JavaSQL::Types::NULL) : super
|
|
56
30
|
end
|
|
57
31
|
|
|
58
|
-
#
|
|
32
|
+
# Execute the connection configuration SQL queries on the connection.
|
|
59
33
|
def setup_connection(conn)
|
|
60
34
|
conn = super(conn)
|
|
61
|
-
conn
|
|
62
|
-
|
|
63
|
-
|
|
35
|
+
statement(conn) do |stmt|
|
|
36
|
+
connection_configuration_sqls.each{|sql| log_yield(sql){stmt.execute(sql)}}
|
|
37
|
+
end
|
|
64
38
|
conn
|
|
65
39
|
end
|
|
66
|
-
|
|
67
|
-
# Call insert_result with the table and values specified in the opts.
|
|
68
|
-
def last_insert_id(conn, opts)
|
|
69
|
-
insert_result(conn, opts[:table], opts[:values])
|
|
70
|
-
end
|
|
71
40
|
end
|
|
72
41
|
|
|
73
42
|
# Dataset subclass used for datasets that connect to PostgreSQL via JDBC.
|
|
@@ -24,7 +24,7 @@ module Sequel
|
|
|
24
24
|
# Use JDBC connection's setAutoCommit to false to start transactions
|
|
25
25
|
def begin_transaction(conn, opts={})
|
|
26
26
|
if supports_savepoints?
|
|
27
|
-
th =
|
|
27
|
+
th = _trans(conn)
|
|
28
28
|
if sps = th[:savepoints]
|
|
29
29
|
sps << log_yield(TRANSACTION_SAVEPOINT){conn.set_savepoint}
|
|
30
30
|
else
|
|
@@ -40,7 +40,7 @@ module Sequel
|
|
|
40
40
|
# Use JDBC connection's commit method to commit transactions
|
|
41
41
|
def commit_transaction(conn, opts={})
|
|
42
42
|
if supports_savepoints?
|
|
43
|
-
sps =
|
|
43
|
+
sps = _trans(conn)[:savepoints]
|
|
44
44
|
if sps.empty?
|
|
45
45
|
log_yield(TRANSACTION_COMMIT){conn.commit}
|
|
46
46
|
elsif supports_releasing_savepoints?
|
|
@@ -54,7 +54,7 @@ module Sequel
|
|
|
54
54
|
# Use JDBC connection's setAutoCommit to true to enable non-transactional behavior
|
|
55
55
|
def remove_transaction(conn, committed)
|
|
56
56
|
if supports_savepoints?
|
|
57
|
-
sps =
|
|
57
|
+
sps = _trans(conn)[:savepoints]
|
|
58
58
|
conn.setAutoCommit(true) if sps.empty?
|
|
59
59
|
sps.pop
|
|
60
60
|
else
|
|
@@ -67,7 +67,7 @@ module Sequel
|
|
|
67
67
|
# Use JDBC connection's rollback method to rollback transactions
|
|
68
68
|
def rollback_transaction(conn, opts={})
|
|
69
69
|
if supports_savepoints?
|
|
70
|
-
sps =
|
|
70
|
+
sps = _trans(conn)[:savepoints]
|
|
71
71
|
if sps.empty?
|
|
72
72
|
log_yield(TRANSACTION_ROLLBACK){conn.rollback}
|
|
73
73
|
else
|
data/lib/sequel/adapters/odbc.rb
CHANGED
|
@@ -22,9 +22,9 @@ module Sequel
|
|
|
22
22
|
extend Sequel::Progress::DatabaseMethods
|
|
23
23
|
extend_datasets(Sequel::Progress::DatasetMethods)
|
|
24
24
|
when 'db2'
|
|
25
|
-
Sequel.ts_require 'adapters/
|
|
26
|
-
extend Sequel::
|
|
27
|
-
|
|
25
|
+
Sequel.ts_require 'adapters/shared/db2'
|
|
26
|
+
extend ::Sequel::DB2::DatabaseMethods
|
|
27
|
+
extend_datasets ::Sequel::DB2::DatasetMethods
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|