sequel 4.34.0 → 4.35.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +30 -0
- data/Rakefile +14 -17
- data/doc/object_model.rdoc +4 -4
- data/doc/release_notes/4.35.0.txt +130 -0
- data/doc/schema_modification.rdoc +8 -3
- data/doc/security.rdoc +3 -3
- data/lib/sequel/adapters/ado.rb +2 -2
- data/lib/sequel/adapters/ado/access.rb +6 -6
- data/lib/sequel/adapters/ado/mssql.rb +2 -2
- data/lib/sequel/adapters/amalgalite.rb +6 -6
- data/lib/sequel/adapters/cubrid.rb +4 -4
- data/lib/sequel/adapters/do.rb +2 -2
- data/lib/sequel/adapters/do/mysql.rb +1 -1
- data/lib/sequel/adapters/do/postgres.rb +1 -1
- data/lib/sequel/adapters/do/sqlite3.rb +1 -1
- data/lib/sequel/adapters/ibmdb.rb +6 -6
- data/lib/sequel/adapters/jdbc.rb +15 -15
- data/lib/sequel/adapters/jdbc/db2.rb +1 -1
- data/lib/sequel/adapters/jdbc/derby.rb +3 -3
- data/lib/sequel/adapters/jdbc/h2.rb +3 -3
- data/lib/sequel/adapters/jdbc/hsqldb.rb +2 -2
- data/lib/sequel/adapters/jdbc/mssql.rb +1 -1
- data/lib/sequel/adapters/jdbc/mysql.rb +1 -1
- data/lib/sequel/adapters/jdbc/oracle.rb +1 -1
- data/lib/sequel/adapters/jdbc/postgresql.rb +2 -2
- data/lib/sequel/adapters/jdbc/sqlanywhere.rb +1 -1
- data/lib/sequel/adapters/jdbc/sqlite.rb +1 -1
- data/lib/sequel/adapters/jdbc/transactions.rb +10 -10
- data/lib/sequel/adapters/mock.rb +1 -1
- data/lib/sequel/adapters/mysql.rb +2 -2
- data/lib/sequel/adapters/mysql2.rb +2 -2
- data/lib/sequel/adapters/odbc.rb +2 -2
- data/lib/sequel/adapters/odbc/mssql.rb +2 -2
- data/lib/sequel/adapters/oracle.rb +9 -9
- data/lib/sequel/adapters/postgres.rb +3 -3
- data/lib/sequel/adapters/shared/mssql.rb +36 -8
- data/lib/sequel/adapters/shared/oracle.rb +15 -0
- data/lib/sequel/adapters/shared/postgres.rb +22 -1
- data/lib/sequel/adapters/sqlanywhere.rb +1 -1
- data/lib/sequel/adapters/sqlite.rb +7 -7
- data/lib/sequel/adapters/swift.rb +3 -3
- data/lib/sequel/adapters/swift/mysql.rb +1 -1
- data/lib/sequel/adapters/swift/postgres.rb +1 -1
- data/lib/sequel/adapters/swift/sqlite.rb +1 -1
- data/lib/sequel/adapters/tinytds.rb +5 -7
- data/lib/sequel/database/logging.rb +18 -3
- data/lib/sequel/database/misc.rb +19 -8
- data/lib/sequel/database/schema_generator.rb +7 -2
- data/lib/sequel/database/schema_methods.rb +9 -2
- data/lib/sequel/database/transactions.rb +52 -18
- data/lib/sequel/dataset/actions.rb +24 -19
- data/lib/sequel/dataset/features.rb +5 -0
- data/lib/sequel/dataset/query.rb +6 -0
- data/lib/sequel/extensions/_pretty_table.rb +1 -1
- data/lib/sequel/extensions/error_sql.rb +3 -3
- data/lib/sequel/extensions/pg_range.rb +10 -1
- data/lib/sequel/extensions/schema_dumper.rb +8 -5
- data/lib/sequel/extensions/server_logging.rb +61 -0
- data/lib/sequel/extensions/sql_comments.rb +91 -0
- data/lib/sequel/model/associations.rb +40 -8
- data/lib/sequel/model/base.rb +19 -5
- data/lib/sequel/plugins/class_table_inheritance.rb +12 -0
- data/lib/sequel/plugins/delay_add_association.rb +1 -0
- data/lib/sequel/plugins/json_serializer.rb +10 -2
- data/lib/sequel/version.rb +1 -1
- data/spec/adapter_spec.rb +4 -0
- data/spec/adapters/mysql_spec.rb +1 -1
- data/spec/adapters/postgres_spec.rb +3 -2
- data/spec/core/connection_pool_spec.rb +2 -0
- data/spec/core/database_spec.rb +49 -0
- data/spec/core/dataset_spec.rb +25 -1
- data/spec/core/mock_adapter_spec.rb +3 -1
- data/spec/core/schema_generator_spec.rb +1 -1
- data/spec/core_model_spec.rb +2 -0
- data/spec/core_spec.rb +1 -0
- data/spec/extensions/delay_add_association_spec.rb +22 -0
- data/spec/extensions/json_serializer_spec.rb +6 -0
- data/spec/extensions/pg_range_spec.rb +30 -2
- data/spec/extensions/schema_dumper_spec.rb +3 -2
- data/spec/extensions/server_logging_spec.rb +45 -0
- data/spec/extensions/sql_comments_spec.rb +27 -0
- data/spec/files/reversible_migrations/006_reversible.rb +10 -0
- data/spec/files/reversible_migrations/007_reversible.rb +10 -0
- data/spec/integration/dataset_test.rb +28 -2
- data/spec/integration/migrator_test.rb +23 -1
- data/spec/integration/schema_test.rb +12 -32
- data/spec/integration/transaction_test.rb +10 -0
- data/spec/integration/type_test.rb +1 -1
- data/spec/model/eager_loading_spec.rb +16 -0
- data/spec/model/record_spec.rb +9 -0
- data/spec/model_no_assoc_spec.rb +1 -0
- data/spec/model_spec.rb +1 -0
- data/spec/plugin_spec.rb +1 -0
- metadata +16 -2
data/lib/sequel/adapters/do.rb
CHANGED
@@ -52,7 +52,7 @@ module Sequel
|
|
52
52
|
synchronize(opts[:server]) do |conn|
|
53
53
|
begin
|
54
54
|
command = conn.create_command(sql)
|
55
|
-
res =
|
55
|
+
res = log_connection_yield(sql, conn){block_given? ? command.execute_reader : command.execute_non_query}
|
56
56
|
rescue ::DataObjects::Error => e
|
57
57
|
raise_error(e)
|
58
58
|
end
|
@@ -126,7 +126,7 @@ module Sequel
|
|
126
126
|
|
127
127
|
# Execute SQL on the connection by creating a command first
|
128
128
|
def log_connection_execute(conn, sql)
|
129
|
-
|
129
|
+
log_connection_yield(sql, conn){conn.create_command(sql).execute_non_query}
|
130
130
|
end
|
131
131
|
|
132
132
|
# Allow extending the given connection when it is first created.
|
@@ -36,7 +36,7 @@ module Sequel
|
|
36
36
|
|
37
37
|
# Apply the connectiong setting SQLs for every new connection.
|
38
38
|
def setup_connection(conn)
|
39
|
-
mysql_connection_setting_sqls.each{|sql|
|
39
|
+
mysql_connection_setting_sqls.each{|sql| log_connection_yield(sql, conn){conn.create_command(sql).execute_non_query}}
|
40
40
|
super
|
41
41
|
end
|
42
42
|
end
|
@@ -35,7 +35,7 @@ module Sequel
|
|
35
35
|
# Extend the adapter with the DataObjects PostgreSQL AdapterMethods
|
36
36
|
def setup_connection(conn)
|
37
37
|
conn = super(conn)
|
38
|
-
connection_configuration_sqls.each{|sql|
|
38
|
+
connection_configuration_sqls.each{|sql| log_connection_yield(sql, conn){conn.create_command(sql).execute_non_query}}
|
39
39
|
conn
|
40
40
|
end
|
41
41
|
end
|
@@ -242,7 +242,7 @@ module Sequel
|
|
242
242
|
sql = ps.prepared_sql
|
243
243
|
synchronize(opts[:server]) do |conn|
|
244
244
|
unless conn.prepared_statements.fetch(ps_name, []).first == sql
|
245
|
-
|
245
|
+
log_connection_yield("PREPARE #{ps_name}: #{sql}", conn){conn.prepare(sql, ps_name)}
|
246
246
|
end
|
247
247
|
args = args.map{|v| v.nil? ? nil : prepared_statement_arg(v)}
|
248
248
|
log_sql = "EXECUTE #{ps_name}"
|
@@ -252,7 +252,7 @@ module Sequel
|
|
252
252
|
log_sql << ")"
|
253
253
|
end
|
254
254
|
begin
|
255
|
-
stmt =
|
255
|
+
stmt = log_connection_yield(log_sql, conn, args){conn.execute_prepared(ps_name, *args)}
|
256
256
|
if block_given?
|
257
257
|
yield(stmt)
|
258
258
|
else
|
@@ -268,7 +268,7 @@ module Sequel
|
|
268
268
|
|
269
269
|
# Execute the given SQL on the database.
|
270
270
|
def _execute(conn, sql, opts)
|
271
|
-
stmt =
|
271
|
+
stmt = log_connection_yield(sql, conn){conn.execute(sql)}
|
272
272
|
if block_given?
|
273
273
|
yield(stmt)
|
274
274
|
else
|
@@ -286,14 +286,14 @@ module Sequel
|
|
286
286
|
# IBM_DB uses an autocommit setting instead of sending SQL queries.
|
287
287
|
# So starting a transaction just turns autocommit off.
|
288
288
|
def begin_transaction(conn, opts=OPTS)
|
289
|
-
|
289
|
+
log_connection_yield(TRANSACTION_BEGIN, conn){conn.autocommit = false}
|
290
290
|
set_transaction_isolation(conn, opts)
|
291
291
|
end
|
292
292
|
|
293
293
|
# This commits transaction in progress on the
|
294
294
|
# connection and sets autocommit back on.
|
295
295
|
def commit_transaction(conn, opts=OPTS)
|
296
|
-
|
296
|
+
log_connection_yield(TRANSACTION_COMMIT, conn){conn.commit}
|
297
297
|
end
|
298
298
|
|
299
299
|
def database_error_classes
|
@@ -337,7 +337,7 @@ module Sequel
|
|
337
337
|
# This rolls back the transaction in progress on the
|
338
338
|
# connection and sets autocommit back on.
|
339
339
|
def rollback_transaction(conn, opts=OPTS)
|
340
|
-
|
340
|
+
log_connection_yield(TRANSACTION_ROLLBACK, conn){conn.rollback}
|
341
341
|
end
|
342
342
|
|
343
343
|
# Convert smallint type to boolean if convert_smallint_to_bool is true
|
data/lib/sequel/adapters/jdbc.rb
CHANGED
@@ -178,14 +178,14 @@ module Sequel
|
|
178
178
|
|
179
179
|
begin
|
180
180
|
if block_given?
|
181
|
-
yield
|
181
|
+
yield log_connection_yield(sql, conn){cps.executeQuery}
|
182
182
|
else
|
183
183
|
case opts[:type]
|
184
184
|
when :insert
|
185
|
-
|
185
|
+
log_connection_yield(sql, conn){cps.executeUpdate}
|
186
186
|
last_insert_id(conn, opts)
|
187
187
|
else
|
188
|
-
|
188
|
+
log_connection_yield(sql, conn){cps.executeUpdate}
|
189
189
|
end
|
190
190
|
end
|
191
191
|
rescue NativeException, JavaSQL::SQLException => e
|
@@ -250,16 +250,16 @@ module Sequel
|
|
250
250
|
if size = fetch_size
|
251
251
|
stmt.setFetchSize(size)
|
252
252
|
end
|
253
|
-
yield
|
253
|
+
yield log_connection_yield(sql, conn){stmt.executeQuery(sql)}
|
254
254
|
else
|
255
255
|
case opts[:type]
|
256
256
|
when :ddl
|
257
|
-
|
257
|
+
log_connection_yield(sql, conn){stmt.execute(sql)}
|
258
258
|
when :insert
|
259
|
-
|
259
|
+
log_connection_yield(sql, conn){execute_statement_insert(stmt, sql)}
|
260
260
|
last_insert_id(conn, Hash[opts].merge!(:stmt=>stmt))
|
261
261
|
else
|
262
|
-
|
262
|
+
log_connection_yield(sql, conn){stmt.executeUpdate(sql)}
|
263
263
|
end
|
264
264
|
end
|
265
265
|
end
|
@@ -418,8 +418,8 @@ module Sequel
|
|
418
418
|
if name and cps = cps_sync(conn){|cpsh| cpsh[name]} and cps[0] == sql
|
419
419
|
cps = cps[1]
|
420
420
|
else
|
421
|
-
|
422
|
-
cps =
|
421
|
+
log_connection_yield("CLOSE #{name}", conn){cps[1].close} if cps
|
422
|
+
cps = log_connection_yield("PREPARE#{" #{name}:" if name} #{sql}", conn){prepare_jdbc_statement(conn, sql, opts)}
|
423
423
|
if size = fetch_size
|
424
424
|
cps.setFetchSize(size)
|
425
425
|
end
|
@@ -429,22 +429,22 @@ module Sequel
|
|
429
429
|
args.each{|arg| set_ps_arg(cps, arg, i+=1)}
|
430
430
|
msg = "EXECUTE#{" #{name}" if name}"
|
431
431
|
if ps.log_sql
|
432
|
-
msg
|
432
|
+
msg += " ("
|
433
433
|
msg << sql
|
434
434
|
msg << ")"
|
435
435
|
end
|
436
436
|
begin
|
437
437
|
if block_given?
|
438
|
-
yield
|
438
|
+
yield log_connection_yield(msg, conn, args){cps.executeQuery}
|
439
439
|
else
|
440
440
|
case opts[:type]
|
441
441
|
when :ddl
|
442
|
-
|
442
|
+
log_connection_yield(msg, conn, args){cps.execute}
|
443
443
|
when :insert
|
444
|
-
|
444
|
+
log_connection_yield(msg, conn, args){execute_prepared_statement_insert(cps)}
|
445
445
|
last_insert_id(conn, Hash[opts].merge!(:prepared=>true, :stmt=>cps))
|
446
446
|
else
|
447
|
-
|
447
|
+
log_connection_yield(msg, conn, args){cps.executeUpdate}
|
448
448
|
end
|
449
449
|
end
|
450
450
|
rescue NativeException, JavaSQL::SQLException => e
|
@@ -519,7 +519,7 @@ module Sequel
|
|
519
519
|
# Log the given SQL and then execute it on the connection, used by
|
520
520
|
# the transaction code.
|
521
521
|
def log_connection_execute(conn, sql)
|
522
|
-
statement(conn){|s|
|
522
|
+
statement(conn){|s| log_connection_yield(sql, conn){s.execute(sql)}}
|
523
523
|
end
|
524
524
|
|
525
525
|
# By default, there is no support for determining the last inserted
|
@@ -90,7 +90,7 @@ module Sequel
|
|
90
90
|
# Add NOT LOGGED for temporary tables to improve performance.
|
91
91
|
def create_table_sql(name, generator, options)
|
92
92
|
s = super
|
93
|
-
s
|
93
|
+
s += ' NOT LOGGED' if options[:temp]
|
94
94
|
s
|
95
95
|
end
|
96
96
|
|
@@ -131,7 +131,7 @@ module Sequel
|
|
131
131
|
def last_insert_id(conn, opts=OPTS)
|
132
132
|
statement(conn) do |stmt|
|
133
133
|
sql = 'SELECT IDENTITY_VAL_LOCAL() FROM sysibm.sysdummy1'
|
134
|
-
rs =
|
134
|
+
rs = log_connection_yield(sql, conn){stmt.executeQuery(sql)}
|
135
135
|
rs.next
|
136
136
|
rs.getLong(1)
|
137
137
|
end
|
@@ -157,7 +157,7 @@ module Sequel
|
|
157
157
|
if column[:identity]
|
158
158
|
sql = "#{super} GENERATED BY DEFAULT AS IDENTITY"
|
159
159
|
if sw = column[:start_with]
|
160
|
-
sql
|
160
|
+
sql += " (START WITH #{sw.to_i}"
|
161
161
|
sql << " INCREMENT BY #{column[:increment_by].to_i}" if column[:increment_by]
|
162
162
|
sql << ")"
|
163
163
|
end
|
@@ -95,7 +95,7 @@ module Sequel
|
|
95
95
|
op = cs.merge!(op)
|
96
96
|
end
|
97
97
|
end
|
98
|
-
sql = "ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(op)}"
|
98
|
+
sql = "ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(op)}".dup
|
99
99
|
column_definition_order.each{|m| send(:"column_definition_#{m}_sql", sql, op)}
|
100
100
|
sql
|
101
101
|
when :drop_constraint
|
@@ -130,7 +130,7 @@ module Sequel
|
|
130
130
|
def last_insert_id(conn, opts=OPTS)
|
131
131
|
statement(conn) do |stmt|
|
132
132
|
sql = 'SELECT IDENTITY();'
|
133
|
-
rs =
|
133
|
+
rs = log_connection_yield(sql, conn){stmt.executeQuery(sql)}
|
134
134
|
rs.next
|
135
135
|
rs.getLong(1)
|
136
136
|
end
|
@@ -146,7 +146,7 @@ module Sequel
|
|
146
146
|
end
|
147
147
|
|
148
148
|
# Use BIGINT IDENTITY for identity columns that use bigint, fixes
|
149
|
-
# the case where primary_key :column, :type
|
149
|
+
# the case where primary_key :column, :type=>:Bignum is used.
|
150
150
|
def type_literal_generic_bignum(column)
|
151
151
|
column[:identity] ? 'BIGINT IDENTITY' : super
|
152
152
|
end
|
@@ -101,7 +101,7 @@ module Sequel
|
|
101
101
|
def last_insert_id(conn, opts=OPTS)
|
102
102
|
statement(conn) do |stmt|
|
103
103
|
sql = 'CALL IDENTITY()'
|
104
|
-
rs =
|
104
|
+
rs = log_connection_yield(sql, conn){stmt.executeQuery(sql)}
|
105
105
|
rs.next
|
106
106
|
rs.getLong(1)
|
107
107
|
end
|
@@ -119,7 +119,7 @@ module Sequel
|
|
119
119
|
if column[:identity]
|
120
120
|
sql = "#{super} GENERATED BY DEFAULT AS IDENTITY"
|
121
121
|
if sw = column[:start_with]
|
122
|
-
sql
|
122
|
+
sql += " (START WITH #{sw.to_i}"
|
123
123
|
sql << " INCREMENT BY #{column[:increment_by].to_i}" if column[:increment_by]
|
124
124
|
sql << ")"
|
125
125
|
end
|
@@ -22,7 +22,7 @@ module Sequel
|
|
22
22
|
def last_insert_id(conn, opts=OPTS)
|
23
23
|
statement(conn) do |stmt|
|
24
24
|
sql = opts[:prepared] ? ATAT_IDENTITY : SCOPE_IDENTITY
|
25
|
-
rs =
|
25
|
+
rs = log_connection_yield(sql, conn){stmt.executeQuery(sql)}
|
26
26
|
rs.next
|
27
27
|
rs.getLong(1)
|
28
28
|
end
|
@@ -83,7 +83,7 @@ module Sequel
|
|
83
83
|
# Run the default connection setting SQL statements.
|
84
84
|
# Apply the connectiong setting SQLs for every new connection.
|
85
85
|
def setup_connection(conn)
|
86
|
-
mysql_connection_setting_sqls.each{|sql| statement(conn){|s|
|
86
|
+
mysql_connection_setting_sqls.each{|sql| statement(conn){|s| log_connection_yield(sql, conn){s.execute(sql)}}}
|
87
87
|
super
|
88
88
|
end
|
89
89
|
end
|
@@ -72,7 +72,7 @@ module Sequel
|
|
72
72
|
sql = "SELECT #{literal(sequence)}.currval FROM dual"
|
73
73
|
statement(conn) do |stmt|
|
74
74
|
begin
|
75
|
-
rs =
|
75
|
+
rs = log_connection_yield(sql, conn){stmt.executeQuery(sql)}
|
76
76
|
rs.next
|
77
77
|
rs.getLong(1)
|
78
78
|
rescue java.sql.SQLException
|
@@ -100,7 +100,7 @@ module Sequel
|
|
100
100
|
end
|
101
101
|
nil
|
102
102
|
else
|
103
|
-
b =
|
103
|
+
b = String.new
|
104
104
|
while buf = copier.readFromCopy
|
105
105
|
b << String.from_java_bytes(buf)
|
106
106
|
end
|
@@ -171,7 +171,7 @@ module Sequel
|
|
171
171
|
def setup_connection(conn)
|
172
172
|
conn = super(conn)
|
173
173
|
statement(conn) do |stmt|
|
174
|
-
connection_configuration_sqls.each{|sql|
|
174
|
+
connection_configuration_sqls.each{|sql| log_connection_yield(sql, conn){stmt.execute(sql)}}
|
175
175
|
end
|
176
176
|
conn
|
177
177
|
end
|
@@ -36,7 +36,7 @@ module Sequel
|
|
36
36
|
if (jdbc_level = JDBC_TRANSACTION_ISOLATION_LEVELS[level]) &&
|
37
37
|
conn.getMetaData.supportsTransactionIsolationLevel(jdbc_level)
|
38
38
|
_trans(conn)[:original_jdbc_isolation_level] = conn.getTransactionIsolation
|
39
|
-
|
39
|
+
log_connection_yield("Transaction.isolation_level = #{level}", conn){conn.setTransactionIsolation(jdbc_level)}
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -50,14 +50,14 @@ module Sequel
|
|
50
50
|
if supports_savepoints?
|
51
51
|
th = _trans(conn)
|
52
52
|
if sps = th[:savepoint_objs]
|
53
|
-
sps <<
|
53
|
+
sps << log_connection_yield(TRANSACTION_SAVEPOINT, conn){conn.set_savepoint}
|
54
54
|
else
|
55
|
-
|
55
|
+
log_connection_yield(TRANSACTION_BEGIN, conn){conn.setAutoCommit(false)}
|
56
56
|
th[:savepoint_objs] = []
|
57
57
|
set_transaction_isolation(conn, opts)
|
58
58
|
end
|
59
59
|
else
|
60
|
-
|
60
|
+
log_connection_yield(TRANSACTION_BEGIN, conn){conn.setAutoCommit(false)}
|
61
61
|
set_transaction_isolation(conn, opts)
|
62
62
|
end
|
63
63
|
end
|
@@ -67,12 +67,12 @@ module Sequel
|
|
67
67
|
if supports_savepoints?
|
68
68
|
sps = _trans(conn)[:savepoint_objs]
|
69
69
|
if sps.empty?
|
70
|
-
|
70
|
+
log_connection_yield(TRANSACTION_COMMIT, conn){conn.commit}
|
71
71
|
elsif supports_releasing_savepoints?
|
72
|
-
|
72
|
+
log_connection_yield(TRANSACTION_RELEASE_SP, conn){supports_releasing_savepoints? ? conn.release_savepoint(sps.last) : sps.last}
|
73
73
|
end
|
74
74
|
else
|
75
|
-
|
75
|
+
log_connection_yield(TRANSACTION_COMMIT, conn){conn.commit}
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -97,12 +97,12 @@ module Sequel
|
|
97
97
|
if supports_savepoints?
|
98
98
|
sps = _trans(conn)[:savepoint_objs]
|
99
99
|
if sps.empty?
|
100
|
-
|
100
|
+
log_connection_yield(TRANSACTION_ROLLBACK, conn){conn.rollback}
|
101
101
|
else
|
102
|
-
|
102
|
+
log_connection_yield(TRANSACTION_ROLLBACK_SP, conn){conn.rollback(sps.last)}
|
103
103
|
end
|
104
104
|
else
|
105
|
-
|
105
|
+
log_connection_yield(TRANSACTION_ROLLBACK, conn){conn.rollback}
|
106
106
|
end
|
107
107
|
end
|
108
108
|
end
|
data/lib/sequel/adapters/mock.rb
CHANGED
@@ -204,7 +204,7 @@ module Sequel
|
|
204
204
|
sql += " -- args: #{opts[:arguments].inspect}" if opts[:arguments]
|
205
205
|
sql += " -- #{@opts[:append]}" if @opts[:append]
|
206
206
|
sql += " -- #{c.server.is_a?(Symbol) ? c.server : c.server.inspect}" if c.server != :default
|
207
|
-
|
207
|
+
log_connection_yield(sql, c){} unless opts[:log] == false
|
208
208
|
@sqls << sql
|
209
209
|
|
210
210
|
ds = opts[:dataset]
|
@@ -118,7 +118,7 @@ module Sequel
|
|
118
118
|
# that feature.
|
119
119
|
sqls.unshift("SET NAMES #{literal(encoding.to_s)}") if encoding
|
120
120
|
|
121
|
-
sqls.each{|sql|
|
121
|
+
sqls.each{|sql| log_connection_yield(sql, conn){conn.query(sql)}}
|
122
122
|
|
123
123
|
add_prepared_statements_cache(conn)
|
124
124
|
conn
|
@@ -174,7 +174,7 @@ module Sequel
|
|
174
174
|
# yield the connection if a block is given.
|
175
175
|
def _execute(conn, sql, opts)
|
176
176
|
begin
|
177
|
-
r =
|
177
|
+
r = log_connection_yield((log_sql = opts[:log_sql]) ? sql + log_sql : sql, conn){conn.query(sql)}
|
178
178
|
if opts[:type] == :select
|
179
179
|
yield r if r
|
180
180
|
elsif block_given?
|
@@ -48,7 +48,7 @@ module Sequel
|
|
48
48
|
sqls.unshift("SET NAMES #{conn.escape(encoding.to_s)}")
|
49
49
|
end
|
50
50
|
|
51
|
-
sqls.each{|sql|
|
51
|
+
sqls.each{|sql| log_connection_yield(sql, conn){conn.query(sql)}}
|
52
52
|
|
53
53
|
add_prepared_statements_cache(conn)
|
54
54
|
conn
|
@@ -77,7 +77,7 @@ module Sequel
|
|
77
77
|
def _execute(conn, sql, opts)
|
78
78
|
begin
|
79
79
|
stream = opts[:stream]
|
80
|
-
r =
|
80
|
+
r = log_connection_yield((log_sql = opts[:log_sql]) ? sql + log_sql : sql, conn){conn.query(sql, :database_timezone => timezone, :application_timezone => Sequel.application_timezone, :stream=>stream)}
|
81
81
|
if opts[:type] == :select
|
82
82
|
if r
|
83
83
|
if stream
|
data/lib/sequel/adapters/odbc.rb
CHANGED
@@ -43,7 +43,7 @@ module Sequel
|
|
43
43
|
def execute(sql, opts=OPTS)
|
44
44
|
synchronize(opts[:server]) do |conn|
|
45
45
|
begin
|
46
|
-
r =
|
46
|
+
r = log_connection_yield(sql, conn){conn.run(sql)}
|
47
47
|
yield(r) if block_given?
|
48
48
|
rescue ::ODBC::Error, ArgumentError => e
|
49
49
|
raise_error(e)
|
@@ -57,7 +57,7 @@ module Sequel
|
|
57
57
|
def execute_dui(sql, opts=OPTS)
|
58
58
|
synchronize(opts[:server]) do |conn|
|
59
59
|
begin
|
60
|
-
|
60
|
+
log_connection_yield(sql, conn){conn.do(sql)}
|
61
61
|
rescue ::ODBC::Error, ArgumentError => e
|
62
62
|
raise_error(e)
|
63
63
|
end
|