sequel 4.34.0 → 4.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.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29e8963c69c4f6e3b0af0840e6cc881934ca608f
|
4
|
+
data.tar.gz: 30d2fa8ead89124fa8a4e8a4582a11a78bf7a5c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2961452f5e6b3f1ab7e32da5e4a4dd92e9362a13bb561999ebd493ab8877132d803b7c3e22206ded6a9c2e8336a9bde344c3e2707cbe81732a115d45383d4186
|
7
|
+
data.tar.gz: 72c885ba7219f83ac043bf213045f7b67ebbf213c4aa8380224c9c9d76fd1cd446f043e77ba0765e34684cf0fd35300b6b966a688f6e631e83b4b556ecb25b76
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
=== 4.35.0 (2016-06-01)
|
2
|
+
|
3
|
+
* Add :headline option to PostgreSQL Dataset#full_text_search for adding an extract of the matched text to the SELECT list (jeremyevans)
|
4
|
+
|
5
|
+
* Make :rollback=>:always inside a transaction use a savepoint automatically if supported (jeremyevans) (#1193)
|
6
|
+
|
7
|
+
* Recognize bool type as boolean in the schema dumper (jeremyevans) (#1192)
|
8
|
+
|
9
|
+
* Make Dataset#to_hash and #to_hash_groups work correctly for model datasets doing eager loading (jeremyevans)
|
10
|
+
|
11
|
+
* Make delay_add_association plugin handle hashes and primary keys passed to add_* association methods (jeremyevans) (#1187)
|
12
|
+
|
13
|
+
* Treat :Bignum as a generic type, to support 64-bit integers on ruby 2.4+, where Bignum == Integer (jeremyevans)
|
14
|
+
|
15
|
+
* Add server_logging extension for including server/shard information when logging queries (jeremyevans)
|
16
|
+
|
17
|
+
* Add Database#log_connection_info, for including connection information when logging queries (jeremyevans)
|
18
|
+
|
19
|
+
* Add Dataset#skip_locked for skipping locked rows on PostgreSQL 9.5+, MSSQL, and Oracle (jeremyevans)
|
20
|
+
|
21
|
+
* Allow Sequel::Model#lock! to accept an optional lock style (petedmarsh) (#1183)
|
22
|
+
|
23
|
+
* Add sql_comments extension for setting SQL comments on queries (jeremyevans)
|
24
|
+
|
25
|
+
* Make Postgres::PGRange#cover? handle empty, unbounded, and exclusive beginning ranges (jeremyevans)
|
26
|
+
|
27
|
+
* Fix frozen string literal issues on JRuby 9.1.0.0 (jeremyevans)
|
28
|
+
|
29
|
+
* Allow json_serializer :include option with cascaded values to work correctly when used with association_proxies (jeremyevans)
|
30
|
+
|
1
31
|
=== 4.34.0 (2016-05-01)
|
2
32
|
|
3
33
|
* Add support for :dataset_associations_join association option to dataset_associations plugin, for making resulting datasets have appropriate joins (jeremyevans)
|
data/Rakefile
CHANGED
@@ -82,21 +82,18 @@ end
|
|
82
82
|
|
83
83
|
### Specs
|
84
84
|
|
85
|
-
run_spec = proc do |
|
85
|
+
run_spec = proc do |file|
|
86
86
|
lib_dir = File.join(File.dirname(File.expand_path(__FILE__)), 'lib')
|
87
87
|
rubylib = ENV['RUBYLIB']
|
88
88
|
ENV['RUBYLIB'] ? (ENV['RUBYLIB'] += ":#{lib_dir}") : (ENV['RUBYLIB'] = lib_dir)
|
89
|
-
|
90
|
-
patterns = patterns.split.map{|pat| Dir[pat].to_a}.flatten.join(' ')
|
91
|
-
end
|
92
|
-
sh "#{FileUtils::RUBY} -e \"ARGV.each{|f| require f}\" #{patterns}"
|
89
|
+
sh "#{FileUtils::RUBY} #{file}"
|
93
90
|
ENV['RUBYLIB'] = rubylib
|
94
91
|
end
|
95
92
|
|
96
|
-
spec_task = proc do |description, name,
|
93
|
+
spec_task = proc do |description, name, file, coverage|
|
97
94
|
desc description
|
98
95
|
task name do
|
99
|
-
run_spec.call(
|
96
|
+
run_spec.call(file)
|
100
97
|
end
|
101
98
|
|
102
99
|
desc "#{description} with warnings, some warnings filtered"
|
@@ -110,7 +107,7 @@ spec_task = proc do |description, name, files, coverage|
|
|
110
107
|
desc "#{description} with coverage"
|
111
108
|
task :"#{name}_cov" do
|
112
109
|
ENV['COVERAGE'] = '1'
|
113
|
-
run_spec.call(
|
110
|
+
run_spec.call(file)
|
114
111
|
ENV.delete('COVERAGE')
|
115
112
|
end
|
116
113
|
end
|
@@ -121,19 +118,19 @@ task :default => :spec
|
|
121
118
|
desc "Run the core, model, and extension/plugin specs"
|
122
119
|
task :spec => [:spec_core, :spec_model, :spec_plugin]
|
123
120
|
|
124
|
-
spec_task.call("Run core and model specs together", :spec_core_model, '
|
125
|
-
spec_task.call("Run core specs", :spec_core, '
|
126
|
-
spec_task.call("Run model specs", :spec_model, '
|
127
|
-
spec_task.call("Run plugin/extension specs", :spec_plugin, '
|
128
|
-
spec_task.call("Run bin/sequel specs", :spec_bin, '
|
129
|
-
spec_task.call("Run core extensions specs", :spec_core_ext, '
|
130
|
-
spec_task.call("Run integration tests", :spec_integration, '
|
121
|
+
spec_task.call("Run core and model specs together", :spec_core_model, 'spec/core_model_spec.rb', true)
|
122
|
+
spec_task.call("Run core specs", :spec_core, 'spec/core_spec.rb', false)
|
123
|
+
spec_task.call("Run model specs", :spec_model, 'spec/model_spec.rb', false)
|
124
|
+
spec_task.call("Run plugin/extension specs", :spec_plugin, 'spec/plugin_spec.rb', true)
|
125
|
+
spec_task.call("Run bin/sequel specs", :spec_bin, 'spec/bin_spec.rb', false)
|
126
|
+
spec_task.call("Run core extensions specs", :spec_core_ext, 'spec/core_extensions_spec.rb', true)
|
127
|
+
spec_task.call("Run integration tests", :spec_integration, 'spec/adapter_spec.rb none', true)
|
131
128
|
|
132
129
|
%w'postgres sqlite mysql informix oracle firebird mssql db2 sqlanywhere'.each do |adapter|
|
133
|
-
spec_task.call("Run #{adapter} tests", :"spec_#{adapter}", "
|
130
|
+
spec_task.call("Run #{adapter} tests", :"spec_#{adapter}", "spec/adapter_spec.rb #{adapter}", true)
|
134
131
|
end
|
135
132
|
|
136
|
-
spec_task.call("Run model specs without the associations code", :_spec_model_no_assoc,
|
133
|
+
spec_task.call("Run model specs without the associations code", :_spec_model_no_assoc, 'spec/model_no_assoc_spec.rb', false)
|
137
134
|
desc "Run model specs without the associations code"
|
138
135
|
task :spec_model_no_assoc do
|
139
136
|
ENV['SEQUEL_NO_ASSOCIATIONS'] = '1'
|
data/doc/object_model.rdoc
CHANGED
@@ -263,7 +263,7 @@ The following shortcuts exist for creating Sequel::SQL::ValueList objects:
|
|
263
263
|
=== Sequel::SQL::Identifier
|
264
264
|
|
265
265
|
Sequel::SQL::Identifier objects represent single identifiers. The main reason for
|
266
|
-
their
|
266
|
+
their existence is that they are not checked for double or triple underscores, so no
|
267
267
|
automatic qualification or aliasing happens for them:
|
268
268
|
|
269
269
|
Sequel::SQL::Identifier.new(:col__umn) # "col__umn"
|
@@ -389,7 +389,7 @@ The following shortcut exists for creating Sequel::SQL::ColumnAll objects:
|
|
389
389
|
|
390
390
|
=== Sequel::SQL::Constant
|
391
391
|
|
392
|
-
Sequel::SQL::Constant objects represent constants or
|
392
|
+
Sequel::SQL::Constant objects represent constants or pseudo-constants in SQL,
|
393
393
|
such as TRUE, NULL, and CURRENT_TIMESTAMP. These are not designed to be created
|
394
394
|
or used by the end user, but some existing values are predefined under the
|
395
395
|
Sequel namespace:
|
@@ -544,9 +544,9 @@ They use a hash-based API, supporting the :frame, :order, :partition, and :windo
|
|
544
544
|
options:
|
545
545
|
|
546
546
|
Sequel::SQL::Window.new(:order=>:a) # (ORDER BY "a")
|
547
|
-
Sequel::SQL::Window.new(:
|
547
|
+
Sequel::SQL::Window.new(:partition=>:a) # (PARTITION BY "a")
|
548
548
|
|
549
|
-
Sequel::SQL::Window.new(:
|
549
|
+
Sequel::SQL::Window.new(:partition=>:a, :frame=>:all)
|
550
550
|
# (PARTITION BY "a" ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
|
551
551
|
|
552
552
|
=== Sequel::SQL::Wrapper
|
@@ -0,0 +1,130 @@
|
|
1
|
+
= Forwards Compatibility
|
2
|
+
|
3
|
+
* Ruby 2.4 will unify the Fixnum and Bignum classes into the Integer
|
4
|
+
class, making both Fixnum and Bignum references to Integer. This
|
5
|
+
will have the affect of changing the behavior of Sequel migrations
|
6
|
+
that use a reference to the Bignum class.
|
7
|
+
|
8
|
+
For example, code like this will change behavior in ruby 2.4:
|
9
|
+
|
10
|
+
DB.create_table(:table) do
|
11
|
+
add_column :column, Bignum
|
12
|
+
end
|
13
|
+
# or:
|
14
|
+
DB.get(Sequel.cast('1', Bignum))
|
15
|
+
|
16
|
+
as this references the Bignum class. On ruby <2.4, this will create
|
17
|
+
a 64-bit integer column, on ruby 2.4+, it will create a 32-bit
|
18
|
+
integer column.
|
19
|
+
|
20
|
+
Code like this will be fine and does not need changing:
|
21
|
+
|
22
|
+
DB.create_table(:table) do
|
23
|
+
Bignum :column
|
24
|
+
end
|
25
|
+
|
26
|
+
as this calls the Bignum method.
|
27
|
+
|
28
|
+
Sequel now supports the :Bignum symbol as a generic type, so you
|
29
|
+
can now switch references to the Bignum class to the :Bignum
|
30
|
+
symbol whenever you want a generic 64-bit integer type:
|
31
|
+
|
32
|
+
DB.create_table(:table) do
|
33
|
+
add_column :column, :Bignum
|
34
|
+
end
|
35
|
+
# or:
|
36
|
+
DB.get(Sequel.cast('1', :Bignum))
|
37
|
+
|
38
|
+
Note that you should only do this if you are using Sequel 4.35.0+,
|
39
|
+
as previous versions of Sequel will treat the :Bignum symbol as
|
40
|
+
a database-specific type named Bignum.
|
41
|
+
|
42
|
+
= New Features
|
43
|
+
|
44
|
+
* A Sequel::Database#log_connection_info accessor has been added. If
|
45
|
+
set to true, this includes connection information in Sequel's query
|
46
|
+
log. In threaded connection pools (the default), this makes it
|
47
|
+
simple to see which connection is executing which queries.
|
48
|
+
|
49
|
+
DB.log_connection_info = true
|
50
|
+
DB.get(1)
|
51
|
+
# Logged: (0.000004s) (conn: 9713390226040) SELECT 1 AS v LIMIT
|
52
|
+
|
53
|
+
* Sequel::Model#lock! now supports an optional lock style, instead
|
54
|
+
of always using FOR UPDATE (which is still the default):
|
55
|
+
|
56
|
+
Example.first.lock!('FOR NO KEY UPDATE')
|
57
|
+
#=> SELECT * FROM examples WHERE id = 1 FOR NO KEY UPDATE LIMIT 1
|
58
|
+
|
59
|
+
* Sequel::Database#skip_locked has been added, which skips locked rows
|
60
|
+
when returning query results. This is useful whenever you are
|
61
|
+
implementing a queue or similar data structure. Currently, this is
|
62
|
+
supported on PostgreSQL 9.5+, Oracle, and Microsoft SQL Server.
|
63
|
+
|
64
|
+
* An sql_comments extension has been added for setting SQL comments
|
65
|
+
on queries:
|
66
|
+
|
67
|
+
ds = DB[:table].comment("Some Comment").all
|
68
|
+
# SELECT * FROM table -- Some Comment
|
69
|
+
#
|
70
|
+
|
71
|
+
All consecutive whitespace in the comment is replaced by a
|
72
|
+
single space, and the comment ends in a newline so that it works
|
73
|
+
correctly in subqueries.
|
74
|
+
|
75
|
+
This extension is mostly useful if you are doing analysis of your
|
76
|
+
database server query log and want to include higher level
|
77
|
+
information about the query in the comment.
|
78
|
+
|
79
|
+
* A server_logging extension has been added, which includes
|
80
|
+
server/shard information in the query log, if connection info
|
81
|
+
is being logged.
|
82
|
+
|
83
|
+
DB.extension :server_logging
|
84
|
+
DB.log_connection_info = true
|
85
|
+
DB.get(1)
|
86
|
+
# Logged: (0.000004s) (conn: 9712828677240, server: read_only)
|
87
|
+
# SELECT 1 AS v LIMIT 1
|
88
|
+
DB[:a].insert(:b=>1)
|
89
|
+
# Logged: (0.000003s) (conn: 9712534040260, server: default)
|
90
|
+
# INSERT INTO a (b) VALUES (1)
|
91
|
+
|
92
|
+
* On PostgreSQL, Database#full_text_search now supports a
|
93
|
+
:headline option for adding an extract of the matched text to
|
94
|
+
the SELECT list.
|
95
|
+
|
96
|
+
* Sequel::Postgres::PGRange#cover? has been added to the pg_range
|
97
|
+
extension, which works with empty, unbounded, and exclusive
|
98
|
+
beginning ranges. Previously, using #cover? with these ranges
|
99
|
+
would raise an exception. Note that cover? is now always
|
100
|
+
defined, where previously it was only defined on ruby 1.9+.
|
101
|
+
|
102
|
+
= Other Improvements
|
103
|
+
|
104
|
+
* The jdbc adapters now work correctly on JRuby 9.1. Previously,
|
105
|
+
some parts were broken on JRuby 9.1 due to frozen string literal
|
106
|
+
issues.
|
107
|
+
|
108
|
+
* Sequel::Dataset#to_hash and #to_hash_groups now work correctly for
|
109
|
+
model datasets doing eager loading.
|
110
|
+
|
111
|
+
* Using Sequel::Database#transaction with the :rollback=>:always
|
112
|
+
option now automatically uses a savepoint if supported when run
|
113
|
+
inside another transaction. If savepoints are not supported,
|
114
|
+
using :rollback=>:always inside a transaction will now raise an
|
115
|
+
exception.
|
116
|
+
|
117
|
+
* The delay_add_association plugin now handles hashes and primary keys
|
118
|
+
passed to the add_* association methods.
|
119
|
+
|
120
|
+
* The json_serializer :include option now works correctly when using
|
121
|
+
*_to_many associations with the association_proxies plugin.
|
122
|
+
|
123
|
+
* The schema_dumper extension now recognizes bool as a boolean type,
|
124
|
+
for consistency with the Database schema parser.
|
125
|
+
|
126
|
+
= Backwards Compatibility
|
127
|
+
|
128
|
+
* Custom adapters should switch from using log_yield to
|
129
|
+
log_connection_yield so that they work correctly when using
|
130
|
+
log_connection_info.
|
@@ -74,6 +74,11 @@ as the second argument, either as ruby classes, symbols, or strings:
|
|
74
74
|
column :a6, 'timestamp(6)' # timestamp(6)
|
75
75
|
end
|
76
76
|
|
77
|
+
If you use a ruby class as the type, Sequel will try to guess the appropriate type name for the
|
78
|
+
database you are using. If a symbol or string as used as the type, it is used verbatim as the type
|
79
|
+
name in SQL, with the exception of :Bignum. Using the symbol :Bignum as a type will use the
|
80
|
+
appropriate 64-bit integer type for the database you are using.
|
81
|
+
|
77
82
|
=== Column options
|
78
83
|
|
79
84
|
When using the type name as method, the third argument is an options hash, and when using the +column+
|
@@ -107,7 +112,7 @@ You've seen this one used already. It's used to create an autoincrementing inte
|
|
107
112
|
|
108
113
|
If you want an autoincrementing 64-bit integer:
|
109
114
|
|
110
|
-
create_table(:a0){primary_key :id, :type
|
115
|
+
create_table(:a0){primary_key :id, :type=>:Bignum}
|
111
116
|
|
112
117
|
If you want to create a primary key column that doesn't use an autoincrementing integer, you should
|
113
118
|
not use this method. Instead, you should use the :primary_key option to the +column+ method or type
|
@@ -520,11 +525,11 @@ This modifies a column's type. Most databases will attempt to convert existing
|
|
520
525
|
the columns to the new type:
|
521
526
|
|
522
527
|
alter_table(:albums) do
|
523
|
-
set_column_type :copies_sold, Bignum
|
528
|
+
set_column_type :copies_sold, :Bignum
|
524
529
|
end
|
525
530
|
|
526
531
|
You can specify the type as a string or symbol, in which case it is used verbatim, or as a supported
|
527
|
-
ruby class, in which case it gets converted to an appropriate database type.
|
532
|
+
ruby class or the :Bignum symbol, in which case it gets converted to an appropriate database type.
|
528
533
|
|
529
534
|
=== +set_column_allow_null+
|
530
535
|
|
data/doc/security.rdoc
CHANGED
@@ -191,10 +191,10 @@ Instead, you should do:
|
|
191
191
|
The no_auto_string_literals extension can also be used to remove the default support
|
192
192
|
for plain strings as literal strings in update methods.
|
193
193
|
|
194
|
-
==== SQL Fragment passed to Dataset#lock_style
|
194
|
+
==== SQL Fragment passed to Dataset#lock_style and Model#lock!
|
195
195
|
|
196
|
-
The Sequel::Dataset#lock_style
|
197
|
-
as SQL code. This method should not be called with user input.
|
196
|
+
The Sequel::Dataset#lock_style and Sequel::Model#lock! methods also treat
|
197
|
+
an input string as SQL code. This method should not be called with user input.
|
198
198
|
|
199
199
|
==== SQL Type Names
|
200
200
|
|
data/lib/sequel/adapters/ado.rb
CHANGED
@@ -64,7 +64,7 @@ module Sequel
|
|
64
64
|
return super if opts[:provider]
|
65
65
|
synchronize(opts[:server]) do |conn|
|
66
66
|
begin
|
67
|
-
|
67
|
+
log_connection_yield(sql, conn){conn.Execute(sql, 1)}
|
68
68
|
WIN32OLE::ARGV[1]
|
69
69
|
rescue ::WIN32OLERuntimeError => e
|
70
70
|
raise_error(e)
|
@@ -75,7 +75,7 @@ module Sequel
|
|
75
75
|
def execute(sql, opts=OPTS)
|
76
76
|
synchronize(opts[:server]) do |conn|
|
77
77
|
begin
|
78
|
-
r =
|
78
|
+
r = log_connection_yield(sql, conn){conn.Execute(sql)}
|
79
79
|
yield(r) if block_given?
|
80
80
|
rescue ::WIN32OLERuntimeError => e
|
81
81
|
raise_error(e)
|
@@ -111,8 +111,8 @@ module Sequel
|
|
111
111
|
def execute_insert(sql, opts=OPTS)
|
112
112
|
synchronize(opts[:server]) do |conn|
|
113
113
|
begin
|
114
|
-
|
115
|
-
res =
|
114
|
+
log_connection_yield(sql, conn){conn.Execute(sql)}
|
115
|
+
res = log_connection_yield(LAST_INSERT_ID, conn){conn.Execute(LAST_INSERT_ID)}
|
116
116
|
res.getRows.transpose.each{|r| return r.shift}
|
117
117
|
rescue ::WIN32OLERuntimeError => e
|
118
118
|
raise_error(e)
|
@@ -203,15 +203,15 @@ module Sequel
|
|
203
203
|
end
|
204
204
|
|
205
205
|
def begin_transaction(conn, opts=OPTS)
|
206
|
-
|
206
|
+
log_connection_yield('Transaction.begin', conn){conn.BeginTrans}
|
207
207
|
end
|
208
208
|
|
209
209
|
def commit_transaction(conn, opts=OPTS)
|
210
|
-
|
210
|
+
log_connection_yield('Transaction.commit', conn){conn.CommitTrans}
|
211
211
|
end
|
212
212
|
|
213
213
|
def rollback_transaction(conn, opts=OPTS)
|
214
|
-
|
214
|
+
log_connection_yield('Transaction.rollback', conn){conn.RollbackTrans}
|
215
215
|
end
|
216
216
|
|
217
217
|
def schema_column_type(db_type)
|
@@ -313,7 +313,7 @@ module Sequel
|
|
313
313
|
ado_schema = AdoSchema.new(type, criteria)
|
314
314
|
synchronize(opts[:server]) do |conn|
|
315
315
|
begin
|
316
|
-
r =
|
316
|
+
r = log_connection_yield("OpenSchema #{type.inspect}, #{criteria.inspect}", conn) {
|
317
317
|
if ado_schema.criteria.empty?
|
318
318
|
conn.OpenSchema(ado_schema.type)
|
319
319
|
else
|
@@ -21,8 +21,8 @@ module Sequel
|
|
21
21
|
return super unless @opts[:provider]
|
22
22
|
synchronize(opts[:server]) do |conn|
|
23
23
|
begin
|
24
|
-
|
25
|
-
res =
|
24
|
+
log_connection_yield(sql, conn){conn.Execute(sql)}
|
25
|
+
res = log_connection_yield(ROWS_AFFECTED, conn){conn.Execute(ROWS_AFFECTED)}
|
26
26
|
res.getRows.transpose.each{|r| return r.shift}
|
27
27
|
rescue ::WIN32OLERuntimeError => e
|
28
28
|
raise_error(e)
|
@@ -81,7 +81,7 @@ module Sequel
|
|
81
81
|
db = ::Amalgalite::Database.new(opts[:database])
|
82
82
|
db.busy_handler(::Amalgalite::BusyTimeout.new(opts.fetch(:timeout, 5000)/50, 50))
|
83
83
|
db.type_map = SequelTypeMap.new(self)
|
84
|
-
connection_pragmas.each{|s|
|
84
|
+
connection_pragmas.each{|s| log_connection_yield(s, db){db.execute_batch(s)}}
|
85
85
|
db
|
86
86
|
end
|
87
87
|
|
@@ -92,25 +92,25 @@ module Sequel
|
|
92
92
|
|
93
93
|
# Run the given SQL with the given arguments. Returns nil.
|
94
94
|
def execute_ddl(sql, opts=OPTS)
|
95
|
-
_execute(sql, opts){|conn|
|
95
|
+
_execute(sql, opts){|conn| log_connection_yield(sql, conn){conn.execute_batch(sql)}}
|
96
96
|
nil
|
97
97
|
end
|
98
98
|
|
99
99
|
# Run the given SQL with the given arguments and return the number of changed rows.
|
100
100
|
def execute_dui(sql, opts=OPTS)
|
101
|
-
_execute(sql, opts){|conn|
|
101
|
+
_execute(sql, opts){|conn| log_connection_yield(sql, conn){conn.execute_batch(sql)}; conn.row_changes}
|
102
102
|
end
|
103
103
|
|
104
104
|
# Run the given SQL with the given arguments and return the last inserted row id.
|
105
105
|
def execute_insert(sql, opts=OPTS)
|
106
|
-
_execute(sql, opts){|conn|
|
106
|
+
_execute(sql, opts){|conn| log_connection_yield(sql, conn){conn.execute_batch(sql)}; conn.last_insert_rowid}
|
107
107
|
end
|
108
108
|
|
109
109
|
# Run the given SQL with the given arguments and yield each row.
|
110
110
|
def execute(sql, opts=OPTS)
|
111
111
|
_execute(sql, opts) do |conn|
|
112
112
|
begin
|
113
|
-
yield(stmt =
|
113
|
+
yield(stmt = log_connection_yield(sql, conn){conn.prepare(sql)})
|
114
114
|
ensure
|
115
115
|
stmt.close if stmt
|
116
116
|
end
|
@@ -119,7 +119,7 @@ module Sequel
|
|
119
119
|
|
120
120
|
# Run the given SQL with the given arguments and return the first value of the first row.
|
121
121
|
def single_value(sql, opts=OPTS)
|
122
|
-
_execute(sql, opts){|conn|
|
122
|
+
_execute(sql, opts){|conn| log_connection_yield(sql, conn){conn.first_value_from(sql)}}
|
123
123
|
end
|
124
124
|
|
125
125
|
private
|
@@ -38,7 +38,7 @@ module Sequel
|
|
38
38
|
|
39
39
|
def execute(sql, opts=OPTS)
|
40
40
|
synchronize(opts[:server]) do |conn|
|
41
|
-
r =
|
41
|
+
r = log_connection_yield(sql, conn) do
|
42
42
|
begin
|
43
43
|
conn.query(sql)
|
44
44
|
rescue => e
|
@@ -92,11 +92,11 @@ module Sequel
|
|
92
92
|
private
|
93
93
|
|
94
94
|
def begin_transaction(conn, opts=OPTS)
|
95
|
-
|
95
|
+
log_connection_yield(TRANSACTION_BEGIN, conn){conn.auto_commit = false}
|
96
96
|
end
|
97
97
|
|
98
98
|
def commit_transaction(conn, opts=OPTS)
|
99
|
-
|
99
|
+
log_connection_yield(TRANSACTION_COMMIT, conn){conn.commit}
|
100
100
|
end
|
101
101
|
|
102
102
|
def database_error_classes
|
@@ -112,7 +112,7 @@ module Sequel
|
|
112
112
|
# This doesn't actually work, as the cubrid ruby driver
|
113
113
|
# does not implement transactions correctly.
|
114
114
|
def rollback_transaction(conn, opts=OPTS)
|
115
|
-
|
115
|
+
log_connection_yield(TRANSACTION_ROLLBACK, conn){conn.rollback}
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|