sequel 5.30.0 → 5.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 +86 -0
- data/README.rdoc +1 -1
- data/doc/advanced_associations.rdoc +4 -4
- data/doc/association_basics.rdoc +10 -5
- data/doc/code_order.rdoc +12 -2
- data/doc/dataset_filtering.rdoc +2 -2
- data/doc/model_dataset_method_design.rdoc +1 -1
- data/doc/postgresql.rdoc +71 -0
- data/doc/release_notes/5.31.0.txt +148 -0
- data/doc/release_notes/5.32.0.txt +46 -0
- data/doc/release_notes/5.33.0.txt +24 -0
- data/doc/release_notes/5.34.0.txt +40 -0
- data/doc/release_notes/5.35.0.txt +56 -0
- data/doc/testing.rdoc +1 -1
- data/lib/sequel/adapters/oracle.rb +2 -1
- data/lib/sequel/adapters/shared/access.rb +6 -6
- data/lib/sequel/adapters/shared/mssql.rb +5 -5
- data/lib/sequel/adapters/shared/mysql.rb +9 -9
- data/lib/sequel/adapters/shared/oracle.rb +16 -16
- data/lib/sequel/adapters/shared/postgres.rb +169 -14
- data/lib/sequel/adapters/shared/sqlanywhere.rb +9 -9
- data/lib/sequel/adapters/shared/sqlite.rb +33 -6
- data/lib/sequel/adapters/tinytds.rb +1 -0
- data/lib/sequel/connection_pool/sharded_single.rb +4 -1
- data/lib/sequel/connection_pool/sharded_threaded.rb +12 -12
- data/lib/sequel/connection_pool/single.rb +1 -1
- data/lib/sequel/connection_pool/threaded.rb +2 -2
- data/lib/sequel/core.rb +318 -314
- data/lib/sequel/database/connecting.rb +1 -1
- data/lib/sequel/database/misc.rb +16 -10
- data/lib/sequel/database/query.rb +3 -1
- data/lib/sequel/database/schema_generator.rb +0 -1
- data/lib/sequel/database/schema_methods.rb +15 -16
- data/lib/sequel/database/transactions.rb +7 -4
- data/lib/sequel/dataset/placeholder_literalizer.rb +3 -7
- data/lib/sequel/dataset/query.rb +5 -4
- data/lib/sequel/deprecated.rb +3 -1
- data/lib/sequel/exceptions.rb +2 -0
- data/lib/sequel/extensions/_pretty_table.rb +1 -2
- data/lib/sequel/extensions/columns_introspection.rb +1 -2
- data/lib/sequel/extensions/connection_expiration.rb +2 -2
- data/lib/sequel/extensions/connection_validator.rb +2 -2
- data/lib/sequel/extensions/core_refinements.rb +2 -0
- data/lib/sequel/extensions/duplicate_columns_handler.rb +2 -0
- data/lib/sequel/extensions/fiber_concurrency.rb +24 -0
- data/lib/sequel/extensions/index_caching.rb +9 -7
- data/lib/sequel/extensions/integer64.rb +2 -0
- data/lib/sequel/extensions/migration.rb +1 -2
- data/lib/sequel/extensions/pg_array_ops.rb +4 -0
- data/lib/sequel/extensions/pg_enum.rb +7 -2
- data/lib/sequel/extensions/pg_extended_date_support.rb +1 -1
- data/lib/sequel/extensions/pg_hstore.rb +6 -0
- data/lib/sequel/extensions/pg_hstore_ops.rb +2 -0
- data/lib/sequel/extensions/pg_inet.rb +15 -5
- data/lib/sequel/extensions/pg_interval.rb +2 -0
- data/lib/sequel/extensions/pg_json_ops.rb +2 -0
- data/lib/sequel/extensions/pg_range.rb +5 -7
- data/lib/sequel/extensions/pg_range_ops.rb +2 -0
- data/lib/sequel/extensions/pg_row.rb +0 -1
- data/lib/sequel/extensions/pg_timestamptz.rb +2 -0
- data/lib/sequel/extensions/run_transaction_hooks.rb +72 -0
- data/lib/sequel/extensions/s.rb +2 -0
- data/lib/sequel/extensions/schema_dumper.rb +10 -4
- data/lib/sequel/extensions/server_block.rb +3 -3
- data/lib/sequel/extensions/symbol_aref_refinement.rb +2 -0
- data/lib/sequel/extensions/symbol_as_refinement.rb +2 -0
- data/lib/sequel/extensions/to_dot.rb +9 -3
- data/lib/sequel/model.rb +2 -0
- data/lib/sequel/model/associations.rb +54 -25
- data/lib/sequel/model/base.rb +70 -57
- data/lib/sequel/model/plugins.rb +3 -3
- data/lib/sequel/plugins/association_lazy_eager_option.rb +66 -0
- data/lib/sequel/plugins/association_multi_add_remove.rb +2 -0
- data/lib/sequel/plugins/association_pks.rb +60 -18
- data/lib/sequel/plugins/association_proxies.rb +2 -0
- data/lib/sequel/plugins/blacklist_security.rb +1 -2
- data/lib/sequel/plugins/boolean_subsets.rb +4 -1
- data/lib/sequel/plugins/class_table_inheritance.rb +28 -28
- data/lib/sequel/plugins/csv_serializer.rb +2 -0
- data/lib/sequel/plugins/dirty.rb +13 -13
- data/lib/sequel/plugins/forbid_lazy_load.rb +216 -0
- data/lib/sequel/plugins/instance_specific_default.rb +113 -0
- data/lib/sequel/plugins/json_serializer.rb +3 -7
- data/lib/sequel/plugins/lazy_attributes.rb +1 -1
- data/lib/sequel/plugins/pg_array_associations.rb +2 -3
- data/lib/sequel/plugins/prepared_statements.rb +5 -11
- data/lib/sequel/plugins/prepared_statements_safe.rb +1 -3
- data/lib/sequel/plugins/rcte_tree.rb +10 -16
- data/lib/sequel/plugins/single_table_inheritance.rb +15 -15
- data/lib/sequel/plugins/skip_saving_columns.rb +108 -0
- data/lib/sequel/plugins/string_stripper.rb +1 -1
- data/lib/sequel/plugins/subclasses.rb +2 -0
- data/lib/sequel/plugins/validation_class_methods.rb +5 -1
- data/lib/sequel/timezones.rb +6 -4
- data/lib/sequel/version.rb +1 -1
- metadata +18 -2
|
@@ -36,7 +36,7 @@ module Sequel
|
|
|
36
36
|
c = adapter_class(scheme)
|
|
37
37
|
uri_options = c.send(:uri_to_options, uri)
|
|
38
38
|
uri.query.split('&').map{|s| s.split('=')}.each{|k,v| uri_options[k.to_sym] = v if k && !k.empty?} unless uri.query.to_s.strip.empty?
|
|
39
|
-
uri_options.to_a.each{|k,v| uri_options[k] =
|
|
39
|
+
uri_options.to_a.each{|k,v| uri_options[k] = URI::DEFAULT_PARSER.unescape(v) if v.is_a?(String)}
|
|
40
40
|
opts = uri_options.merge(opts).merge!(:orig_opts=>opts.dup, :uri=>conn_string, :adapter=>scheme)
|
|
41
41
|
end
|
|
42
42
|
when Hash
|
data/lib/sequel/database/misc.rb
CHANGED
|
@@ -153,19 +153,23 @@ module Sequel
|
|
|
153
153
|
reset_default_dataset
|
|
154
154
|
adapter_initialize
|
|
155
155
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
keep_reference = typecast_value_boolean(@opts[:keep_reference]) != false
|
|
157
|
+
begin
|
|
158
|
+
Sequel.synchronize{::Sequel::DATABASES.push(self)} if keep_reference
|
|
159
|
+
Sequel::Database.run_after_initialize(self)
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
initialize_load_extensions(:preconnect_extensions)
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
if typecast_value_boolean(@opts[:preconnect]) && @pool.respond_to?(:preconnect, true)
|
|
164
|
+
concurrent = typecast_value_string(@opts[:preconnect]) == "concurrently"
|
|
165
|
+
@pool.send(:preconnect, concurrent)
|
|
166
|
+
end
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
initialize_load_extensions(:extensions)
|
|
169
|
+
rescue
|
|
170
|
+
Sequel.synchronize{::Sequel::DATABASES.delete(self)} if keep_reference
|
|
171
|
+
raise
|
|
172
|
+
end
|
|
169
173
|
end
|
|
170
174
|
|
|
171
175
|
# Freeze internal data structures for the Database instance.
|
|
@@ -185,7 +189,9 @@ module Sequel
|
|
|
185
189
|
|
|
186
190
|
# Disallow dup/clone for Database instances
|
|
187
191
|
undef_method :dup, :clone, :initialize_copy
|
|
192
|
+
# :nocov:
|
|
188
193
|
if RUBY_VERSION >= '1.9.3'
|
|
194
|
+
# :nocov:
|
|
189
195
|
undef_method :initialize_clone, :initialize_dup
|
|
190
196
|
end
|
|
191
197
|
|
|
@@ -325,7 +325,7 @@ module Sequel
|
|
|
325
325
|
:integer
|
|
326
326
|
when /\Adate\z/io
|
|
327
327
|
:date
|
|
328
|
-
when /\A((small)?datetime|timestamp( with(out)? time zone)?)
|
|
328
|
+
when /\A((small)?datetime|timestamp(\(\d\))?( with(out)? time zone)?)\z/io
|
|
329
329
|
:datetime
|
|
330
330
|
when /\Atime( with(out)? time zone)?\z/io
|
|
331
331
|
:time
|
|
@@ -344,7 +344,9 @@ module Sequel
|
|
|
344
344
|
|
|
345
345
|
# Post process the schema values.
|
|
346
346
|
def schema_post_process(cols)
|
|
347
|
+
# :nocov:
|
|
347
348
|
if RUBY_VERSION >= '2.5'
|
|
349
|
+
# :nocov:
|
|
348
350
|
cols.each do |_, h|
|
|
349
351
|
db_type = h[:db_type]
|
|
350
352
|
if db_type.is_a?(String)
|
|
@@ -38,7 +38,6 @@ module Sequel
|
|
|
38
38
|
@constraints = []
|
|
39
39
|
@primary_key = nil
|
|
40
40
|
instance_exec(&block) if block
|
|
41
|
-
@columns.unshift(@primary_key) if @primary_key && !has_column?(primary_key_name)
|
|
42
41
|
end
|
|
43
42
|
|
|
44
43
|
# Use custom Bignum method to use :Bignum instead of Bignum class, to work
|
|
@@ -494,7 +494,9 @@ module Sequel
|
|
|
494
494
|
when :drop_index
|
|
495
495
|
drop_index_sql(table, op)
|
|
496
496
|
else
|
|
497
|
-
|
|
497
|
+
if sql = alter_table_op_sql(table, op)
|
|
498
|
+
"ALTER TABLE #{quote_schema_table(table)} #{sql}"
|
|
499
|
+
end
|
|
498
500
|
end
|
|
499
501
|
end
|
|
500
502
|
|
|
@@ -811,23 +813,20 @@ module Sequel
|
|
|
811
813
|
# Proxy the filter_expr call to the dataset, used for creating constraints.
|
|
812
814
|
# Support passing Proc arguments as blocks, as well as treating plain strings
|
|
813
815
|
# as literal strings, so that previous migrations that used this API do not break.
|
|
814
|
-
def filter_expr(
|
|
815
|
-
if
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
elsif arg.length > 1
|
|
826
|
-
args = [Sequel.&(*arg)]
|
|
827
|
-
end
|
|
816
|
+
def filter_expr(arg=nil, &block)
|
|
817
|
+
if arg.is_a?(Proc) && !block
|
|
818
|
+
block = arg
|
|
819
|
+
arg = nil
|
|
820
|
+
elsif arg.is_a?(String)
|
|
821
|
+
arg = Sequel.lit(arg)
|
|
822
|
+
elsif arg.is_a?(Array)
|
|
823
|
+
if arg.first.is_a?(String)
|
|
824
|
+
arg = Sequel.lit(*arg)
|
|
825
|
+
elsif arg.length > 1
|
|
826
|
+
arg = Sequel.&(*arg)
|
|
828
827
|
end
|
|
829
828
|
end
|
|
830
|
-
schema_utility_dataset.literal(schema_utility_dataset.send(:filter_expr,
|
|
829
|
+
schema_utility_dataset.literal(schema_utility_dataset.send(:filter_expr, arg, &block))
|
|
831
830
|
end
|
|
832
831
|
|
|
833
832
|
# SQL statement for creating an index for the table with the given name
|
|
@@ -205,6 +205,10 @@ module Sequel
|
|
|
205
205
|
end
|
|
206
206
|
end
|
|
207
207
|
|
|
208
|
+
if opts[:savepoint] && !supports_savepoints?
|
|
209
|
+
raise Sequel::InvalidOperation, "savepoints not supported on #{database_type}"
|
|
210
|
+
end
|
|
211
|
+
|
|
208
212
|
if already_in_transaction?(conn, opts)
|
|
209
213
|
if opts[:rollback] == :always && !opts.has_key?(:savepoint)
|
|
210
214
|
if supports_savepoints?
|
|
@@ -418,11 +422,10 @@ module Sequel
|
|
|
418
422
|
end
|
|
419
423
|
|
|
420
424
|
# Retrieve the savepoint hooks that should be run for the given
|
|
421
|
-
# connection and commit status.
|
|
425
|
+
# connection and commit status. This expacts that you are
|
|
426
|
+
# already inside a savepoint when calling.
|
|
422
427
|
def savepoint_hooks(conn, committed)
|
|
423
|
-
|
|
424
|
-
_trans(conn)[:savepoints].last[committed ? :after_commit : :after_rollback]
|
|
425
|
-
end
|
|
428
|
+
_trans(conn)[:savepoints].last[committed ? :after_commit : :after_rollback]
|
|
426
429
|
end
|
|
427
430
|
|
|
428
431
|
# Retrieve the transaction hooks that should be run for the given
|
|
@@ -114,10 +114,8 @@ module Sequel
|
|
|
114
114
|
prepared_sql << sql
|
|
115
115
|
prepared_sql << "$#{prepared_args[i]}"
|
|
116
116
|
end
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
prepared_sql << final_sql
|
|
120
|
-
end
|
|
117
|
+
frags << final_sql
|
|
118
|
+
prepared_sql << final_sql
|
|
121
119
|
|
|
122
120
|
[prepared_sql, frags]
|
|
123
121
|
end
|
|
@@ -213,9 +211,7 @@ module Sequel
|
|
|
213
211
|
end
|
|
214
212
|
ds.literal_append(s, v)
|
|
215
213
|
end
|
|
216
|
-
|
|
217
|
-
s << sql
|
|
218
|
-
end
|
|
214
|
+
s << @final_sql
|
|
219
215
|
s
|
|
220
216
|
end
|
|
221
217
|
end
|
data/lib/sequel/dataset/query.rb
CHANGED
|
@@ -81,7 +81,7 @@ module Sequel
|
|
|
81
81
|
# If the options changed include options in COLUMN_CHANGE_OPTS, the cached
|
|
82
82
|
# columns are deleted. This method should generally not be called
|
|
83
83
|
# directly by user code.
|
|
84
|
-
def clone(opts = (return self
|
|
84
|
+
def clone(opts = nil || (return self))
|
|
85
85
|
# return self used above because clone is called by almost all
|
|
86
86
|
# other query methods, and it is the fastest approach
|
|
87
87
|
c = super(:freeze=>false)
|
|
@@ -330,16 +330,17 @@ module Sequel
|
|
|
330
330
|
# # SELECT * FROM a WHERE ((a LIKE '%foo%' ESCAPE '\') AND (b LIKE '%foo%' ESCAPE '\')
|
|
331
331
|
# # AND (a LIKE '%bar%' ESCAPE '\') AND (b LIKE '%bar%' ESCAPE '\'))
|
|
332
332
|
def grep(columns, patterns, opts=OPTS)
|
|
333
|
+
column_op = opts[:all_columns] ? :AND : :OR
|
|
333
334
|
if opts[:all_patterns]
|
|
334
335
|
conds = Array(patterns).map do |pat|
|
|
335
|
-
SQL::BooleanExpression.new(
|
|
336
|
+
SQL::BooleanExpression.new(column_op, *Array(columns).map{|c| SQL::StringExpression.like(c, pat, opts)})
|
|
336
337
|
end
|
|
337
|
-
where(SQL::BooleanExpression.new(
|
|
338
|
+
where(SQL::BooleanExpression.new(:AND, *conds))
|
|
338
339
|
else
|
|
339
340
|
conds = Array(columns).map do |c|
|
|
340
341
|
SQL::BooleanExpression.new(:OR, *Array(patterns).map{|pat| SQL::StringExpression.like(c, pat, opts)})
|
|
341
342
|
end
|
|
342
|
-
where(SQL::BooleanExpression.new(
|
|
343
|
+
where(SQL::BooleanExpression.new(column_op, *conds))
|
|
343
344
|
end
|
|
344
345
|
end
|
|
345
346
|
|
data/lib/sequel/deprecated.rb
CHANGED
|
@@ -39,7 +39,7 @@ module Sequel
|
|
|
39
39
|
# Print the message and possibly backtrace to the output.
|
|
40
40
|
def self.deprecate(method, instead=nil)
|
|
41
41
|
return unless output
|
|
42
|
-
message = instead ? "#{method} is deprecated and will be removed in Sequel
|
|
42
|
+
message = instead ? "#{method} is deprecated and will be removed in Sequel 6. #{instead}." : method
|
|
43
43
|
message = "#{prefix}#{message}" if prefix
|
|
44
44
|
output.puts(message)
|
|
45
45
|
case b = backtrace_filter
|
|
@@ -60,7 +60,9 @@ module Sequel
|
|
|
60
60
|
# If using ruby 2.3+, use Module#deprecate_constant to deprecate the constant,
|
|
61
61
|
# otherwise do nothing as the ruby implementation does not support constant deprecation.
|
|
62
62
|
def self.deprecate_constant(mod, constant)
|
|
63
|
+
# :nocov:
|
|
63
64
|
if RUBY_VERSION > '2.3'
|
|
65
|
+
# :nocov:
|
|
64
66
|
mod.deprecate_constant(constant)
|
|
65
67
|
end
|
|
66
68
|
end
|
data/lib/sequel/exceptions.rb
CHANGED
|
@@ -75,8 +75,7 @@ module Sequel
|
|
|
75
75
|
when SQL::Identifier
|
|
76
76
|
c.value.to_sym
|
|
77
77
|
when SQL::QualifiedIdentifier
|
|
78
|
-
|
|
79
|
-
col.is_a?(SQL::Identifier) ? col.value.to_sym : col.to_sym
|
|
78
|
+
c.column.to_sym
|
|
80
79
|
when SQL::AliasedExpression
|
|
81
80
|
a = c.alias
|
|
82
81
|
a.is_a?(SQL::Identifier) ? a.value.to_sym : a.to_sym
|
|
@@ -80,9 +80,9 @@ module Sequel
|
|
|
80
80
|
Sequel.elapsed_seconds_since(cet[0]) > cet[1]
|
|
81
81
|
|
|
82
82
|
if pool_type == :sharded_threaded
|
|
83
|
-
sync{allocated(a.last).delete(
|
|
83
|
+
sync{allocated(a.last).delete(Sequel.current)}
|
|
84
84
|
else
|
|
85
|
-
sync{@allocated.delete(
|
|
85
|
+
sync{@allocated.delete(Sequel.current)}
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
disconnect_connection(conn)
|
|
@@ -104,9 +104,9 @@ module Sequel
|
|
|
104
104
|
!db.valid_connection?(conn)
|
|
105
105
|
|
|
106
106
|
if pool_type == :sharded_threaded
|
|
107
|
-
sync{allocated(a.last).delete(
|
|
107
|
+
sync{allocated(a.last).delete(Sequel.current)}
|
|
108
108
|
else
|
|
109
|
-
sync{@allocated.delete(
|
|
109
|
+
sync{@allocated.delete(Sequel.current)}
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
disconnect_connection(conn)
|
|
@@ -39,7 +39,9 @@
|
|
|
39
39
|
|
|
40
40
|
module Sequel
|
|
41
41
|
module DuplicateColumnsHandler
|
|
42
|
+
# :nocov:
|
|
42
43
|
CALLER_ARGS = (RUBY_VERSION >= '2.0' ? [0,1] : [0]).freeze
|
|
44
|
+
# :nocov:
|
|
43
45
|
|
|
44
46
|
# Customize handling of duplicate columns for this dataset.
|
|
45
47
|
def on_duplicate_columns(handler = (raise Error, "Must provide either an argument or a block to on_duplicate_columns" unless block_given?; nil), &block)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen-string-literal: true
|
|
2
|
+
#
|
|
3
|
+
# The fiber_concurrency extension changes the default concurrency
|
|
4
|
+
# primitive in Sequel to be Fiber.current instead of Thread.current.
|
|
5
|
+
# This is the value used in various hash keys to implement safe
|
|
6
|
+
# concurrency (thread-safe concurrency by default, fiber-safe
|
|
7
|
+
# concurrency with this extension. It can be enabled via:
|
|
8
|
+
#
|
|
9
|
+
# Sequel.extension :fiber_concurrency
|
|
10
|
+
#
|
|
11
|
+
# Related module: Sequel::FiberConcurrency
|
|
12
|
+
|
|
13
|
+
require 'fiber'
|
|
14
|
+
|
|
15
|
+
module Sequel
|
|
16
|
+
module FiberConcurrency
|
|
17
|
+
# Make the current concurrency primitive be Fiber.current.
|
|
18
|
+
def current
|
|
19
|
+
Fiber.current
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
extend FiberConcurrency
|
|
24
|
+
end
|
|
@@ -54,13 +54,6 @@ module Sequel
|
|
|
54
54
|
db.instance_variable_set(:@indexes, {})
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
# Remove the index cache for the given schema name
|
|
58
|
-
def remove_cached_schema(table)
|
|
59
|
-
k = quote_schema_table(table)
|
|
60
|
-
Sequel.synchronize{@indexes.delete(k)}
|
|
61
|
-
super
|
|
62
|
-
end
|
|
63
|
-
|
|
64
57
|
# Dump the index cache to the filename given in Marshal format.
|
|
65
58
|
def dump_index_cache(file)
|
|
66
59
|
File.open(file, 'wb'){|f| f.write(Marshal.dump(@indexes))}
|
|
@@ -101,6 +94,15 @@ module Sequel
|
|
|
101
94
|
Sequel.synchronize{@indexes[quoted_name] = result}
|
|
102
95
|
result
|
|
103
96
|
end
|
|
97
|
+
|
|
98
|
+
private
|
|
99
|
+
|
|
100
|
+
# Remove the index cache for the given schema name
|
|
101
|
+
def remove_cached_schema(table)
|
|
102
|
+
k = quote_schema_table(table)
|
|
103
|
+
Sequel.synchronize{@indexes.delete(k)}
|
|
104
|
+
super
|
|
105
|
+
end
|
|
104
106
|
end
|
|
105
107
|
|
|
106
108
|
Database.register_extension(:index_caching, IndexCaching)
|
|
@@ -176,7 +176,7 @@ module Sequel
|
|
|
176
176
|
just_raise = true
|
|
177
177
|
end
|
|
178
178
|
if just_raise
|
|
179
|
-
Proc.new{raise Sequel::Error,
|
|
179
|
+
Proc.new{raise Sequel::Error, "irreversible migration method used in #{block.source_location.first}, you may need to write your own down method"}
|
|
180
180
|
else
|
|
181
181
|
actions = @actions.reverse
|
|
182
182
|
Proc.new do
|
|
@@ -518,7 +518,6 @@ module Sequel
|
|
|
518
518
|
def initialize(db, directory, opts=OPTS)
|
|
519
519
|
super
|
|
520
520
|
@current = opts[:current] || current_migration_version
|
|
521
|
-
raise(Error, "No current version available") unless current
|
|
522
521
|
|
|
523
522
|
latest_version = latest_migration_version
|
|
524
523
|
@target = if opts[:target]
|
|
@@ -157,7 +157,9 @@ module Sequel
|
|
|
157
157
|
else
|
|
158
158
|
Sequel.function(:hstore, self, wrap_array(arg))
|
|
159
159
|
end
|
|
160
|
+
# :nocov:
|
|
160
161
|
if Sequel.respond_to?(:hstore_op)
|
|
162
|
+
# :nocov:
|
|
161
163
|
v = Sequel.hstore_op(v)
|
|
162
164
|
end
|
|
163
165
|
v
|
|
@@ -283,7 +285,9 @@ module Sequel
|
|
|
283
285
|
end
|
|
284
286
|
end
|
|
285
287
|
|
|
288
|
+
# :nocov:
|
|
286
289
|
if defined?(PGArray)
|
|
290
|
+
# :nocov:
|
|
287
291
|
class PGArray
|
|
288
292
|
# Wrap the PGArray instance in an ArrayOp, allowing you to easily use
|
|
289
293
|
# the PostgreSQL array functions and operators with literal arrays.
|
|
@@ -40,8 +40,11 @@
|
|
|
40
40
|
# DB.schema(:table_name)
|
|
41
41
|
# [[:column_name, {:type=>:enum, :enum_values=>['value1', 'value2']}]]
|
|
42
42
|
#
|
|
43
|
-
#
|
|
44
|
-
#
|
|
43
|
+
# This extension integrates with the pg_array extension. If you plan
|
|
44
|
+
# to use arrays of enum types, load the pg_array extension before the
|
|
45
|
+
# pg_interval extension:
|
|
46
|
+
#
|
|
47
|
+
# DB.extension :pg_array, :pg_enum
|
|
45
48
|
#
|
|
46
49
|
# DB.create_table(:table_name) do
|
|
47
50
|
# column :column_name, 'enum_type_name[]'
|
|
@@ -178,7 +181,9 @@ module Sequel
|
|
|
178
181
|
end
|
|
179
182
|
|
|
180
183
|
# support reversible create_enum statements if the migration extension is loaded
|
|
184
|
+
# :nocov:
|
|
181
185
|
if defined?(MigrationReverser)
|
|
186
|
+
# :nocov:
|
|
182
187
|
class MigrationReverser
|
|
183
188
|
private
|
|
184
189
|
def create_enum(name, _)
|
|
@@ -189,7 +189,7 @@ module Sequel
|
|
|
189
189
|
if date < DATETIME_YEAR_1
|
|
190
190
|
date <<= ((date.year) * 24 - 12)
|
|
191
191
|
date = db.from_application_timestamp(date)
|
|
192
|
-
minutes = (date.
|
|
192
|
+
minutes = (date.offset * 1440).to_i
|
|
193
193
|
date.strftime("'%Y-%m-%d %H:%M:%S.%N#{format_timestamp_offset(*minutes.divmod(60))} BC'")
|
|
194
194
|
else
|
|
195
195
|
super
|
|
@@ -74,6 +74,12 @@
|
|
|
74
74
|
#
|
|
75
75
|
# DB.extension :pg_hstore
|
|
76
76
|
#
|
|
77
|
+
# This extension integrates with the pg_array extension. If you plan
|
|
78
|
+
# to use arrays of hstore types, load the pg_array extension before the
|
|
79
|
+
# pg_interval extension:
|
|
80
|
+
#
|
|
81
|
+
# DB.extension :pg_array, :pg_hstore
|
|
82
|
+
#
|
|
77
83
|
# See the {schema modification guide}[rdoc-ref:doc/schema_modification.rdoc]
|
|
78
84
|
# for details on using hstore columns in CREATE/ALTER TABLE statements.
|
|
79
85
|
#
|