sequel 5.109.0 → 5.110.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d532e5b8b7464ce5420441aada5a737826aadf657b7ae2d74e00947fb9073b8c
4
- data.tar.gz: 8768f69d56e2683b1a3613fb087372fb419fe5086f6e6c399278d648e106527b
3
+ metadata.gz: d4be34cd4998fd62078e4fb51023be8159bd77b389b624f007eb3b87157dca5d
4
+ data.tar.gz: 0b52ddb812f25f08739a868dcc30372cf6064d5b08de57744134a4fd9be67e86
5
5
  SHA512:
6
- metadata.gz: 9e1c3559c9fe77f574f54e6b0c67a1ab421d9cc2661aba5121693bc0a101e7d922474e443ae2c93ff55a7a4e7880c7a1eb9b6476a9b2b4b22fbb361d616996db
7
- data.tar.gz: '07583c0e8b4375f7016a8806973ff555ec8dc2225f0306b8a73535e34c1a517a3d5071299613d80b328cd1835519a5df577b372495ef793c1e58aad271ae9661'
6
+ metadata.gz: 9df7bb5f6c320bea0df51937de5afac163c30bed29c34b28da823780f3c5462afdc6dc43b6188c3eb3aad66c6b00b49b911d291d30963edb93bc357223c114a8
7
+ data.tar.gz: 2970e6a1a3f11d04fa94aeaf5f502188f013c6c30ae4d77f46f23b25cec7fc517a898a8761efc5bce72fd925816d71996a318c8292a6847015a1f201ae0e6951
@@ -180,6 +180,7 @@ module Sequel
180
180
  def adapter_initialize
181
181
  case @opts[:conn_string]
182
182
  when /Microsoft\.(Jet|ACE)\.OLEDB/i
183
+ # SEQUEL6: Remove
183
184
  require_relative 'ado/access'
184
185
  extend Sequel::ADO::Access::DatabaseMethods
185
186
  self.dataset_class = ADO::Access::Dataset
@@ -1,5 +1,7 @@
1
1
  # frozen-string-literal: true
2
2
 
3
+ Sequel::Deprecation.deprecate("Sequel's support for Microsoft Access", "Please consider maintaining it yourself as an external gem if you want to continue using it")
4
+
3
5
  require_relative '../utils/emulate_offset_with_reverse_and_count'
4
6
  require_relative '../utils/unmodified_identifiers'
5
7
  require_relative '../utils/columns_limit_1'
@@ -185,7 +187,9 @@ module Sequel
185
187
  # Access uses [] for quoting identifiers, and can't handle
186
188
  # ] inside identifiers.
187
189
  def quoted_identifier_append(sql, v)
188
- sql << '[' << v.to_s << ']'
190
+ v = v.to_s
191
+ raise Error, "Access cannot quote an identifier containing ]" if v.include?("]")
192
+ sql << '[' << v << ']'
189
193
  end
190
194
 
191
195
  # Access does not support derived column lists.
@@ -397,6 +397,13 @@ module Sequel
397
397
  end
398
398
  end
399
399
 
400
+ # Raise error if trying to quote identifier containing "
401
+ def quoted_identifier_append(sql, name)
402
+ name = name.to_s
403
+ raise Error, "Oracle cannot quote an identifier containing \"" if name.include?('"')
404
+ sql << '"' << name << '"'
405
+ end
406
+
400
407
  # Oracle requires SQL standard datetimes
401
408
  def requires_sql_standard_datetimes?
402
409
  true
@@ -134,6 +134,17 @@ module Sequel
134
134
  def exclude(elements, opts=OPTS)
135
135
  constraints << {:type => :exclude, :elements => elements}.merge!(opts)
136
136
  end
137
+
138
+ # Copies the column names, data types, and not null constraints from
139
+ # the specified table using LIKE. Arguments:
140
+ # table: Name of table to copy from
141
+ # excluding: LIKE options to exclude, can be a symbol or array of symbols
142
+ # (options: :comments, :compression:, :constraints, :defaults,
143
+ # :generated, :identity, :indexes, :statistics, :storage, :all)
144
+ # including: LIKE options to include (same values supported as excluding)
145
+ def like(table, excluding: nil, including: nil)
146
+ columns << {like_table: table, excluding: Array(excluding), including: Array(including)}
147
+ end
137
148
  end
138
149
 
139
150
  class AlterTableGenerator < Sequel::Schema::AlterTableGenerator
@@ -154,7 +165,25 @@ module Sequel
154
165
  @operations << {:op => :alter_constraint, :name => name}.merge!(opts)
155
166
  end
156
167
 
157
- # :inherit :: Set true to use INHERIT, or false to use NO INHERIT (PostgreSQL 18+)
168
+ # Attach an existing table as a partition of the altered table. This
169
+ # is preferable to using create_table with :partition_of for a number of
170
+ # reasons. Accepts the same block that you would pass to create_table with
171
+ # the :partition_of option.
172
+ def attach_partition(name, &block)
173
+ @operations << {:op => :attach_partition, :name => name, :generator => CreatePartitionOfTableGenerator.new(&block)}
174
+ end
175
+
176
+ # Detach a partition from a partitioned table. The detached partition becomes
177
+ # a separate table. Arguments:
178
+ # name: Name of partitioned table
179
+ # concurrently: Use CONCURRENTLY when detaching, which reduces the locking required.
180
+ # finalize: Use FINALIZE when detaching, to complete a case where CONCURRENTLY was
181
+ # used but could not complete the detach.
182
+ def detach_partition(name, concurrently: false, finalize: false)
183
+ @operations << {:op => :detach_partition, :name => name, :concurrently => concurrently, :finalize => finalize}
184
+ end
185
+
186
+ # Rename an constraint.
158
187
  def rename_constraint(name, new_name)
159
188
  @operations << {:op => :rename_constraint, :name => name, :new_name => new_name}
160
189
  end
@@ -1208,6 +1237,13 @@ module Sequel
1208
1237
  "ADD COLUMN#{' IF NOT EXISTS' if op[:if_not_exists]} #{column_definition_sql(op)}"
1209
1238
  end
1210
1239
 
1240
+ def alter_table_attach_partition_sql(table, op)
1241
+ sql = String.new
1242
+ sql << "ATTACH PARTITION #{quote_identifier(op[:name])}"
1243
+ partition_bound_spec_sql_append(sql, op[:generator])
1244
+ sql
1245
+ end
1246
+
1211
1247
  def alter_table_alter_constraint_sql(table, op)
1212
1248
  sql = String.new
1213
1249
  sql << "ALTER CONSTRAINT #{quote_identifier(op[:name])}"
@@ -1251,6 +1287,10 @@ module Sequel
1251
1287
  s
1252
1288
  end
1253
1289
 
1290
+ def alter_table_detach_partition_sql(table, op)
1291
+ "DETACH PARTITION #{quote_identifier(op[:name])}#{' CONCURRENTLY' if op[:concurrently]}#{' FINALIZE' if op[:finalize]}"
1292
+ end
1293
+
1254
1294
  def alter_table_drop_column_sql(table, op)
1255
1295
  "DROP COLUMN #{'IF EXISTS ' if op[:if_exists]}#{quote_identifier(op[:name])}#{' CASCADE' if op[:cascade]}"
1256
1296
  end
@@ -1293,6 +1333,33 @@ module Sequel
1293
1333
  end
1294
1334
  end
1295
1335
 
1336
+ def column_definition_sql(column)
1337
+ if table = column[:like_table]
1338
+ sql = String.new
1339
+ sql << "LIKE #{quote_schema_table(table)}"
1340
+ allowed_options = %i[comments compression constraints defaults generated identity indexes statistics storage all].freeze
1341
+
1342
+ %i[including excluding].freeze.each do |type|
1343
+ options = column[type]
1344
+ next if options.empty?
1345
+
1346
+ unallowed_options = options - allowed_options
1347
+ if unallowed_options.empty?
1348
+ type = type.to_s.upcase
1349
+ options.each do |opt|
1350
+ sql << " #{type} #{opt.to_s.upcase}"
1351
+ end
1352
+ else
1353
+ raise Error, "unsupported like :#{type} options: #{unallowed_options.inspect}"
1354
+ end
1355
+ end
1356
+
1357
+ sql
1358
+ else
1359
+ super
1360
+ end
1361
+ end
1362
+
1296
1363
  def column_definition_append_include_sql(sql, constraint)
1297
1364
  if include_cols = constraint[:include]
1298
1365
  sql << " INCLUDE " << literal(Array(include_cols))
@@ -1588,25 +1655,25 @@ module Sequel
1588
1655
  # SQL for creating a partition of another table.
1589
1656
  def create_partition_of_table_sql(name, generator, options)
1590
1657
  sql = create_table_prefix_sql(name, options).dup
1591
-
1592
1658
  sql << " PARTITION OF #{quote_schema_table(options[:partition_of])}"
1659
+ partition_bound_spec_sql_append(sql, generator)
1660
+ sql << create_table_suffix_sql(name, options)
1661
+ sql
1662
+ end
1593
1663
 
1594
- case generator.partition_type
1664
+ def partition_bound_spec_sql_append(sql, generator)
1665
+ sql << case generator.partition_type
1595
1666
  when :range
1596
1667
  from, to = generator.range
1597
- sql << " FOR VALUES FROM #{literal(from)} TO #{literal(to)}"
1668
+ " FOR VALUES FROM #{literal(from)} TO #{literal(to)}"
1598
1669
  when :list
1599
- sql << " FOR VALUES IN #{literal(generator.list)}"
1670
+ " FOR VALUES IN #{literal(generator.list)}"
1600
1671
  when :hash
1601
1672
  mod, remainder = generator.hash_values
1602
- sql << " FOR VALUES WITH (MODULUS #{literal(mod)}, REMAINDER #{literal(remainder)})"
1673
+ " FOR VALUES WITH (MODULUS #{literal(mod)}, REMAINDER #{literal(remainder)})"
1603
1674
  else # when :default
1604
- sql << " DEFAULT"
1675
+ " DEFAULT"
1605
1676
  end
1606
-
1607
- sql << create_table_suffix_sql(name, options)
1608
-
1609
- sql
1610
1677
  end
1611
1678
 
1612
1679
  # SQL for creating a schema.
data/lib/sequel/core.rb CHANGED
@@ -10,7 +10,7 @@
10
10
  # DB = Sequel.sqlite # Memory database
11
11
  # DB = Sequel.sqlite('blog.db')
12
12
  # DB = Sequel.postgres('database_name',
13
- # user:'user',
13
+ # user: 'user',
14
14
  # password: 'password',
15
15
  # host: 'host'
16
16
  # port: 5432,
@@ -25,7 +25,7 @@
25
25
  # For a more expanded introduction, see the {README}[rdoc-ref:README.rdoc].
26
26
  # For a quicker introduction, see the {cheat sheet}[rdoc-ref:doc/cheat_sheet.rdoc].
27
27
  module Sequel
28
- @convert_two_digit_years = true
28
+ @convert_two_digit_years = true # SEQUEL6: Remove
29
29
  @datetime_class = Time # SEQUEL6: Remove
30
30
  @split_symbols = false # SEQUEL6: Remove
31
31
  @single_threaded = false
@@ -37,6 +37,8 @@ module Sequel
37
37
  OPTS = {}.freeze
38
38
 
39
39
  SPLIT_SYMBOL_CACHE = {} # SEQUEL6: Remove
40
+ SPLIT_SYMBOL_CACHE_ = SPLIT_SYMBOL_CACHE
41
+ private_constant :SPLIT_SYMBOL_CACHE_
40
42
 
41
43
  module SequelMethods
42
44
  # Sequel converts two digit years in <tt>Date</tt>s and <tt>DateTime</tt>s by default,
@@ -45,7 +47,16 @@ module Sequel
45
47
  # January 2nd, 0003 and December 13, 0099, respectively, by:
46
48
  #
47
49
  # Sequel.convert_two_digit_years = false
48
- attr_accessor :convert_two_digit_years
50
+ #
51
+ # The setter method is deprecated and will be removed in Sequel 6.
52
+ # The reader method will be deprecated in Sequel 6.0 and removed in
53
+ # Sequel 6.1.
54
+ attr_reader :convert_two_digit_years # SEQUEL6.1: Remove
55
+
56
+ def convert_two_digit_years=(v)
57
+ Sequel::Deprecation.deprecate("Sequel.convert_two_digit_years= is deprecated and will be removed in Sequel 6.")
58
+ @convert_two_digit_years = v
59
+ end
49
60
 
50
61
  # Sequel can use either +Time+ or +DateTime+ for times returned from the
51
62
  # database. It defaults to +Time+. To change it to +DateTime+:
@@ -55,9 +66,16 @@ module Sequel
55
66
  # Note that +Time+ and +DateTime+ objects have a different API, and in
56
67
  # cases where they implement the same methods, they often implement them
57
68
  # differently (e.g. + using seconds on +Time+ and days on +DateTime+).
58
- attr_accessor :datetime_class
59
- # SEQUEL6: Remove datetime_class=
60
- # SEQUEL6.1: Remove datetime_class
69
+ #
70
+ # The setter method is deprecated and will be removed in Sequel 6.
71
+ # The reader method will be deprecated in Sequel 6.0 and removed in
72
+ # Sequel 6.1.
73
+ attr_reader :datetime_class # SEQUEL6.1: Remove
74
+
75
+ def datetime_class=(v)
76
+ Sequel::Deprecation.deprecate("Sequel.datetime_class= is deprecated and will be removed in Sequel 6.")
77
+ @datetime_class = v
78
+ end
61
79
 
62
80
  # Set whether Sequel is being used in single threaded mode. By default,
63
81
  # Sequel uses a thread-safe connection pool, which isn't as fast as the
@@ -68,8 +86,8 @@ module Sequel
68
86
  # Sequel.single_threaded = true
69
87
  attr_accessor :single_threaded
70
88
 
71
- # # SEQUEL6: Remove
72
- alias orig_require require
89
+ # SEQUEL6: Remove
90
+ define_method(:orig_require, Kernel.instance_method(:require))
73
91
  private :orig_require
74
92
 
75
93
  # Returns true if the passed object could be a specifier of conditions, false otherwise.
@@ -92,7 +110,7 @@ module Sequel
92
110
  end
93
111
  end
94
112
 
95
- # Creates a new database object based on the supplied connection string
113
+ # Creates a new Database object based on the supplied connection string
96
114
  # and optional arguments. The specified scheme determines the database
97
115
  # class used, and the rest of the string specifies the connection options.
98
116
  # For example:
@@ -163,19 +181,23 @@ module Sequel
163
181
  raise Error, "cannot use extension with ../ for security reasons"
164
182
  end
165
183
 
166
- orig_require("sequel/extensions/#{e}")
184
+ Kernel.require("sequel/extensions/#{e}")
167
185
  end
168
186
  end
169
187
 
170
- # The exception classed raised if there is an error parsing JSON.
188
+ # The exception class raised if there is an error parsing JSON.
171
189
  # This can be overridden to use an alternative json implementation.
172
- def json_parser_error_class
190
+ #
191
+ # This method is deprecated and will be removed in Sequel 6.1.
192
+ def json_parser_error_class # SEQUEL6.1: Remove
173
193
  JSON::ParserError
174
194
  end
175
195
 
176
196
  if RUBY_VERSION >= '3'
177
197
  # Join the array or set.
178
- def array_or_set_join(obj, arg)
198
+ #
199
+ # This method is deprecated and will be removed in Sequel 6.1.
200
+ def array_or_set_join(obj, arg) # SEQUEL6.1: Remove
179
201
  obj.join(arg)
180
202
  end
181
203
  # simplecov:disable
@@ -204,13 +226,17 @@ module Sequel
204
226
 
205
227
  # Convert given object to json and return the result.
206
228
  # This can be overridden to use an alternative json implementation.
207
- def object_to_json(obj, *args, &block)
229
+ #
230
+ # This method is deprecated and will be removed in Sequel 6.1.
231
+ def object_to_json(obj, *args, &block) # SEQUEL6.1: Remove
208
232
  obj.to_json(*args, &block)
209
233
  end
210
234
 
211
235
  # Parse the string as JSON and return the result.
212
236
  # This can be overridden to use an alternative json implementation.
213
- def parse_json(json)
237
+ #
238
+ # This method is deprecated and will be removed in Sequel 6.1.
239
+ def parse_json(json) # SEQUEL6.1: Remove
214
240
  if JSON::VERSION >= '3'
215
241
  JSON.parse(json)
216
242
  else
@@ -261,7 +287,7 @@ module Sequel
261
287
  # For tables, these parts are the schema, table, and alias.
262
288
  def split_symbol(sym)
263
289
  # SEQUEL6.1: Remove
264
- unless v = Sequel.synchronize{SPLIT_SYMBOL_CACHE[sym]}
290
+ unless v = Sequel.synchronize{SPLIT_SYMBOL_CACHE_[sym]}
265
291
  if split_symbols?
266
292
  v = case s = sym.to_s
267
293
  when /\A((?:(?!__).)+)__((?:(?!___).)+)___(.+)\z/
@@ -276,7 +302,7 @@ module Sequel
276
302
  else
277
303
  v = [nil,sym.to_s.freeze,nil].freeze
278
304
  end
279
- Sequel.synchronize{SPLIT_SYMBOL_CACHE[sym] = v}
305
+ Sequel.synchronize{SPLIT_SYMBOL_CACHE_[sym] = v}
280
306
  end
281
307
  v
282
308
  end
@@ -312,8 +338,8 @@ module Sequel
312
338
  # Sequel.expr{table__column} # table__column
313
339
  # Sequel.expr{table[:column]} # table.column
314
340
  def split_symbols=(v)
315
- # SEQUEL6: Remove
316
- Sequel.synchronize{SPLIT_SYMBOL_CACHE.clear}
341
+ Sequel::Deprecation.deprecate("Sequel.split_symbols= is deprecated and will be removed in Sequel 6.")
342
+ Sequel.synchronize{SPLIT_SYMBOL_CACHE_.clear}
317
343
  @split_symbols = v
318
344
  end
319
345
 
@@ -336,7 +362,9 @@ module Sequel
336
362
  # value of <tt>Sequel.datetime_class</tt>.
337
363
  #
338
364
  # Sequel.string_to_datetime('2010-09-10 10:20:30') # Time.local(2010, 09, 10, 10, 20, 30)
339
- def string_to_datetime(string)
365
+ #
366
+ # This method is deprecated and will be removed in Sequel 6.1.
367
+ def string_to_datetime(string) # SEQUEL6.1: Remove
340
368
  if datetime_class == DateTime
341
369
  DateTime.parse(string, convert_two_digit_years)
342
370
  else
@@ -368,7 +396,10 @@ module Sequel
368
396
  if RUBY_VERSION >= '2.1'
369
397
  # A timer object that can be passed to Sequel.elapsed_seconds_since
370
398
  # to return the number of seconds elapsed.
371
- def start_timer
399
+ #
400
+ # This method is deprecated and will be removed in Sequel 6.1 (or
401
+ # potentially in 6.0 if Ruby 2.1 support is dropped before 6.0).
402
+ def start_timer # SEQUEL6.1: Remove
372
403
  Process.clock_gettime(Process::CLOCK_MONOTONIC)
373
404
  end
374
405
  else
@@ -381,7 +412,10 @@ module Sequel
381
412
 
382
413
  # The elapsed seconds since the given timer object was created. The
383
414
  # timer object should have been created via Sequel.start_timer.
384
- def elapsed_seconds_since(timer)
415
+ #
416
+ # This method is deprecated and will be removed in Sequel 6.1 (or
417
+ # potentially in 6.0 if Ruby 2.1 support is dropped before 6.0).
418
+ def elapsed_seconds_since(timer) # SEQUEL6.1: Remove
385
419
  start_timer - timer
386
420
  end
387
421
 
@@ -493,4 +527,6 @@ module Sequel
493
527
 
494
528
  # Add the database adapter class methods to Sequel via metaprogramming
495
529
  def_adapter_method(*Database::ADAPTERS)
530
+
531
+ Deprecation.deprecate_constant(self, :SPLIT_SYMBOL_CACHE)
496
532
  end
@@ -170,18 +170,18 @@ module Sequel
170
170
  # :engine :: The table engine to use for the table.
171
171
  #
172
172
  # PostgreSQL specific options:
173
- # :on_commit :: Either :preserve_rows (default), :drop or :delete_rows. Should
174
- # only be specified when creating a temporary table.
175
173
  # :foreign :: Create a foreign table. The value should be the name of the
176
174
  # foreign server that was specified in CREATE SERVER.
177
175
  # :inherits :: Inherit from a different table. An array can be
178
176
  # specified to inherit from multiple tables.
179
- # :unlogged :: Create the table as an unlogged table.
177
+ # :on_commit :: Either :preserve_rows (default), :drop or :delete_rows. Should
178
+ # only be specified when creating a temporary table.
180
179
  # :options :: The OPTIONS clause to use for foreign tables. Should be a hash
181
180
  # where keys are option names and values are option values. Note
182
181
  # that option names are unquoted, so you should not use untrusted
183
182
  # keys.
184
183
  # :tablespace :: The tablespace to use for the table.
184
+ # :unlogged :: Create the table as an unlogged table.
185
185
  #
186
186
  # SQLite specific options:
187
187
  # :strict :: Create a STRICT table, which checks that the values for the columns
@@ -38,7 +38,7 @@ module Sequel
38
38
  private
39
39
 
40
40
  # Literalize custom DateTime subclass objects as CURRENT_TIMESTAMP.
41
- def literal_datetime_append(sql, v)
41
+ def literal_datetime_append(sql, v) # SEQUEL6: Remove
42
42
  v.is_a?(DateTime) ? literal_append(sql, Sequel::CURRENT_TIMESTAMP) : super
43
43
  end
44
44
 
@@ -52,7 +52,7 @@ module Sequel
52
52
  class Time < ::Time; end
53
53
 
54
54
  # DateTime subclass literalized as CURRENT_TIMESTAMP
55
- class DateTime < ::DateTime; end
55
+ class DateTime < ::DateTime; end # SEQUEL6.1: Remove
56
56
  end
57
57
 
58
58
  Dataset.register_extension(:current_datetime_timestamp, CurrentDateTimeTimestamp::DatasetMethods)
@@ -1,17 +1,17 @@
1
1
  # frozen-string-literal: true
2
2
  #
3
3
  # Allows the use of named timezones via TZInfo (requires tzinfo).
4
- # Forces the use of DateTime as Sequel's datetime_class, since
4
+ # Forces the use of DateTime as Sequel's datetime_class by default, since
5
5
  # historically, Ruby's Time class doesn't support timezones other
6
6
  # than local and UTC. To continue using Ruby's Time class when using
7
- # the named_timezones extension:
7
+ # the named_timezones extension, set the
8
+ # +SEQUEL_NAMED_TIMEZONES_USE_TIME+ environment variable before
9
+ # loading the extension:
8
10
  #
9
11
  # # Load the extension
12
+ # ENV['SEQUEL_NAMED_TIMEZONES_USE_TIME'] = "1"
10
13
  # Sequel.extension :named_timezones
11
14
  #
12
- # # Set Sequel.datetime_class back to Time
13
- # Sequel.datetime_class = Time
14
- #
15
15
  # This allows you to either pass strings or TZInfo::Timezone
16
16
  # instance to Sequel.database_timezone=, application_timezone=, and
17
17
  # typecast_timezone=. If a string is passed, it is converted to a
@@ -49,7 +49,9 @@ require 'tzinfo'
49
49
 
50
50
  #
51
51
  module Sequel
52
- self.datetime_class = DateTime
52
+ # simplecov:disable
53
+ self.datetime_class = DateTime unless ENV["SEQUEL_NAMED_TIMEZONES_USE_TIME"]
54
+ # simplecov:enable
53
55
 
54
56
  module NamedTimezones
55
57
  module DatabaseMethods
@@ -10,7 +10,11 @@
10
10
  #
11
11
  # DB.loose_count(Sequel[:schema][:table]) # => 123456
12
12
  #
13
- # How accurate this count is depends on the number of rows
13
+ # To get the loose count of all tables in a given schema:
14
+ #
15
+ # DB.loose_counts(:schema) # => {table: 123456, ...}
16
+ #
17
+ # How accurate these counts are depends on the number of rows
14
18
  # added/deleted from the table since the last time it was
15
19
  # analyzed. If the table has not been vacuumed or analyzed
16
20
  # yet, this can return 0 or -1 depending on the PostgreSQL
@@ -31,9 +35,40 @@ module Sequel
31
35
  def loose_count(table)
32
36
  from(:pg_class).where(:oid=>regclass_oid(table)).get(Sequel.cast(:reltuples, Integer))
33
37
  end
38
+
39
+ # Look at the table statistics for the given schema and return a
40
+ # hash with table name keys and approximate counts. Results include
41
+ # normal tables, materialized views, and partitioned tables.
42
+ def loose_counts(schema)
43
+ case schema
44
+ when Symbol
45
+ schema = schema.to_s
46
+ when String
47
+ nil
48
+ when SQL::Identifier
49
+ schema = schema.value.to_s
50
+ else
51
+ raise Error, "unsupported argument type, should be symbol, string, or Sequel::SQL::Identifier, given #{schema.inspect}"
52
+ end
53
+
54
+ namespace_oid = if server_version >= 90500
55
+ Sequel.function(:to_regnamespace, schema).cast(:oid)
56
+ else
57
+ from(:pg_namespace).where(nspname: schema).select(:oid)
58
+ end
59
+
60
+ hash = {}
61
+ from(:pg_class).
62
+ where(relnamespace: namespace_oid, relkind: %w"r m p").
63
+ order(:relname).
64
+ select_map([:relname, Sequel.cast(:reltuples, Integer).as(:v)]).
65
+ each do |k, v|
66
+ hash[k.to_sym] = v
67
+ end
68
+ hash
69
+ end
34
70
  end
35
71
  end
36
72
 
37
73
  Database.register_extension(:pg_loose_count, Postgres::LooseCount)
38
74
  end
39
-
@@ -84,10 +84,6 @@
84
84
  # # SELECT * FROM albums -- model:Album,action:all -- Some Comment
85
85
  # end
86
86
  #
87
- # Note that Microsoft Access does not support inline comments,
88
- # and attempting to use comments on it will result in SQL syntax
89
- # errors.
90
- #
91
87
  # Related modules: Sequel::SQLComments, Sequel::Database::SQLComments
92
88
 
93
89
  #
@@ -22,14 +22,17 @@ class String
22
22
 
23
23
  # Converts a string into a DateTime object.
24
24
  def to_datetime
25
- DateTime.parse(self, Sequel.convert_two_digit_years)
26
- rescue => e
27
- raise Sequel.convert_exception_class(e, Sequel::InvalidValue)
25
+ Sequel::Deprecation.deprecate("String#to_datetime is deprecated and will be removed in Sequel 6.")
26
+ begin
27
+ DateTime.parse(self, Sequel.convert_two_digit_years)
28
+ rescue => e
29
+ raise Sequel.convert_exception_class(e, Sequel::InvalidValue)
30
+ end
28
31
  end
29
32
 
30
33
  # Converts a string into a Time or DateTime object, depending on the
31
34
  # value of Sequel.datetime_class
32
- def to_sequel_time
35
+ def to_sequel_time # SEQUEL6: Simplify making an alias to to_time
33
36
  if Sequel.datetime_class == DateTime
34
37
  DateTime.parse(self, Sequel.convert_two_digit_years)
35
38
  else
@@ -1188,7 +1188,7 @@ END
1188
1188
  # By default it calls send with the argument to get the value. This can
1189
1189
  # be overridden if you have columns that conflict with existing
1190
1190
  # method names.
1191
- alias get_column_value send
1191
+ define_method(:get_column_value, Kernel.instance_method(:send))
1192
1192
 
1193
1193
  # Set the value of the column. Takes two arguments. The first is a
1194
1194
  # symbol or string argument for the column name, suffixed with =. The
@@ -1196,7 +1196,7 @@ END
1196
1196
  # with the argument to set the value. This can be overridden if you have
1197
1197
  # columns that conflict with existing method names (unlikely for setter
1198
1198
  # methods, but possible).
1199
- alias set_column_value send
1199
+ define_method(:set_column_value, Kernel.instance_method(:send))
1200
1200
 
1201
1201
  # Creates new instance and passes the given values to set.
1202
1202
  # If a block is given, yield the instance to the block.
@@ -1293,7 +1293,7 @@ END
1293
1293
  # self.class.
1294
1294
  #
1295
1295
  # Artist.new.model # => Artist
1296
- alias_method :model, :class
1296
+ define_method(:model, Kernel.instance_method(:class))
1297
1297
 
1298
1298
  # The autoincrementing primary key for this model object. Should be
1299
1299
  # overridden if you have a composite primary key with one part of it
@@ -6,7 +6,7 @@ module Sequel
6
6
 
7
7
  # The minor version of Sequel. Bumped for every non-patch level
8
8
  # release, generally around once a month.
9
- MINOR = 109
9
+ MINOR = 110
10
10
 
11
11
  # The tiny version of Sequel. Usually 0, only bumped for bugfix
12
12
  # releases that fix regressions from previous versions.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.109.0
4
+ version: 5.110.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans