sequel 5.107.0 → 5.108.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/bin/sequel +5 -5
- data/lib/sequel/adapters/ado.rb +1 -1
- data/lib/sequel/adapters/ibmdb.rb +2 -2
- data/lib/sequel/adapters/jdbc/hsqldb.rb +1 -1
- data/lib/sequel/adapters/jdbc/mysql.rb +1 -1
- data/lib/sequel/adapters/jdbc.rb +2 -2
- data/lib/sequel/adapters/mock.rb +1 -1
- data/lib/sequel/adapters/mysql.rb +7 -2
- data/lib/sequel/adapters/mysql2.rb +5 -4
- data/lib/sequel/adapters/postgres.rb +37 -37
- data/lib/sequel/adapters/shared/db2.rb +2 -2
- data/lib/sequel/adapters/shared/mssql.rb +4 -4
- data/lib/sequel/adapters/shared/mysql.rb +2 -2
- data/lib/sequel/adapters/shared/postgres.rb +67 -44
- data/lib/sequel/adapters/shared/sqlite.rb +3 -3
- data/lib/sequel/adapters/utils/emulate_offset_with_reverse_and_count.rb +1 -1
- data/lib/sequel/adapters/utils/mysql_mysql2.rb +11 -1
- data/lib/sequel/connection_pool/sharded_single.rb +1 -1
- data/lib/sequel/connection_pool/sharded_threaded.rb +7 -5
- data/lib/sequel/connection_pool/sharded_timed_queue.rb +3 -3
- data/lib/sequel/connection_pool/threaded.rb +9 -7
- data/lib/sequel/connection_pool/timed_queue.rb +2 -2
- data/lib/sequel/connection_pool.rb +3 -3
- data/lib/sequel/core.rb +30 -22
- data/lib/sequel/database/connecting.rb +1 -1
- data/lib/sequel/database/features.rb +1 -1
- data/lib/sequel/database/misc.rb +7 -7
- data/lib/sequel/database/query.rb +2 -2
- data/lib/sequel/database/schema_generator.rb +4 -4
- data/lib/sequel/database/schema_methods.rb +2 -2
- data/lib/sequel/database/transactions.rb +4 -4
- data/lib/sequel/dataset/actions.rb +1 -1
- data/lib/sequel/dataset/features.rb +4 -4
- data/lib/sequel/dataset/graph.rb +1 -1
- data/lib/sequel/dataset/misc.rb +3 -3
- data/lib/sequel/dataset/prepared_statements.rb +2 -2
- data/lib/sequel/dataset/query.rb +8 -8
- data/lib/sequel/dataset/sql.rb +18 -10
- data/lib/sequel/dataset.rb +2 -2
- data/lib/sequel/deprecated.rb +2 -2
- data/lib/sequel/exceptions.rb +2 -2
- data/lib/sequel/extensions/_pretty_table.rb +1 -1
- data/lib/sequel/extensions/async_thread_pool.rb +3 -3
- data/lib/sequel/extensions/auto_cast_date_and_time.rb +2 -2
- data/lib/sequel/extensions/blank.rb +2 -2
- data/lib/sequel/extensions/constraint_validations.rb +1 -1
- data/lib/sequel/extensions/core_refinements.rb +8 -8
- data/lib/sequel/extensions/date_arithmetic.rb +1 -1
- data/lib/sequel/extensions/datetime_parse_to_time.rb +2 -2
- data/lib/sequel/extensions/duplicate_columns_handler.rb +2 -2
- data/lib/sequel/extensions/graph_each.rb +1 -1
- data/lib/sequel/extensions/index_caching.rb +1 -1
- data/lib/sequel/extensions/inflector.rb +5 -5
- data/lib/sequel/extensions/is_distinct_from.rb +2 -2
- data/lib/sequel/extensions/lit_require_frozen.rb +3 -3
- data/lib/sequel/extensions/migration.rb +21 -7
- data/lib/sequel/extensions/named_timezones.rb +8 -8
- data/lib/sequel/extensions/pg_array.rb +9 -8
- data/lib/sequel/extensions/pg_array_ops.rb +69 -14
- data/lib/sequel/extensions/pg_auto_parameterize.rb +2 -2
- data/lib/sequel/extensions/pg_auto_parameterize_in_array.rb +3 -3
- data/lib/sequel/extensions/pg_enum.rb +2 -2
- data/lib/sequel/extensions/pg_extended_date_support.rb +5 -5
- data/lib/sequel/extensions/pg_extended_integer_support.rb +1 -1
- data/lib/sequel/extensions/pg_hstore.rb +2 -2
- data/lib/sequel/extensions/pg_hstore_ops.rb +5 -5
- data/lib/sequel/extensions/pg_inet.rb +2 -2
- data/lib/sequel/extensions/pg_inet_ops.rb +2 -2
- data/lib/sequel/extensions/pg_interval.rb +6 -6
- data/lib/sequel/extensions/pg_json.rb +4 -4
- data/lib/sequel/extensions/pg_json_ops.rb +11 -11
- data/lib/sequel/extensions/pg_range.rb +6 -6
- data/lib/sequel/extensions/pg_range_ops.rb +7 -7
- data/lib/sequel/extensions/pg_row.rb +4 -4
- data/lib/sequel/extensions/pg_row_ops.rb +6 -6
- data/lib/sequel/extensions/provenance.rb +2 -2
- data/lib/sequel/extensions/query.rb +2 -2
- data/lib/sequel/extensions/s.rb +2 -2
- data/lib/sequel/extensions/schema_dumper.rb +4 -4
- data/lib/sequel/extensions/sequel_4_dataset_methods.rb +2 -0
- data/lib/sequel/extensions/sql_comments.rb +1 -1
- data/lib/sequel/extensions/sql_log_normalizer.rb +1 -1
- data/lib/sequel/extensions/sqlite_json_ops.rb +2 -2
- data/lib/sequel/extensions/string_agg.rb +5 -5
- data/lib/sequel/extensions/symbol_aref.rb +3 -3
- data/lib/sequel/extensions/symbol_aref_refinement.rb +3 -3
- data/lib/sequel/extensions/symbol_as_refinement.rb +2 -2
- data/lib/sequel/extensions/transaction_connection_validator.rb +1 -1
- data/lib/sequel/model/associations.rb +17 -17
- data/lib/sequel/model/base.rb +19 -11
- data/lib/sequel/model/inflections.rb +1 -1
- data/lib/sequel/model/plugins.rb +2 -2
- data/lib/sequel/model.rb +2 -2
- data/lib/sequel/plugins/association_pks.rb +1 -1
- data/lib/sequel/plugins/association_proxies.rb +4 -4
- data/lib/sequel/plugins/auto_restrict_eager_graph.rb +2 -0
- data/lib/sequel/plugins/caching.rb +1 -1
- data/lib/sequel/plugins/class_table_inheritance.rb +1 -1
- data/lib/sequel/plugins/column_encryption.rb +10 -10
- data/lib/sequel/plugins/concurrent_eager_loading.rb +2 -2
- data/lib/sequel/plugins/csv_serializer.rb +2 -2
- data/lib/sequel/plugins/deprecated_associations.rb +2 -2
- data/lib/sequel/plugins/eager_each.rb +1 -1
- data/lib/sequel/plugins/finder.rb +1 -1
- data/lib/sequel/plugins/forbid_lazy_load.rb +3 -3
- data/lib/sequel/plugins/insert_conflict.rb +1 -1
- data/lib/sequel/plugins/insert_returning_select.rb +1 -1
- data/lib/sequel/plugins/json_serializer.rb +4 -4
- data/lib/sequel/plugins/lazy_attributes.rb +1 -1
- data/lib/sequel/plugins/many_through_many.rb +1 -1
- data/lib/sequel/plugins/pg_array_associations.rb +4 -4
- data/lib/sequel/plugins/pg_auto_constraint_validations.rb +3 -3
- data/lib/sequel/plugins/pg_eager_any_typed_array.rb +2 -2
- data/lib/sequel/plugins/prepared_statements.rb +2 -2
- data/lib/sequel/plugins/serialization.rb +1 -1
- data/lib/sequel/plugins/sharding.rb +1 -1
- data/lib/sequel/plugins/single_table_inheritance.rb +1 -1
- data/lib/sequel/plugins/skip_saving_columns.rb +2 -2
- data/lib/sequel/plugins/split_values.rb +1 -1
- data/lib/sequel/plugins/sql_comments.rb +8 -8
- data/lib/sequel/plugins/subclasses.rb +6 -6
- data/lib/sequel/plugins/subset_conditions.rb +2 -2
- data/lib/sequel/plugins/tactical_eager_loading.rb +1 -1
- data/lib/sequel/plugins/throw_failures.rb +2 -2
- data/lib/sequel/plugins/unused_associations.rb +5 -5
- data/lib/sequel/plugins/validation_helpers.rb +1 -1
- data/lib/sequel/plugins/xml_serializer.rb +2 -0
- data/lib/sequel/sql.rb +11 -11
- data/lib/sequel/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ebb20cf6a0935b45043b5dc3d5ba39256f5c9fe34a1894a32383211f4cbeced5
|
|
4
|
+
data.tar.gz: a5a0c9a83a2862f133516a91b76862e0f69e6b4ac95356a7358e0ae798ab6449
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bde58f0598455d105c3c4a2e3d30ebf86776c2acbef2ccfdf6ea0f3c36772396c42be9678f8e03bbfab41e06a593f2d3e6e651a8fbded9ffa3fb2f13c2f1f1eb
|
|
7
|
+
data.tar.gz: d92f6fa652e500b92106aaafb5646dab52c80647e0cf1d42164cdccdf16e8e56209b3205b8699e99704bfae480bdd4846769100e7e602c2ac72d4a9383765b60
|
data/bin/sequel
CHANGED
|
@@ -74,7 +74,7 @@ options = OptionParser.new do |opts|
|
|
|
74
74
|
loggers << file
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
opts.on("-L", "--load-dir DIR", "loads all *.rb under
|
|
77
|
+
opts.on("-L", "--load-dir DIR", "loads all *.rb under specified directory") do |v|
|
|
78
78
|
load_dirs << v
|
|
79
79
|
end
|
|
80
80
|
|
|
@@ -200,9 +200,9 @@ begin
|
|
|
200
200
|
same_db = DB.database_type==TO_DB.database_type
|
|
201
201
|
index_opts = {:same_db=>same_db}
|
|
202
202
|
|
|
203
|
-
# :
|
|
203
|
+
# simplecov:disable
|
|
204
204
|
index_opts[:index_names] = :namespace if !DB.global_index_namespace? && TO_DB.global_index_namespace?
|
|
205
|
-
# :
|
|
205
|
+
# simplecov:enable
|
|
206
206
|
|
|
207
207
|
if DB.database_type == :sqlite && !same_db
|
|
208
208
|
# SQLite integer types allows 64-bit integers
|
|
@@ -271,10 +271,10 @@ if !ARGV.empty?
|
|
|
271
271
|
ARGV.each{|v| load(v)}
|
|
272
272
|
elsif !$stdin.isatty
|
|
273
273
|
eval($stdin.read)
|
|
274
|
-
# :
|
|
274
|
+
# simplecov:disable
|
|
275
275
|
else
|
|
276
276
|
require 'irb'
|
|
277
277
|
puts "Your database is stored in DB..."
|
|
278
278
|
IRB.start
|
|
279
279
|
end
|
|
280
|
-
# :
|
|
280
|
+
# simplecov:enable
|
data/lib/sequel/adapters/ado.rb
CHANGED
|
@@ -108,7 +108,7 @@ module Sequel
|
|
|
108
108
|
# Pay special attention to the :provider option, as without specifying a provider,
|
|
109
109
|
# many things will be broken. The SQLNCLI10 provider appears to work well if you
|
|
110
110
|
# are connecting to Microsoft SQL Server, but it is not the default as that is not
|
|
111
|
-
# always available and would break backwards
|
|
111
|
+
# always available and would break backwards compatibility.
|
|
112
112
|
def connect(server)
|
|
113
113
|
opts = server_opts(server)
|
|
114
114
|
s = opts[:conn_string] || "driver=#{opts[:driver]};server=#{opts[:host]};database=#{opts[:database]}#{";uid=#{opts[:user]};pwd=#{opts[:password]}" if opts[:user]}"
|
|
@@ -312,13 +312,13 @@ module Sequel
|
|
|
312
312
|
# Don't convert smallint to boolean for the metadata
|
|
313
313
|
# dataset, since the DB2 metadata does not use
|
|
314
314
|
# boolean columns, and some smallint columns are
|
|
315
|
-
#
|
|
315
|
+
# accidentally treated as booleans.
|
|
316
316
|
def _metadata_dataset
|
|
317
317
|
super.with_convert_smallint_to_bool(false)
|
|
318
318
|
end
|
|
319
319
|
|
|
320
320
|
# Format Numeric, Date, and Time types specially for use
|
|
321
|
-
# as IBM_DB prepared statements argument
|
|
321
|
+
# as IBM_DB prepared statements argument values.
|
|
322
322
|
def prepared_statement_arg(v)
|
|
323
323
|
case v
|
|
324
324
|
when Numeric
|
|
@@ -163,7 +163,7 @@ module Sequel
|
|
|
163
163
|
end
|
|
164
164
|
|
|
165
165
|
# HSQLDB does support common table expressions, but the support is broken.
|
|
166
|
-
# CTEs operate more like
|
|
166
|
+
# CTEs operate more like temporary tables or views, lasting longer than the duration of the expression.
|
|
167
167
|
# CTEs in earlier queries might take precedence over CTEs with the same name in later queries.
|
|
168
168
|
# Also, if any CTE is recursive, all CTEs must be recursive.
|
|
169
169
|
# If you want to use CTEs with HSQLDB, you'll have to manually modify the dataset to allow it.
|
|
@@ -68,7 +68,7 @@ module Sequel
|
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
# Run the default connection setting SQL statements.
|
|
71
|
-
# Apply the
|
|
71
|
+
# Apply the connection setting SQLs for every new connection.
|
|
72
72
|
def setup_connection(conn)
|
|
73
73
|
mysql_connection_setting_sqls.each{|sql| statement(conn){|s| log_connection_yield(sql, conn){s.execute(sql)}}}
|
|
74
74
|
super
|
data/lib/sequel/adapters/jdbc.rb
CHANGED
|
@@ -5,7 +5,7 @@ require_relative 'utils/stored_procedures'
|
|
|
5
5
|
|
|
6
6
|
module Sequel
|
|
7
7
|
module JDBC
|
|
8
|
-
# Make it
|
|
8
|
+
# Make it accessing the java.sql hierarchy more ruby friendly.
|
|
9
9
|
module JavaSQL
|
|
10
10
|
include_package 'java.sql'
|
|
11
11
|
end
|
|
@@ -361,7 +361,7 @@ module Sequel
|
|
|
361
361
|
# The uri for this connection. You can specify the uri
|
|
362
362
|
# using the :uri, :url, or :database options. You don't
|
|
363
363
|
# need to worry about this if you use Sequel.connect
|
|
364
|
-
# with the JDBC
|
|
364
|
+
# with the JDBC connection strings.
|
|
365
365
|
def uri(opts=OPTS)
|
|
366
366
|
opts = @opts.merge(opts)
|
|
367
367
|
ur = opts[:uri] || opts[:url] || opts[:database]
|
data/lib/sequel/adapters/mock.rb
CHANGED
|
@@ -38,7 +38,7 @@ module Sequel
|
|
|
38
38
|
#
|
|
39
39
|
# nil :: Return nil for all inserts
|
|
40
40
|
# Integer :: Starting integer for next insert, with
|
|
41
|
-
#
|
|
41
|
+
# further inserts getting an incremented
|
|
42
42
|
# value
|
|
43
43
|
# Array :: First insert gets the first value in the
|
|
44
44
|
# array, second gets the second value, etc.
|
|
@@ -69,7 +69,7 @@ module Sequel
|
|
|
69
69
|
# :auto_is_null :: Set to true to use MySQL default behavior of having
|
|
70
70
|
# a filter for an autoincrement column equals NULL to return the last
|
|
71
71
|
# inserted row.
|
|
72
|
-
# :charset :: Same as :encoding (:encoding takes
|
|
72
|
+
# :charset :: Same as :encoding (:encoding takes precedence)
|
|
73
73
|
# :compress :: Set to false to not compress results from the server
|
|
74
74
|
# :config_default_group :: The default group to read from the in
|
|
75
75
|
# the MySQL config file.
|
|
@@ -284,8 +284,13 @@ module Sequel
|
|
|
284
284
|
Dataset
|
|
285
285
|
end
|
|
286
286
|
|
|
287
|
+
# If the error is a Mysql::Error, check the client error code and exception
|
|
288
|
+
# message for disconnects.
|
|
287
289
|
def disconnect_error?(e, opts)
|
|
288
|
-
super ||
|
|
290
|
+
super ||
|
|
291
|
+
(e.is_a?(::Mysql::Error) &&
|
|
292
|
+
(MYSQL_DISCONNECT_ERROR_CODES.include?(e.errno) ||
|
|
293
|
+
MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message)))
|
|
289
294
|
end
|
|
290
295
|
|
|
291
296
|
# Convert tinyint(1) type to boolean if convert_tinyint_to_bool is true
|
|
@@ -28,7 +28,7 @@ module Sequel
|
|
|
28
28
|
# :auto_is_null :: Set to true to use MySQL default behavior of having
|
|
29
29
|
# a filter for an autoincrement column equals NULL to return the last
|
|
30
30
|
# inserted row.
|
|
31
|
-
# :charset :: Same as :encoding (:encoding takes
|
|
31
|
+
# :charset :: Same as :encoding (:encoding takes precedence)
|
|
32
32
|
# :encoding :: Set all the related character sets for this
|
|
33
33
|
# connection (connection, client, database, server, and results).
|
|
34
34
|
#
|
|
@@ -215,13 +215,14 @@ module Sequel
|
|
|
215
215
|
end
|
|
216
216
|
|
|
217
217
|
# If a connection object is available, try pinging it. Otherwise, if the
|
|
218
|
-
# error is a Mysql2::Error, check the SQL state and
|
|
219
|
-
# disconnects.
|
|
218
|
+
# error is a Mysql2::Error, check the client error code, SQL state, and
|
|
219
|
+
# exception message for disconnects.
|
|
220
220
|
def disconnect_error?(e, opts)
|
|
221
221
|
super ||
|
|
222
222
|
((conn = opts[:conn]) && !conn.ping) ||
|
|
223
223
|
(e.is_a?(::Mysql2::Error) &&
|
|
224
|
-
((e.
|
|
224
|
+
(MYSQL_DISCONNECT_ERROR_CODES.include?(e.errno) ||
|
|
225
|
+
(e.sql_state && e.sql_state.start_with?("08")) ||
|
|
225
226
|
MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message)))
|
|
226
227
|
end
|
|
227
228
|
|
|
@@ -5,7 +5,7 @@ require_relative 'shared/postgres'
|
|
|
5
5
|
begin
|
|
6
6
|
require 'pg'
|
|
7
7
|
|
|
8
|
-
# :
|
|
8
|
+
# simplecov:disable
|
|
9
9
|
Sequel::Postgres::PGError = PG::Error if defined?(PG::Error)
|
|
10
10
|
Sequel::Postgres::PGconn = PG::Connection if defined?(PG::Connection)
|
|
11
11
|
Sequel::Postgres::PGresult = PG::Result if defined?(PG::Result)
|
|
@@ -16,7 +16,7 @@ begin
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
if defined?(PG::TypeMapByClass)
|
|
19
|
-
# :
|
|
19
|
+
# simplecov:enable
|
|
20
20
|
type_map = Sequel::Postgres::PG_QUERY_TYPE_MAP = PG::TypeMapByClass.new
|
|
21
21
|
type_map[Integer] = PG::TextEncoder::Integer.new
|
|
22
22
|
type_map[FalseClass] = type_map[TrueClass] = PG::TextEncoder::Boolean.new
|
|
@@ -25,7 +25,7 @@ begin
|
|
|
25
25
|
|
|
26
26
|
Sequel::Postgres::USES_PG = true
|
|
27
27
|
rescue LoadError => e
|
|
28
|
-
# :
|
|
28
|
+
# simplecov:disable
|
|
29
29
|
begin
|
|
30
30
|
require 'sequel/postgres-pr'
|
|
31
31
|
rescue LoadError
|
|
@@ -36,19 +36,19 @@ rescue LoadError => e
|
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
Sequel::Postgres::USES_PG = false
|
|
39
|
-
# :
|
|
39
|
+
# simplecov:enable
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
module Sequel
|
|
43
43
|
module Postgres
|
|
44
|
-
# :
|
|
44
|
+
# simplecov:disable
|
|
45
45
|
if USES_PG
|
|
46
46
|
# Whether the given sequel_pg version integer is supported.
|
|
47
47
|
def self.sequel_pg_version_supported?(version)
|
|
48
48
|
version >= 10617
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
|
-
# :
|
|
51
|
+
# simplecov:enable
|
|
52
52
|
|
|
53
53
|
# PGconn subclass for connection specific methods used with the
|
|
54
54
|
# pg or postgres-pr driver.
|
|
@@ -56,9 +56,9 @@ module Sequel
|
|
|
56
56
|
# The underlying exception classes to reraise as disconnect errors
|
|
57
57
|
# instead of regular database errors.
|
|
58
58
|
DISCONNECT_ERROR_CLASSES = [IOError, Errno::EPIPE, Errno::ECONNRESET]
|
|
59
|
-
# :
|
|
59
|
+
# simplecov:disable
|
|
60
60
|
if defined?(::PG::ConnectionBad)
|
|
61
|
-
# :
|
|
61
|
+
# simplecov:enable
|
|
62
62
|
DISCONNECT_ERROR_CLASSES << ::PG::ConnectionBad
|
|
63
63
|
end
|
|
64
64
|
DISCONNECT_ERROR_CLASSES.freeze
|
|
@@ -84,7 +84,7 @@ module Sequel
|
|
|
84
84
|
# are SQL strings.
|
|
85
85
|
attr_reader :prepared_statements
|
|
86
86
|
|
|
87
|
-
# :
|
|
87
|
+
# simplecov:disable
|
|
88
88
|
unless public_method_defined?(:async_exec_params)
|
|
89
89
|
alias async_exec_params async_exec
|
|
90
90
|
end
|
|
@@ -127,7 +127,7 @@ module Sequel
|
|
|
127
127
|
alias cmd_tuples cmdtuples
|
|
128
128
|
end
|
|
129
129
|
end
|
|
130
|
-
# :
|
|
130
|
+
# simplecov:enable
|
|
131
131
|
|
|
132
132
|
# Raise a Sequel::DatabaseDisconnectError if a one of the disconnect
|
|
133
133
|
# error classes is raised, or a PGError is raised and the connection
|
|
@@ -185,12 +185,12 @@ module Sequel
|
|
|
185
185
|
case arg
|
|
186
186
|
when Sequel::SQL::Blob
|
|
187
187
|
{:value=>arg, :type=>17, :format=>1}
|
|
188
|
-
# :
|
|
188
|
+
# simplecov:disable
|
|
189
189
|
# Not covered by tests as tests use pg_extended_date_support
|
|
190
190
|
# extension, which has basically the same code.
|
|
191
191
|
when Time, DateTime
|
|
192
192
|
@default_dataset.literal_date_or_time(arg)
|
|
193
|
-
# :
|
|
193
|
+
# simplecov:enable
|
|
194
194
|
else
|
|
195
195
|
arg
|
|
196
196
|
end
|
|
@@ -225,9 +225,9 @@ module Sequel
|
|
|
225
225
|
:sslmode => opts[:sslmode],
|
|
226
226
|
:sslrootcert => opts[:sslrootcert]
|
|
227
227
|
}.delete_if { |key, value| blank_object?(value) }
|
|
228
|
-
# :
|
|
228
|
+
# simplecov:disable
|
|
229
229
|
connection_params.merge!(opts[:driver_options]) if opts[:driver_options]
|
|
230
|
-
# :
|
|
230
|
+
# simplecov:enable
|
|
231
231
|
conn = Adapter.connect(opts[:conn_str] || connection_params)
|
|
232
232
|
|
|
233
233
|
conn.instance_variable_set(:@prepared_statements, {})
|
|
@@ -236,12 +236,12 @@ module Sequel
|
|
|
236
236
|
conn.set_notice_receiver(&receiver)
|
|
237
237
|
end
|
|
238
238
|
|
|
239
|
-
# :
|
|
239
|
+
# simplecov:disable
|
|
240
240
|
if conn.respond_to?(:type_map_for_queries=) && defined?(PG_QUERY_TYPE_MAP)
|
|
241
|
-
# :
|
|
241
|
+
# simplecov:enable
|
|
242
242
|
conn.type_map_for_queries = PG_QUERY_TYPE_MAP
|
|
243
243
|
end
|
|
244
|
-
# :
|
|
244
|
+
# simplecov:disable
|
|
245
245
|
else
|
|
246
246
|
unless typecast_value_boolean(@opts.fetch(:force_standard_strings, true))
|
|
247
247
|
raise Error, "Cannot create connection using postgres-pr unless force_standard_strings is set"
|
|
@@ -256,11 +256,11 @@ module Sequel
|
|
|
256
256
|
opts[:password]
|
|
257
257
|
)
|
|
258
258
|
end
|
|
259
|
-
# :
|
|
259
|
+
# simplecov:enable
|
|
260
260
|
|
|
261
261
|
conn.instance_variable_set(:@db, self)
|
|
262
262
|
|
|
263
|
-
# :
|
|
263
|
+
# simplecov:disable
|
|
264
264
|
if encoding = opts[:encoding] || opts[:charset]
|
|
265
265
|
if conn.respond_to?(:set_client_encoding)
|
|
266
266
|
conn.set_client_encoding(encoding)
|
|
@@ -268,7 +268,7 @@ module Sequel
|
|
|
268
268
|
conn.async_exec("set client_encoding to '#{encoding}'")
|
|
269
269
|
end
|
|
270
270
|
end
|
|
271
|
-
# :
|
|
271
|
+
# simplecov:enable
|
|
272
272
|
|
|
273
273
|
connection_configuration_sqls(opts).each{|sql| conn.execute(sql)}
|
|
274
274
|
conn
|
|
@@ -295,9 +295,9 @@ module Sequel
|
|
|
295
295
|
nil
|
|
296
296
|
end
|
|
297
297
|
|
|
298
|
-
# :
|
|
298
|
+
# simplecov:disable
|
|
299
299
|
if USES_PG && Object.const_defined?(:PG) && ::PG.const_defined?(:Constants) && ::PG::Constants.const_defined?(:PG_DIAG_SCHEMA_NAME)
|
|
300
|
-
# :
|
|
300
|
+
# simplecov:enable
|
|
301
301
|
# Return a hash of information about the related PGError (or Sequel::DatabaseError that
|
|
302
302
|
# wraps a PGError), with the following entries (any of which may be +nil+):
|
|
303
303
|
#
|
|
@@ -348,9 +348,9 @@ module Sequel
|
|
|
348
348
|
synchronize(opts[:server]){|conn| check_database_errors{_execute(conn, sql, opts, &block)}}
|
|
349
349
|
end
|
|
350
350
|
|
|
351
|
-
# :
|
|
351
|
+
# simplecov:disable
|
|
352
352
|
if USES_PG
|
|
353
|
-
# :
|
|
353
|
+
# simplecov:enable
|
|
354
354
|
# +copy_table+ uses PostgreSQL's +COPY TO STDOUT+ SQL statement to return formatted
|
|
355
355
|
# results directly to the caller. This method is only supported if pg is the
|
|
356
356
|
# underlying ruby driver. This method should only be called if you want
|
|
@@ -544,10 +544,10 @@ module Sequel
|
|
|
544
544
|
def adapter_initialize
|
|
545
545
|
@use_iso_date_format = typecast_value_boolean(@opts.fetch(:use_iso_date_format, true))
|
|
546
546
|
initialize_postgres_adapter
|
|
547
|
-
# :
|
|
547
|
+
# simplecov:disable
|
|
548
548
|
add_conversion_proc(17, method(:unescape_bytea)) if USES_PG
|
|
549
549
|
add_conversion_proc(1082, TYPE_TRANSLATOR_DATE) if @use_iso_date_format
|
|
550
|
-
# :
|
|
550
|
+
# simplecov:enable
|
|
551
551
|
self.convert_infinite_timestamps = @opts[:convert_infinite_timestamps]
|
|
552
552
|
end
|
|
553
553
|
|
|
@@ -560,19 +560,19 @@ module Sequel
|
|
|
560
560
|
# Set the DateStyle to ISO if configured, for faster date parsing.
|
|
561
561
|
def connection_configuration_sqls(opts=@opts)
|
|
562
562
|
sqls = super
|
|
563
|
-
# :
|
|
563
|
+
# simplecov:disable
|
|
564
564
|
sqls << "SET DateStyle = 'ISO'" if @use_iso_date_format
|
|
565
|
-
# :
|
|
565
|
+
# simplecov:enable
|
|
566
566
|
sqls
|
|
567
567
|
end
|
|
568
568
|
|
|
569
|
-
# :
|
|
569
|
+
# simplecov:disable
|
|
570
570
|
if USES_PG
|
|
571
571
|
def unescape_bytea(s)
|
|
572
572
|
::Sequel::SQL::Blob.new(Adapter.unescape_bytea(s))
|
|
573
573
|
end
|
|
574
574
|
end
|
|
575
|
-
# :
|
|
575
|
+
# simplecov:enable
|
|
576
576
|
|
|
577
577
|
DATABASE_ERROR_CLASSES = [PGError].freeze
|
|
578
578
|
def database_error_classes
|
|
@@ -586,9 +586,9 @@ module Sequel
|
|
|
586
586
|
end
|
|
587
587
|
|
|
588
588
|
def database_exception_sqlstate(exception, opts)
|
|
589
|
-
# :
|
|
589
|
+
# simplecov:disable
|
|
590
590
|
if exception.respond_to?(:result) && (result = exception.result)
|
|
591
|
-
# :
|
|
591
|
+
# simplecov:enable
|
|
592
592
|
result.error_field(PGresult::PG_DIAG_SQLSTATE)
|
|
593
593
|
end
|
|
594
594
|
end
|
|
@@ -699,9 +699,9 @@ module Sequel
|
|
|
699
699
|
clone(:where=>Sequel.lit(['CURRENT OF '], Sequel.identifier(cursor_name)))
|
|
700
700
|
end
|
|
701
701
|
|
|
702
|
-
# :
|
|
702
|
+
# simplecov:disable
|
|
703
703
|
if USES_PG
|
|
704
|
-
# :
|
|
704
|
+
# simplecov:enable
|
|
705
705
|
PREPARED_ARG_PLACEHOLDER = LiteralString.new('$').freeze
|
|
706
706
|
|
|
707
707
|
# PostgreSQL specific argument mapper used for mapping the named
|
|
@@ -804,7 +804,7 @@ module Sequel
|
|
|
804
804
|
end
|
|
805
805
|
|
|
806
806
|
# Set the columns based on the result set, and return the array of
|
|
807
|
-
# field
|
|
807
|
+
# field numbers, type conversion procs, and name symbol arrays.
|
|
808
808
|
def fetch_rows_set_cols(res)
|
|
809
809
|
cols = []
|
|
810
810
|
procs = db.conversion_procs
|
|
@@ -848,7 +848,7 @@ module Sequel
|
|
|
848
848
|
end
|
|
849
849
|
end
|
|
850
850
|
|
|
851
|
-
# :
|
|
851
|
+
# simplecov:disable
|
|
852
852
|
if Sequel::Postgres::USES_PG && !ENV['NO_SEQUEL_PG']
|
|
853
853
|
begin
|
|
854
854
|
require 'sequel_pg'
|
|
@@ -860,4 +860,4 @@ if Sequel::Postgres::USES_PG && !ENV['NO_SEQUEL_PG']
|
|
|
860
860
|
rescue LoadError
|
|
861
861
|
end
|
|
862
862
|
end
|
|
863
|
-
# :
|
|
863
|
+
# simplecov:enable
|
|
@@ -153,7 +153,7 @@ module Sequel
|
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
# REORG the related table whenever it is altered. This is not always
|
|
156
|
-
# required, but it is necessary for
|
|
156
|
+
# required, but it is necessary for compatibility with other Sequel
|
|
157
157
|
# code in many cases.
|
|
158
158
|
def apply_alter_table(name, ops)
|
|
159
159
|
alter_table_sql_list(name, ops).each do |sql|
|
|
@@ -437,7 +437,7 @@ module Sequel
|
|
|
437
437
|
'1'
|
|
438
438
|
end
|
|
439
439
|
|
|
440
|
-
# DB2 uses a literal
|
|
440
|
+
# DB2 uses a literal hexadecimal number for blob strings
|
|
441
441
|
def literal_blob_append(sql, v)
|
|
442
442
|
if db.use_clob_as_blob
|
|
443
443
|
super
|
|
@@ -42,7 +42,7 @@ module Sequel
|
|
|
42
42
|
#
|
|
43
43
|
# :result :: The result code of the stored procedure
|
|
44
44
|
# :numrows :: The number of rows affected by the stored procedure
|
|
45
|
-
# output params :: Values for any output
|
|
45
|
+
# output params :: Values for any output parameters, using the name given for the output parameter
|
|
46
46
|
#
|
|
47
47
|
# Because Sequel datasets only support a single result set per query, and retrieving
|
|
48
48
|
# the result code and number of rows requires a query, this does not support
|
|
@@ -672,7 +672,7 @@ module Sequel
|
|
|
672
672
|
end
|
|
673
673
|
end
|
|
674
674
|
|
|
675
|
-
# MSSQL treats [] as a metacharacter in LIKE
|
|
675
|
+
# MSSQL treats [] as a metacharacter in LIKE expressions.
|
|
676
676
|
def escape_like(string)
|
|
677
677
|
string.gsub(/[\\%_\[\]]/){|m| "\\#{m}"}
|
|
678
678
|
end
|
|
@@ -941,7 +941,7 @@ module Sequel
|
|
|
941
941
|
# Allow update and delete for unordered, limited datasets only.
|
|
942
942
|
def check_not_limited!(type)
|
|
943
943
|
return if @opts[:skip_limit_check] && type != :truncate
|
|
944
|
-
raise Sequel::InvalidOperation, "Dataset##{type} not
|
|
944
|
+
raise Sequel::InvalidOperation, "Dataset##{type} not supported on ordered, limited datasets" if opts[:order] && opts[:limit]
|
|
945
945
|
super if type == :truncate || @opts[:offset]
|
|
946
946
|
end
|
|
947
947
|
|
|
@@ -1040,7 +1040,7 @@ module Sequel
|
|
|
1040
1040
|
end
|
|
1041
1041
|
end
|
|
1042
1042
|
|
|
1043
|
-
# MSSQL uses a literal
|
|
1043
|
+
# MSSQL uses a literal hexadecimal number for blob strings
|
|
1044
1044
|
def literal_blob_append(sql, v)
|
|
1045
1045
|
sql << '0x' << v.unpack("H*").first
|
|
1046
1046
|
end
|
|
@@ -381,7 +381,7 @@ module Sequel
|
|
|
381
381
|
'AUTO_INCREMENT'
|
|
382
382
|
end
|
|
383
383
|
|
|
384
|
-
# MySQL needs to set transaction isolation before
|
|
384
|
+
# MySQL needs to set transaction isolation before beginning a transaction
|
|
385
385
|
def begin_new_transaction(conn, opts)
|
|
386
386
|
set_transaction_isolation(conn, opts)
|
|
387
387
|
log_connection_execute(conn, begin_transaction_sql)
|
|
@@ -937,7 +937,7 @@ module Sequel
|
|
|
937
937
|
end
|
|
938
938
|
|
|
939
939
|
# Check the database setting for whether fractional timestamps
|
|
940
|
-
# are
|
|
940
|
+
# are supported.
|
|
941
941
|
def supports_timestamp_usecs?
|
|
942
942
|
db.supports_timestamp_usecs?
|
|
943
943
|
end
|