sequel 3.47.0 → 3.48.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +230 -0
- data/README.rdoc +31 -40
- data/Rakefile +1 -14
- data/doc/active_record.rdoc +29 -29
- data/doc/association_basics.rdoc +4 -13
- data/doc/cheat_sheet.rdoc +8 -6
- data/doc/code_order.rdoc +89 -0
- data/doc/core_extensions.rdoc +3 -3
- data/doc/dataset_basics.rdoc +7 -8
- data/doc/dataset_filtering.rdoc +7 -2
- data/doc/mass_assignment.rdoc +2 -3
- data/doc/migration.rdoc +8 -8
- data/doc/model_hooks.rdoc +11 -7
- data/doc/object_model.rdoc +2 -2
- data/doc/opening_databases.rdoc +5 -14
- data/doc/prepared_statements.rdoc +5 -9
- data/doc/querying.rdoc +23 -28
- data/doc/reflection.rdoc +11 -0
- data/doc/release_notes/3.48.0.txt +477 -0
- data/doc/schema_modification.rdoc +12 -5
- data/doc/security.rdoc +2 -2
- data/doc/sharding.rdoc +1 -2
- data/doc/sql.rdoc +10 -13
- data/doc/testing.rdoc +8 -4
- data/doc/transactions.rdoc +2 -2
- data/doc/validations.rdoc +40 -17
- data/doc/virtual_rows.rdoc +2 -2
- data/lib/sequel/adapters/ado.rb +25 -20
- data/lib/sequel/adapters/ado/access.rb +1 -0
- data/lib/sequel/adapters/ado/mssql.rb +1 -0
- data/lib/sequel/adapters/db2.rb +9 -7
- data/lib/sequel/adapters/dbi.rb +16 -16
- data/lib/sequel/adapters/do.rb +17 -18
- data/lib/sequel/adapters/do/mysql.rb +1 -0
- data/lib/sequel/adapters/do/postgres.rb +2 -0
- data/lib/sequel/adapters/do/sqlite.rb +1 -0
- data/lib/sequel/adapters/firebird.rb +5 -7
- data/lib/sequel/adapters/ibmdb.rb +23 -20
- data/lib/sequel/adapters/informix.rb +8 -2
- data/lib/sequel/adapters/jdbc.rb +39 -35
- data/lib/sequel/adapters/jdbc/as400.rb +1 -0
- data/lib/sequel/adapters/jdbc/cubrid.rb +1 -0
- data/lib/sequel/adapters/jdbc/db2.rb +1 -0
- data/lib/sequel/adapters/jdbc/derby.rb +1 -0
- data/lib/sequel/adapters/jdbc/firebird.rb +1 -0
- data/lib/sequel/adapters/jdbc/h2.rb +1 -0
- data/lib/sequel/adapters/jdbc/hsqldb.rb +1 -0
- data/lib/sequel/adapters/jdbc/informix.rb +1 -0
- data/lib/sequel/adapters/jdbc/jtds.rb +1 -0
- data/lib/sequel/adapters/jdbc/mssql.rb +1 -0
- data/lib/sequel/adapters/jdbc/mysql.rb +1 -0
- data/lib/sequel/adapters/jdbc/oracle.rb +1 -0
- data/lib/sequel/adapters/jdbc/postgresql.rb +2 -0
- data/lib/sequel/adapters/jdbc/progress.rb +1 -0
- data/lib/sequel/adapters/jdbc/sqlite.rb +1 -0
- data/lib/sequel/adapters/jdbc/sqlserver.rb +1 -0
- data/lib/sequel/adapters/mock.rb +30 -31
- data/lib/sequel/adapters/mysql.rb +6 -7
- data/lib/sequel/adapters/mysql2.rb +5 -6
- data/lib/sequel/adapters/odbc.rb +22 -20
- data/lib/sequel/adapters/odbc/mssql.rb +1 -0
- data/lib/sequel/adapters/openbase.rb +4 -1
- data/lib/sequel/adapters/oracle.rb +10 -8
- data/lib/sequel/adapters/postgres.rb +12 -10
- data/lib/sequel/adapters/shared/access.rb +6 -0
- data/lib/sequel/adapters/shared/cubrid.rb +2 -0
- data/lib/sequel/adapters/shared/db2.rb +2 -0
- data/lib/sequel/adapters/shared/firebird.rb +2 -0
- data/lib/sequel/adapters/shared/informix.rb +2 -0
- data/lib/sequel/adapters/shared/mssql.rb +14 -8
- data/lib/sequel/adapters/shared/mysql.rb +6 -0
- data/lib/sequel/adapters/shared/oracle.rb +2 -0
- data/lib/sequel/adapters/shared/postgres.rb +14 -4
- data/lib/sequel/adapters/shared/progress.rb +1 -0
- data/lib/sequel/adapters/shared/sqlite.rb +4 -3
- data/lib/sequel/adapters/sqlite.rb +6 -7
- data/lib/sequel/adapters/swift.rb +20 -21
- data/lib/sequel/adapters/swift/mysql.rb +1 -0
- data/lib/sequel/adapters/swift/postgres.rb +2 -0
- data/lib/sequel/adapters/swift/sqlite.rb +1 -0
- data/lib/sequel/adapters/tinytds.rb +5 -6
- data/lib/sequel/adapters/utils/emulate_offset_with_reverse_and_count.rb +68 -0
- data/lib/sequel/connection_pool.rb +1 -1
- data/lib/sequel/core.rb +57 -50
- data/lib/sequel/database/connecting.rb +9 -10
- data/lib/sequel/database/dataset.rb +11 -6
- data/lib/sequel/database/dataset_defaults.rb +61 -69
- data/lib/sequel/database/features.rb +21 -0
- data/lib/sequel/database/misc.rb +23 -3
- data/lib/sequel/database/query.rb +13 -7
- data/lib/sequel/database/schema_methods.rb +6 -6
- data/lib/sequel/database/transactions.rb +1 -0
- data/lib/sequel/dataset/actions.rb +51 -38
- data/lib/sequel/dataset/features.rb +1 -0
- data/lib/sequel/dataset/graph.rb +9 -33
- data/lib/sequel/dataset/misc.rb +30 -5
- data/lib/sequel/dataset/mutation.rb +2 -3
- data/lib/sequel/dataset/prepared_statements.rb +1 -1
- data/lib/sequel/dataset/query.rb +91 -27
- data/lib/sequel/dataset/sql.rb +40 -6
- data/lib/sequel/deprecated.rb +74 -0
- data/lib/sequel/deprecated_core_extensions.rb +135 -0
- data/lib/sequel/extensions/columns_introspection.rb +1 -5
- data/lib/sequel/extensions/core_extensions.rb +10 -3
- data/lib/sequel/extensions/date_arithmetic.rb +1 -0
- data/lib/sequel/extensions/empty_array_ignore_nulls.rb +33 -0
- data/lib/sequel/extensions/filter_having.rb +58 -0
- data/lib/sequel/extensions/graph_each.rb +63 -0
- data/lib/sequel/extensions/hash_aliases.rb +44 -0
- data/lib/sequel/extensions/looser_typecasting.rb +14 -3
- data/lib/sequel/extensions/migration.rb +2 -3
- data/lib/sequel/extensions/named_timezones.rb +14 -1
- data/lib/sequel/extensions/null_dataset.rb +7 -1
- data/lib/sequel/extensions/pagination.rb +15 -5
- data/lib/sequel/extensions/pg_auto_parameterize.rb +1 -0
- data/lib/sequel/extensions/pg_hstore_ops.rb +48 -14
- data/lib/sequel/extensions/pg_json.rb +7 -7
- data/lib/sequel/extensions/pg_range_ops.rb +8 -2
- data/lib/sequel/extensions/pg_statement_cache.rb +1 -0
- data/lib/sequel/extensions/pretty_table.rb +13 -4
- data/lib/sequel/extensions/query.rb +21 -4
- data/lib/sequel/extensions/ruby18_symbol_extensions.rb +22 -0
- data/lib/sequel/extensions/schema_caching.rb +10 -7
- data/lib/sequel/extensions/schema_dumper.rb +35 -48
- data/lib/sequel/extensions/select_remove.rb +13 -4
- data/lib/sequel/extensions/sequel_3_dataset_methods.rb +117 -0
- data/lib/sequel/extensions/set_overrides.rb +43 -0
- data/lib/sequel/extensions/to_dot.rb +6 -0
- data/lib/sequel/model.rb +12 -6
- data/lib/sequel/model/associations.rb +80 -38
- data/lib/sequel/model/base.rb +137 -52
- data/lib/sequel/model/errors.rb +7 -2
- data/lib/sequel/plugins/active_model.rb +13 -0
- data/lib/sequel/plugins/after_initialize.rb +43 -0
- data/lib/sequel/plugins/association_proxies.rb +63 -7
- data/lib/sequel/plugins/auto_validations.rb +56 -16
- data/lib/sequel/plugins/blacklist_security.rb +63 -0
- data/lib/sequel/plugins/class_table_inheritance.rb +9 -0
- data/lib/sequel/plugins/constraint_validations.rb +50 -8
- data/lib/sequel/plugins/dataset_associations.rb +2 -0
- data/lib/sequel/plugins/hook_class_methods.rb +7 -1
- data/lib/sequel/plugins/identity_map.rb +4 -0
- data/lib/sequel/plugins/json_serializer.rb +32 -13
- data/lib/sequel/plugins/optimistic_locking.rb +1 -1
- data/lib/sequel/plugins/rcte_tree.rb +4 -4
- data/lib/sequel/plugins/scissors.rb +33 -0
- data/lib/sequel/plugins/serialization.rb +1 -1
- data/lib/sequel/plugins/single_table_inheritance.rb +6 -0
- data/lib/sequel/plugins/tree.rb +5 -1
- data/lib/sequel/plugins/validation_class_methods.rb +2 -1
- data/lib/sequel/plugins/validation_helpers.rb +15 -11
- data/lib/sequel/plugins/xml_serializer.rb +12 -3
- data/lib/sequel/sql.rb +12 -2
- data/lib/sequel/timezones.rb +1 -1
- data/lib/sequel/version.rb +1 -1
- data/lib/sequel_core.rb +1 -0
- data/lib/sequel_model.rb +1 -0
- data/spec/adapters/mssql_spec.rb +24 -57
- data/spec/adapters/postgres_spec.rb +27 -55
- data/spec/adapters/spec_helper.rb +1 -1
- data/spec/adapters/sqlite_spec.rb +1 -1
- data/spec/bin_spec.rb +251 -0
- data/spec/core/database_spec.rb +46 -32
- data/spec/core/dataset_spec.rb +233 -181
- data/spec/core/deprecated_spec.rb +78 -0
- data/spec/core/expression_filters_spec.rb +3 -4
- data/spec/core/mock_adapter_spec.rb +9 -9
- data/spec/core/object_graph_spec.rb +9 -19
- data/spec/core/schema_spec.rb +3 -1
- data/spec/core/spec_helper.rb +19 -0
- data/spec/core_extensions_spec.rb +80 -30
- data/spec/extensions/after_initialize_spec.rb +24 -0
- data/spec/extensions/association_proxies_spec.rb +37 -1
- data/spec/extensions/auto_validations_spec.rb +20 -4
- data/spec/extensions/blacklist_security_spec.rb +87 -0
- data/spec/extensions/boolean_readers_spec.rb +2 -1
- data/spec/extensions/class_table_inheritance_spec.rb +7 -0
- data/spec/extensions/columns_introspection_spec.rb +3 -3
- data/spec/extensions/constraint_validations_plugin_spec.rb +83 -5
- data/spec/extensions/core_refinements_spec.rb +7 -7
- data/spec/extensions/dataset_associations_spec.rb +2 -2
- data/spec/extensions/date_arithmetic_spec.rb +1 -1
- data/spec/extensions/defaults_setter_spec.rb +2 -1
- data/spec/extensions/empty_array_ignore_nulls_spec.rb +24 -0
- data/spec/extensions/filter_having_spec.rb +40 -0
- data/spec/extensions/graph_each_spec.rb +109 -0
- data/spec/extensions/hash_aliases_spec.rb +16 -0
- data/spec/extensions/hook_class_methods_spec.rb +2 -2
- data/spec/extensions/identity_map_spec.rb +3 -3
- data/spec/extensions/json_serializer_spec.rb +19 -19
- data/spec/extensions/lazy_attributes_spec.rb +1 -0
- data/spec/extensions/list_spec.rb +13 -13
- data/spec/extensions/looser_typecasting_spec.rb +10 -3
- data/spec/extensions/many_through_many_spec.rb +1 -1
- data/spec/extensions/migration_spec.rb +7 -7
- data/spec/extensions/named_timezones_spec.rb +6 -0
- data/spec/extensions/nested_attributes_spec.rb +2 -2
- data/spec/extensions/null_dataset_spec.rb +1 -1
- data/spec/extensions/pagination_spec.rb +2 -2
- data/spec/extensions/pg_hstore_ops_spec.rb +75 -0
- data/spec/extensions/pg_range_ops_spec.rb +4 -2
- data/spec/extensions/pg_row_plugin_spec.rb +1 -1
- data/spec/extensions/pretty_table_spec.rb +1 -1
- data/spec/extensions/query_literals_spec.rb +1 -1
- data/spec/extensions/query_spec.rb +3 -3
- data/spec/extensions/schema_caching_spec.rb +3 -3
- data/spec/extensions/schema_dumper_spec.rb +27 -2
- data/spec/extensions/schema_spec.rb +2 -2
- data/spec/extensions/scissors_spec.rb +26 -0
- data/spec/extensions/select_remove_spec.rb +1 -1
- data/spec/extensions/sequel_3_dataset_methods_spec.rb +102 -0
- data/spec/extensions/set_overrides_spec.rb +45 -0
- data/spec/extensions/single_table_inheritance_spec.rb +10 -0
- data/spec/extensions/spec_helper.rb +24 -1
- data/spec/extensions/static_cache_spec.rb +1 -1
- data/spec/extensions/string_stripper_spec.rb +2 -1
- data/spec/extensions/to_dot_spec.rb +1 -1
- data/spec/extensions/typecast_on_load_spec.rb +3 -2
- data/spec/extensions/update_primary_key_spec.rb +2 -2
- data/spec/extensions/validation_class_methods_spec.rb +19 -19
- data/spec/extensions/validation_helpers_spec.rb +30 -21
- data/spec/extensions/xml_serializer_spec.rb +5 -5
- data/spec/integration/associations_test.rb +10 -30
- data/spec/integration/dataset_test.rb +20 -24
- data/spec/integration/eager_loader_test.rb +5 -5
- data/spec/integration/model_test.rb +3 -3
- data/spec/integration/plugin_test.rb +7 -39
- data/spec/integration/schema_test.rb +4 -38
- data/spec/integration/spec_helper.rb +2 -1
- data/spec/model/association_reflection_spec.rb +70 -5
- data/spec/model/associations_spec.rb +11 -11
- data/spec/model/base_spec.rb +25 -8
- data/spec/model/class_dataset_methods_spec.rb +143 -0
- data/spec/model/dataset_methods_spec.rb +1 -1
- data/spec/model/eager_loading_spec.rb +25 -25
- data/spec/model/hooks_spec.rb +1 -1
- data/spec/model/model_spec.rb +22 -7
- data/spec/model/plugins_spec.rb +1 -6
- data/spec/model/record_spec.rb +37 -29
- data/spec/model/spec_helper.rb +23 -1
- data/spec/model/validations_spec.rb +15 -17
- metadata +32 -3
data/lib/sequel/dataset/sql.rb
CHANGED
@@ -336,6 +336,7 @@ module Sequel
|
|
336
336
|
# Do not call this method with untrusted input, as that can result in
|
337
337
|
# arbitrary code execution.
|
338
338
|
def self.def_append_methods(meths)
|
339
|
+
Sequel::Deprecation.deprecate('Dataset.def_append_methods', "There is no replacement planned")
|
339
340
|
meths.each do |meth|
|
340
341
|
class_eval(<<-END, __FILE__, __LINE__ + 1)
|
341
342
|
def #{meth}(*args, &block)
|
@@ -346,9 +347,28 @@ module Sequel
|
|
346
347
|
END
|
347
348
|
end
|
348
349
|
end
|
349
|
-
|
350
|
+
(PUBLIC_APPEND_METHODS + PRIVATE_APPEND_METHODS - [:literal, :quote_identifier, :quote_schema_table]).each do |meth|
|
351
|
+
class_eval(<<-END, __FILE__, __LINE__ + 1)
|
352
|
+
def #{meth}(*args, &block)
|
353
|
+
Sequel::Deprecation.deprecate('Dataset##{meth}', "Please switch to Dataset##{meth}_append")
|
354
|
+
s = ''
|
355
|
+
#{meth}_append(s, *args, &block)
|
356
|
+
s
|
357
|
+
end
|
358
|
+
END
|
359
|
+
end
|
350
360
|
private(*PRIVATE_APPEND_METHODS)
|
351
361
|
|
362
|
+
[:literal, :quote_identifier, :quote_schema_table].each do |meth|
|
363
|
+
class_eval(<<-END, __FILE__, __LINE__ + 1)
|
364
|
+
def #{meth}(*args, &block)
|
365
|
+
s = ''
|
366
|
+
#{meth}_append(s, *args, &block)
|
367
|
+
s
|
368
|
+
end
|
369
|
+
END
|
370
|
+
end
|
371
|
+
|
352
372
|
# SQL fragment for AliasedExpression
|
353
373
|
def aliased_expression_sql_append(sql, ae)
|
354
374
|
literal_append(sql, ae.expression)
|
@@ -601,13 +621,21 @@ module Sequel
|
|
601
621
|
sql << s
|
602
622
|
literal_append(sql, args[i]) unless i == len
|
603
623
|
end
|
624
|
+
unless str.length == args.length || str.length == args.length + 1
|
625
|
+
Sequel::Deprecation.deprecate("Using a mismatched number of placeholders (#{str.length}) and placeholder arguments (#{args.length}) is deprecated and will raise an Error in Sequel 4.")
|
626
|
+
end
|
604
627
|
else
|
605
628
|
i = -1
|
606
629
|
loop do
|
607
630
|
previous, q, str = str.partition(QUESTION_MARK)
|
608
631
|
sql << previous
|
609
|
-
|
610
|
-
|
632
|
+
literal_append(sql, args.at(i+=1)) unless q.empty?
|
633
|
+
if str.empty?
|
634
|
+
unless i + 1 == args.length
|
635
|
+
Sequel::Deprecation.deprecate("Using a mismatched number of placeholders (#{i+1}) and placeholder arguments (#{args.length}) is deprecated and will raise an Error in Sequel 4.")
|
636
|
+
end
|
637
|
+
break
|
638
|
+
end
|
611
639
|
end
|
612
640
|
end
|
613
641
|
sql << PAREN_CLOSE if pls.parens
|
@@ -665,7 +693,7 @@ module Sequel
|
|
665
693
|
# Note that this function does not handle tables with more than one
|
666
694
|
# level of qualification (e.g. database.schema.table on Microsoft
|
667
695
|
# SQL Server).
|
668
|
-
def schema_and_table(table_name, sch=(db.
|
696
|
+
def schema_and_table(table_name, sch=(db._default_schema if db))
|
669
697
|
sch = sch.to_s if sch
|
670
698
|
case table_name
|
671
699
|
when Symbol
|
@@ -921,6 +949,7 @@ module Sequel
|
|
921
949
|
end
|
922
950
|
end
|
923
951
|
|
952
|
+
# An expression for how to handle an empty array lookup
|
924
953
|
def empty_array_value(op, cols)
|
925
954
|
if Sequel.empty_array_handle_nulls
|
926
955
|
c = Array(cols)
|
@@ -978,7 +1007,12 @@ module Sequel
|
|
978
1007
|
literal_append(sql, v)
|
979
1008
|
end
|
980
1009
|
end
|
981
|
-
|
1010
|
+
|
1011
|
+
# REMOVE40
|
1012
|
+
def table_ref_append(sql, v)
|
1013
|
+
Sequel::Deprecation.deprecate('Dataset#table_ref_append', "Please switch to Dataset#identifier_append")
|
1014
|
+
identifier_append(sql, v)
|
1015
|
+
end
|
982
1016
|
|
983
1017
|
# Append all identifiers in args interspersed by commas.
|
984
1018
|
def identifier_list_append(sql, args)
|
@@ -1196,7 +1230,7 @@ module Sequel
|
|
1196
1230
|
# Returns a qualified column name (including a table name) if the column
|
1197
1231
|
# name isn't already qualified.
|
1198
1232
|
def qualified_column_name(column, table)
|
1199
|
-
if Symbol
|
1233
|
+
if column.is_a?(Symbol)
|
1200
1234
|
c_table, column, _ = split_symbol(column)
|
1201
1235
|
unless c_table
|
1202
1236
|
case table
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Sequel
|
2
|
+
# This module makes it easy to print deprecation warnings with optional backtraces to a given stream.
|
3
|
+
# There are a two accessors you can use to change how/where the deprecation methods are printed
|
4
|
+
# and whether/how backtraces should be included:
|
5
|
+
#
|
6
|
+
# Sequel::Deprecation.output = $stderr # print deprecation messages to standard error (default)
|
7
|
+
# Sequel::Deprecation.output = File.open('deprecated_calls.txt', 'wb') # use a file instead
|
8
|
+
# Sequel::Deprecation.output = false # do not output deprecation messages
|
9
|
+
#
|
10
|
+
# Sequel::Deprecation.prefix = "SEQUEL DEPRECATION WARNING: " # prefix deprecation messages with a given string (default)
|
11
|
+
# Sequel::Deprecation.prefix = false # do not prefix deprecation messages
|
12
|
+
#
|
13
|
+
# Sequel::Deprecation.backtrace_filter = false # don't include backtraces
|
14
|
+
# Sequel::Deprecation.backtrace_filter = true # include full backtraces
|
15
|
+
# Sequel::Deprecation.backtrace_filter = 10 # include 10 backtrace lines (default)
|
16
|
+
# Sequel::Deprecation.backtrace_filter = 1 # include 1 backtrace line
|
17
|
+
# Sequel::Deprecation.backtrace_filter = lambda{|line, line_no| line_no < 3 || line =~ /my_app/} # select backtrace lines to output
|
18
|
+
module Deprecation
|
19
|
+
@backtrace_filter = 10
|
20
|
+
@output = $stderr
|
21
|
+
@prefix = "SEQUEL DEPRECATION WARNING: "
|
22
|
+
|
23
|
+
class << self
|
24
|
+
# How to filter backtraces. +false+ does not include backtraces, +true+ includes
|
25
|
+
# full backtraces, an Integer includes that number of backtrace lines, and
|
26
|
+
# a proc is called with the backtrace line and line number to select the backtrace
|
27
|
+
# lines to include. The default is 10 backtrace lines.
|
28
|
+
attr_accessor :backtrace_filter
|
29
|
+
|
30
|
+
# Where deprecation messages should be output, must respond to puts. $stderr by default.
|
31
|
+
attr_accessor :output
|
32
|
+
|
33
|
+
# Where deprecation messages should be prefixed with ("SEQUEL DEPRECATION WARNING: " by default).
|
34
|
+
attr_accessor :prefix
|
35
|
+
end
|
36
|
+
|
37
|
+
# Print the message and possibly backtrace to the output.
|
38
|
+
def self.deprecate(method, instead=nil)
|
39
|
+
return unless output
|
40
|
+
message = instead ? "#{method} is deprecated and will be removed in Sequel 4.0. #{instead}." : method
|
41
|
+
message = "#{prefix}#{message}" if prefix
|
42
|
+
output.puts(message)
|
43
|
+
case b = backtrace_filter
|
44
|
+
when Integer
|
45
|
+
caller.each do |c|
|
46
|
+
b -= 1
|
47
|
+
output.puts(c)
|
48
|
+
break if b <= 0
|
49
|
+
end
|
50
|
+
when true
|
51
|
+
caller.each{|c| output.puts(c)}
|
52
|
+
when Proc
|
53
|
+
caller.each_with_index{|line, line_no| output.puts(line) if b.call(line, line_no)}
|
54
|
+
end
|
55
|
+
nil
|
56
|
+
end
|
57
|
+
|
58
|
+
# Return a module that includes deprecation warnings for all public
|
59
|
+
# instance methods in the given module, such that including the returned
|
60
|
+
# module will not result in the given module being included.
|
61
|
+
def self.deprecated_module(mod, &block)
|
62
|
+
Module.new do
|
63
|
+
include mod.dup
|
64
|
+
mod.public_instance_methods.each do |meth|
|
65
|
+
msg = block.call(meth)
|
66
|
+
define_method(meth) do |*a, &blk|
|
67
|
+
Sequel::Deprecation.deprecate(*msg)
|
68
|
+
super(*a, &blk)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
def Sequel.core_extensions?
|
2
|
+
true
|
3
|
+
end
|
4
|
+
|
5
|
+
class Array
|
6
|
+
def ~
|
7
|
+
Sequel::Deprecation.deprecate('Array#~', 'Please use Sequel.~ instead, or Sequel.extension(:core_extensions) to continue using it')
|
8
|
+
Sequel.~(self)
|
9
|
+
end
|
10
|
+
|
11
|
+
def case(*args)
|
12
|
+
Sequel::Deprecation.deprecate('Array#case', 'Please use Sequel.case instead, or Sequel.extension(:core_extensions) to continue using it')
|
13
|
+
::Sequel::SQL::CaseExpression.new(self, *args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def sql_value_list
|
17
|
+
Sequel::Deprecation.deprecate('Array#sql_value_list/Array#sql_array', 'Please use Sequel.value_list instead, or Sequel.extension(:core_extensions) to continue using it')
|
18
|
+
::Sequel::SQL::ValueList.new(self)
|
19
|
+
end
|
20
|
+
alias sql_array sql_value_list
|
21
|
+
|
22
|
+
def sql_expr
|
23
|
+
Sequel::Deprecation.deprecate('Array#sql_expr', 'Please use Sequel.expr instead, or Sequel.extension(:core_extensions) to continue using it')
|
24
|
+
Sequel.expr(self)
|
25
|
+
end
|
26
|
+
|
27
|
+
def sql_negate
|
28
|
+
Sequel::Deprecation.deprecate('Array#sql_negate', 'Please use Sequel.negate instead, or Sequel.extension(:core_extensions) to continue using it')
|
29
|
+
Sequel.negate(self)
|
30
|
+
end
|
31
|
+
|
32
|
+
def sql_or
|
33
|
+
Sequel::Deprecation.deprecate('Array#sql_or', 'Please use Sequel.or instead, or Sequel.extension(:core_extensions) to continue using it')
|
34
|
+
Sequel.or(self)
|
35
|
+
end
|
36
|
+
|
37
|
+
def sql_string_join(joiner=nil)
|
38
|
+
Sequel::Deprecation.deprecate('Array#sql_string_join', 'Please use Sequel.join instead, or Sequel.extension(:core_extensions) to continue using it')
|
39
|
+
Sequel.join(self, joiner)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class Hash
|
44
|
+
def &(ce)
|
45
|
+
Sequel::Deprecation.deprecate('Hash#&', 'Please use Sequel.& instead, or Sequel.extension(:core_extensions) to continue using it')
|
46
|
+
::Sequel::SQL::BooleanExpression.new(:AND, self, ce)
|
47
|
+
end
|
48
|
+
|
49
|
+
def |(ce)
|
50
|
+
Sequel::Deprecation.deprecate('Hash#|', 'Please use Sequel.| instead, or Sequel.extension(:core_extensions) to continue using it')
|
51
|
+
::Sequel::SQL::BooleanExpression.new(:OR, self, ce)
|
52
|
+
end
|
53
|
+
|
54
|
+
def ~
|
55
|
+
Sequel::Deprecation.deprecate('Hash#~', 'Please use Sequel.~ instead, or Sequel.extension(:core_extensions) to continue using it')
|
56
|
+
::Sequel::SQL::BooleanExpression.from_value_pairs(self, :OR, true)
|
57
|
+
end
|
58
|
+
|
59
|
+
def case(*args)
|
60
|
+
Sequel::Deprecation.deprecate('Hash#case', 'Please use Sequel.case instead, or Sequel.extension(:core_extensions) to continue using it')
|
61
|
+
::Sequel::SQL::CaseExpression.new(to_a, *args)
|
62
|
+
end
|
63
|
+
|
64
|
+
def sql_expr
|
65
|
+
Sequel::Deprecation.deprecate('Hash#sql_expr', 'Please use Sequel.expr instead, or Sequel.extension(:core_extensions) to continue using it')
|
66
|
+
::Sequel::SQL::BooleanExpression.from_value_pairs(self)
|
67
|
+
end
|
68
|
+
|
69
|
+
def sql_negate
|
70
|
+
Sequel::Deprecation.deprecate('Hash#sql_negate', 'Please use Sequel.negate instead, or Sequel.extension(:core_extensions) to continue using it')
|
71
|
+
::Sequel::SQL::BooleanExpression.from_value_pairs(self, :AND, true)
|
72
|
+
end
|
73
|
+
|
74
|
+
def sql_or
|
75
|
+
Sequel::Deprecation.deprecate('Hash#sql_or', 'Please use Sequel.or instead, or Sequel.extension(:core_extensions) to continue using it')
|
76
|
+
::Sequel::SQL::BooleanExpression.from_value_pairs(self, :OR)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class String
|
81
|
+
include Sequel::Deprecation.deprecated_module(Sequel::SQL::AliasMethods){|meth| ["String#as", 'Please use Sequel.as instead, or Sequel.extension(:core_extensions) to continue using it']}
|
82
|
+
include Sequel::Deprecation.deprecated_module(Sequel::SQL::CastMethods){|meth| ["String##{meth}", "Please use Sequel.#{meth} instead, or Sequel.extension(:core_extensions) to continue using it"]}
|
83
|
+
|
84
|
+
def lit(*args)
|
85
|
+
Sequel::Deprecation.deprecate('String#lit', 'Please use Sequel.lit instead, or Sequel.extension(:core_extensions) to continue using it')
|
86
|
+
args.empty? ? Sequel::LiteralString.new(self) : Sequel::SQL::PlaceholderLiteralString.new(self, args)
|
87
|
+
end
|
88
|
+
|
89
|
+
def to_sequel_blob
|
90
|
+
Sequel::Deprecation.deprecate('String#to_sequel_blob', 'Please use Sequel.blob instead, or Sequel.extension(:core_extensions) to continue using it')
|
91
|
+
::Sequel::SQL::Blob.new(self)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
class Symbol
|
96
|
+
include Sequel::Deprecation.deprecated_module(Sequel::SQL::AliasMethods){|meth| ["Symbol#as", 'Please use Sequel.as instead, or Sequel.extension(:core_extensions) to continue using it']}
|
97
|
+
include Sequel::Deprecation.deprecated_module(Sequel::SQL::CastMethods){|meth| ["Symbol##{meth}", "Please use Sequel.#{meth} instead, or Sequel.extension(:core_extensions) to continue using it"]}
|
98
|
+
include Sequel::Deprecation.deprecated_module(Sequel::SQL::OrderMethods){|meth| ["Symbol##{meth}", "Please use Sequel.#{meth} instead, or Sequel.extension(:core_extensions) to continue using it"]}
|
99
|
+
include Sequel::Deprecation.deprecated_module(Sequel::SQL::BooleanMethods){|meth| ["Symbol##{meth}", "Please use Sequel.#{meth} instead, or Sequel.extension(:core_extensions) to continue using it"]}
|
100
|
+
include Sequel::Deprecation.deprecated_module(Sequel::SQL::NumericMethods){|meth| ["Symbol##{meth}", "Please use Sequel.#{meth} instead, or Sequel.extension(:core_extensions) to continue using it"]}
|
101
|
+
include(Sequel::Deprecation.deprecated_module(Sequel::SQL::QualifyingMethods){|meth| ["Symbol##{meth}", "Please use Sequel.#{meth} instead, or Sequel.extension(:core_extensions) to continue using it"]}.module_eval do
|
102
|
+
def *(ce=(arg=false;nil))
|
103
|
+
if arg == false
|
104
|
+
Sequel::Deprecation.deprecate('Symbol#*', "Please use Sequel.expr(symbol).* instead, or Sequel.extension(:core_extensions) to continue using it")
|
105
|
+
Sequel::SQL::ColumnAll.new(self)
|
106
|
+
else
|
107
|
+
super(ce)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
self
|
111
|
+
end)
|
112
|
+
include Sequel::Deprecation.deprecated_module(Sequel::SQL::StringMethods){|meth| ["Symbol##{meth}", "Please use Sequel.#{meth} instead, or Sequel.extension(:core_extensions) to continue using it"]}
|
113
|
+
include Sequel::Deprecation.deprecated_module(Sequel::SQL::SubscriptMethods){["Symbol#sql_subscript", "Please use Sequel.subscript instead, or Sequel.extension(:core_extensions) to continue using it"]}
|
114
|
+
include Sequel::Deprecation.deprecated_module(Sequel::SQL::ComplexExpressionMethods){|meth| ["Symbol##{meth}", "Please use Sequel.expr(symbol).#{meth} instead, or Sequel.extension(:core_extensions) to continue using it"]}
|
115
|
+
|
116
|
+
if RUBY_VERSION < '1.9.0'
|
117
|
+
include Sequel::Deprecation.deprecated_module(Sequel::SQL::InequalityMethods){|meth| ["Symbol##{meth}", "Please use Sequel.expr(symbol).#{meth} instead, or Sequel.extension(:ruby18_symbol_extensions) to continue using it"]}
|
118
|
+
end
|
119
|
+
|
120
|
+
def identifier
|
121
|
+
Sequel::Deprecation.deprecate('Symbol#identifier', 'Please use Sequel.identifier instead, or Sequel.extension(:core_extensions) to continue using it')
|
122
|
+
Sequel::SQL::Identifier.new(self)
|
123
|
+
end
|
124
|
+
|
125
|
+
def sql_function(*args)
|
126
|
+
Sequel::Deprecation.deprecate('Symbol#sql_function', 'Please use Sequel.function instead, or Sequel.extension(:core_extensions) to continue using it')
|
127
|
+
Sequel::SQL::Function.new(self, *args)
|
128
|
+
end
|
129
|
+
if RUBY_VERSION < '1.9.0'
|
130
|
+
def [](*args)
|
131
|
+
Sequel::Deprecation.deprecate('Symbol#[]', 'Please use Sequel.function instead, or Sequel.extension(:ruby18_symbol_extensions) to continue using it')
|
132
|
+
Sequel::SQL::Function.new(self, *args)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -14,11 +14,6 @@
|
|
14
14
|
# To attempt to introspect columns for all datasets on a single database:
|
15
15
|
#
|
16
16
|
# DB.extension(:columns_introspection)
|
17
|
-
#
|
18
|
-
# To attempt to introspect columns for all datasets on all databases:
|
19
|
-
#
|
20
|
-
# Sequel.extension :columns_introspection
|
21
|
-
# Sequel::Dataset.introspect_all_columns
|
22
17
|
|
23
18
|
module Sequel
|
24
19
|
module ColumnsIntrospection
|
@@ -87,6 +82,7 @@ module Sequel
|
|
87
82
|
|
88
83
|
# Enable column introspection for every dataset.
|
89
84
|
def self.introspect_all_columns
|
85
|
+
Sequel::Deprecation.deprecate('Sequel::Dataset.introspect_all_columns', "Please use Database.extension :columns_introspection to load the extension into all databases")
|
90
86
|
include ColumnsIntrospection
|
91
87
|
remove_method(:columns) if instance_methods(false).map{|x| x.to_s}.include?('columns')
|
92
88
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# expression objects.
|
5
5
|
#
|
6
6
|
# This extension is currently loaded by default, but that will no
|
7
|
-
# longer be true in
|
7
|
+
# longer be true in Sequel 4. Starting in Sequel 4, you will
|
8
8
|
# need to load it manually via:
|
9
9
|
#
|
10
10
|
# Sequel.extension :core_extensions
|
@@ -208,7 +208,9 @@ class Symbol
|
|
208
208
|
include Sequel::SQL::StringMethods
|
209
209
|
include Sequel::SQL::SubscriptMethods
|
210
210
|
include Sequel::SQL::ComplexExpressionMethods
|
211
|
-
|
211
|
+
if RUBY_VERSION < '1.9.0'
|
212
|
+
include Sequel::Deprecation.deprecated_module(Sequel::SQL::InequalityMethods){|meth| ["Symbol##{meth}", "Please use Sequel.expr(symbol).#{meth} instead, or Sequel.extension(:ruby18_symbol_extensions) to continue using it"]}
|
213
|
+
end
|
212
214
|
|
213
215
|
# Returns receiver wrapped in an <tt>Sequel::SQL::Identifier</tt>. Usually used to
|
214
216
|
# prevent splitting the symbol.
|
@@ -230,5 +232,10 @@ class Symbol
|
|
230
232
|
def sql_function(*args)
|
231
233
|
Sequel::SQL::Function.new(self, *args)
|
232
234
|
end
|
233
|
-
|
235
|
+
if RUBY_VERSION < '1.9.0'
|
236
|
+
def [](*args)
|
237
|
+
Sequel::Deprecation.deprecate('Symbol#[]', 'Please use Sequel.function instead, or Sequel.extension(:ruby18_symbol_extensions) to continue using it')
|
238
|
+
Sequel::SQL::Function.new(self, *args)
|
239
|
+
end
|
240
|
+
end
|
234
241
|
end
|
@@ -122,6 +122,7 @@ module Sequel
|
|
122
122
|
end
|
123
123
|
false
|
124
124
|
else
|
125
|
+
Sequel::Deprecation.deprecate('Sequel::NotImplemented', 'Sequel 4 will just raise Error if date_arithmetic is not supported on the database')
|
125
126
|
raise NotImplemented, "date arithmetic is not implemented on #{db.database_type}"
|
126
127
|
end
|
127
128
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# This changes Sequel's literalization of IN/NOT IN with an empty
|
2
|
+
# array value to not return NULL even if one of the referenced
|
3
|
+
# columns is NULL:
|
4
|
+
#
|
5
|
+
# DB[:test].where(:name=>[])
|
6
|
+
# # SELECT * FROM test WHERE (1 = 0)
|
7
|
+
# DB[:test].exclude(:name=>[])
|
8
|
+
# # SELECT * FROM test WHERE (1 = 1)
|
9
|
+
#
|
10
|
+
# The default Sequel behavior is to respect NULLs, so that when
|
11
|
+
# name is NULL, the expression returns NULL.
|
12
|
+
#
|
13
|
+
# You can load this extension into specific datasets:
|
14
|
+
#
|
15
|
+
# ds = DB[:table]
|
16
|
+
# ds.extension(:empty_array_ignore_nulls)
|
17
|
+
#
|
18
|
+
# Or you can load it into all of a database's datasets, which
|
19
|
+
# is probably the desired behavior if you are using this extension:
|
20
|
+
#
|
21
|
+
# DB.extension(:empty_array_ignore_nulls)
|
22
|
+
|
23
|
+
module Sequel
|
24
|
+
module EmptyArrayIgnoreNulls
|
25
|
+
# Use a simple expression that is always true or false, never NULL.
|
26
|
+
def empty_array_value(op, cols)
|
27
|
+
{1 => ((op == :IN) ? 0 : 1)}
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
Dataset.register_extension(:empty_array_ignore_nulls, EmptyArrayIgnoreNulls)
|
33
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# The filter_having extension allows Dataset#filter, #and, #or
|
2
|
+
# and #exclude to operate on the HAVING clause if the dataset
|
3
|
+
# already has a HAVING clause, which was the historical behavior
|
4
|
+
# before Sequel 4. It is only recommended to use this for
|
5
|
+
# backwards compatibility.
|
6
|
+
#
|
7
|
+
# You can load this extension into specific datasets:
|
8
|
+
#
|
9
|
+
# ds = DB[:table]
|
10
|
+
# ds.extension(:filter_having)
|
11
|
+
#
|
12
|
+
# Or you can load it into all of a database's datasets, which
|
13
|
+
# is probably the desired behavior if you are using this extension:
|
14
|
+
#
|
15
|
+
# DB.extension(:filter_having)
|
16
|
+
|
17
|
+
module Sequel
|
18
|
+
module FilterHaving
|
19
|
+
# Operate on HAVING clause if HAVING clause already present.
|
20
|
+
def and(*cond, &block)
|
21
|
+
if @opts[:having]
|
22
|
+
having(*cond, &block)
|
23
|
+
else
|
24
|
+
super
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Operate on HAVING clause if HAVING clause already present.
|
29
|
+
def exclude(*cond, &block)
|
30
|
+
if @opts[:having]
|
31
|
+
exclude_having(*cond, &block)
|
32
|
+
else
|
33
|
+
super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Operate on HAVING clause if HAVING clause already present.
|
38
|
+
def filter(*cond, &block)
|
39
|
+
if @opts[:having]
|
40
|
+
having(*cond, &block)
|
41
|
+
else
|
42
|
+
super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Operate on HAVING clause if HAVING clause already present.
|
47
|
+
def or(*cond, &block)
|
48
|
+
if having = @opts[:having]
|
49
|
+
cond = cond.first if cond.size == 1
|
50
|
+
clone(:having => SQL::BooleanExpression.new(:OR, having, filter_expr(cond, &block)))
|
51
|
+
else
|
52
|
+
super
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
Dataset.register_extension(:filter_having, FilterHaving)
|
58
|
+
end
|