sequel 4.45.0 → 4.46.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +108 -0
  3. data/doc/release_notes/4.46.0.txt +404 -0
  4. data/doc/security.rdoc +9 -0
  5. data/doc/sql.rdoc +2 -2
  6. data/doc/testing.rdoc +1 -1
  7. data/doc/validations.rdoc +1 -2
  8. data/lib/sequel/adapters/ado.rb +8 -3
  9. data/lib/sequel/adapters/ado/access.rb +8 -4
  10. data/lib/sequel/adapters/ado/mssql.rb +3 -1
  11. data/lib/sequel/adapters/amalgalite.rb +5 -0
  12. data/lib/sequel/adapters/cubrid.rb +16 -7
  13. data/lib/sequel/adapters/do.rb +7 -1
  14. data/lib/sequel/adapters/do/mysql.rb +8 -4
  15. data/lib/sequel/adapters/ibmdb.rb +10 -5
  16. data/lib/sequel/adapters/jdbc.rb +8 -2
  17. data/lib/sequel/adapters/jdbc/as400.rb +10 -3
  18. data/lib/sequel/adapters/jdbc/db2.rb +27 -16
  19. data/lib/sequel/adapters/jdbc/derby.rb +47 -20
  20. data/lib/sequel/adapters/jdbc/h2.rb +13 -7
  21. data/lib/sequel/adapters/jdbc/hsqldb.rb +18 -9
  22. data/lib/sequel/adapters/jdbc/mssql.rb +5 -2
  23. data/lib/sequel/adapters/jdbc/mysql.rb +3 -2
  24. data/lib/sequel/adapters/jdbc/oracle.rb +3 -2
  25. data/lib/sequel/adapters/jdbc/postgresql.rb +4 -3
  26. data/lib/sequel/adapters/jdbc/sqlanywhere.rb +2 -1
  27. data/lib/sequel/adapters/jdbc/sqlite.rb +10 -3
  28. data/lib/sequel/adapters/jdbc/sqlserver.rb +23 -0
  29. data/lib/sequel/adapters/jdbc/transactions.rb +16 -10
  30. data/lib/sequel/adapters/mock.rb +5 -0
  31. data/lib/sequel/adapters/mysql.rb +8 -1
  32. data/lib/sequel/adapters/mysql2.rb +6 -1
  33. data/lib/sequel/adapters/odbc.rb +20 -8
  34. data/lib/sequel/adapters/odbc/mssql.rb +6 -3
  35. data/lib/sequel/adapters/oracle.rb +12 -6
  36. data/lib/sequel/adapters/postgres.rb +20 -8
  37. data/lib/sequel/adapters/shared/access.rb +76 -47
  38. data/lib/sequel/adapters/shared/cubrid.rb +16 -11
  39. data/lib/sequel/adapters/shared/db2.rb +46 -19
  40. data/lib/sequel/adapters/shared/firebird.rb +20 -8
  41. data/lib/sequel/adapters/shared/informix.rb +6 -3
  42. data/lib/sequel/adapters/shared/mssql.rb +132 -72
  43. data/lib/sequel/adapters/shared/mysql.rb +112 -65
  44. data/lib/sequel/adapters/shared/oracle.rb +36 -21
  45. data/lib/sequel/adapters/shared/postgres.rb +91 -56
  46. data/lib/sequel/adapters/shared/sqlanywhere.rb +65 -37
  47. data/lib/sequel/adapters/shared/sqlite.rb +67 -32
  48. data/lib/sequel/adapters/sqlanywhere.rb +9 -1
  49. data/lib/sequel/adapters/sqlite.rb +8 -1
  50. data/lib/sequel/adapters/swift.rb +5 -0
  51. data/lib/sequel/adapters/swift/mysql.rb +4 -2
  52. data/lib/sequel/adapters/swift/sqlite.rb +1 -1
  53. data/lib/sequel/adapters/tinytds.rb +10 -3
  54. data/lib/sequel/adapters/utils/emulate_offset_with_reverse_and_count.rb +1 -1
  55. data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +1 -1
  56. data/lib/sequel/adapters/utils/mysql_mysql2.rb +1 -0
  57. data/lib/sequel/adapters/utils/pg_types.rb +14 -6
  58. data/lib/sequel/adapters/utils/replace.rb +4 -2
  59. data/lib/sequel/connection_pool/single.rb +2 -2
  60. data/lib/sequel/core.rb +24 -11
  61. data/lib/sequel/database/connecting.rb +9 -3
  62. data/lib/sequel/database/dataset_defaults.rb +7 -1
  63. data/lib/sequel/database/logging.rb +1 -0
  64. data/lib/sequel/database/misc.rb +5 -2
  65. data/lib/sequel/database/query.rb +7 -5
  66. data/lib/sequel/database/schema_generator.rb +1 -0
  67. data/lib/sequel/database/schema_methods.rb +50 -27
  68. data/lib/sequel/database/transactions.rb +19 -9
  69. data/lib/sequel/dataset/actions.rb +15 -6
  70. data/lib/sequel/dataset/graph.rb +15 -5
  71. data/lib/sequel/dataset/misc.rb +12 -4
  72. data/lib/sequel/dataset/mutation.rb +17 -8
  73. data/lib/sequel/dataset/prepared_statements.rb +3 -2
  74. data/lib/sequel/dataset/query.rb +84 -38
  75. data/lib/sequel/dataset/sql.rb +302 -191
  76. data/lib/sequel/deprecated.rb +26 -17
  77. data/lib/sequel/extensions/_deprecated_identifier_mangling.rb +2 -2
  78. data/lib/sequel/extensions/auto_literal_strings.rb +74 -0
  79. data/lib/sequel/extensions/from_block.rb +1 -0
  80. data/lib/sequel/extensions/graph_each.rb +1 -1
  81. data/lib/sequel/extensions/identifier_mangling.rb +2 -2
  82. data/lib/sequel/extensions/migration.rb +28 -4
  83. data/lib/sequel/extensions/no_auto_literal_strings.rb +2 -0
  84. data/lib/sequel/extensions/schema_dumper.rb +4 -4
  85. data/lib/sequel/extensions/sequel_3_dataset_methods.rb +5 -3
  86. data/lib/sequel/extensions/set_overrides.rb +2 -0
  87. data/lib/sequel/extensions/split_array_nil.rb +2 -2
  88. data/lib/sequel/extensions/virtual_row_method_block.rb +44 -0
  89. data/lib/sequel/model.rb +11 -7
  90. data/lib/sequel/model/associations.rb +5 -7
  91. data/lib/sequel/model/base.rb +47 -45
  92. data/lib/sequel/model/dataset_module.rb +9 -14
  93. data/lib/sequel/model/plugins.rb +3 -0
  94. data/lib/sequel/no_core_ext.rb +1 -0
  95. data/lib/sequel/plugins/blacklist_security.rb +1 -1
  96. data/lib/sequel/plugins/boolean_subsets.rb +7 -5
  97. data/lib/sequel/plugins/class_table_inheritance.rb +47 -10
  98. data/lib/sequel/plugins/dataset_associations.rb +1 -1
  99. data/lib/sequel/plugins/def_dataset_method.rb +90 -0
  100. data/lib/sequel/plugins/finder.rb +240 -0
  101. data/lib/sequel/plugins/inverted_subsets.rb +19 -12
  102. data/lib/sequel/plugins/many_through_many.rb +1 -1
  103. data/lib/sequel/plugins/nested_attributes.rb +1 -1
  104. data/lib/sequel/plugins/schema.rb +1 -1
  105. data/lib/sequel/plugins/single_table_inheritance.rb +7 -1
  106. data/lib/sequel/plugins/subset_conditions.rb +11 -3
  107. data/lib/sequel/plugins/whitelist_security.rb +118 -0
  108. data/lib/sequel/sql.rb +80 -36
  109. data/lib/sequel/timezones.rb +2 -0
  110. data/lib/sequel/version.rb +1 -1
  111. data/spec/adapters/mssql_spec.rb +20 -0
  112. data/spec/adapters/mysql_spec.rb +1 -1
  113. data/spec/adapters/oracle_spec.rb +12 -8
  114. data/spec/adapters/postgres_spec.rb +1 -1
  115. data/spec/adapters/spec_helper.rb +1 -1
  116. data/spec/adapters/sqlite_spec.rb +36 -34
  117. data/spec/core/connection_pool_spec.rb +2 -1
  118. data/spec/core/database_spec.rb +87 -9
  119. data/spec/core/dataset_spec.rb +501 -129
  120. data/spec/core/deprecated_spec.rb +1 -1
  121. data/spec/core/expression_filters_spec.rb +146 -60
  122. data/spec/core/mock_adapter_spec.rb +1 -1
  123. data/spec/core/object_graph_spec.rb +61 -9
  124. data/spec/core/placeholder_literalizer_spec.rb +20 -2
  125. data/spec/core/schema_generator_spec.rb +6 -6
  126. data/spec/core/schema_spec.rb +54 -5
  127. data/spec/core_extensions_spec.rb +122 -18
  128. data/spec/deprecation_helper.rb +27 -2
  129. data/spec/extensions/_deprecated_identifier_mangling_spec.rb +6 -6
  130. data/spec/extensions/association_proxies_spec.rb +2 -2
  131. data/spec/extensions/auto_literal_strings_spec.rb +212 -0
  132. data/spec/extensions/blacklist_security_spec.rb +1 -0
  133. data/spec/extensions/class_table_inheritance_spec.rb +1037 -39
  134. data/spec/extensions/column_select_spec.rb +20 -8
  135. data/spec/extensions/columns_introspection_spec.rb +3 -3
  136. data/spec/extensions/core_refinements_spec.rb +29 -12
  137. data/spec/extensions/dataset_associations_spec.rb +12 -12
  138. data/spec/extensions/def_dataset_method_spec.rb +100 -0
  139. data/spec/extensions/error_sql_spec.rb +1 -1
  140. data/spec/extensions/finder_spec.rb +260 -0
  141. data/spec/extensions/graph_each_spec.rb +2 -2
  142. data/spec/extensions/identifier_mangling_spec.rb +14 -8
  143. data/spec/extensions/inverted_subsets_spec.rb +4 -4
  144. data/spec/extensions/lazy_attributes_spec.rb +7 -0
  145. data/spec/extensions/many_through_many_spec.rb +38 -14
  146. data/spec/extensions/nested_attributes_spec.rb +18 -6
  147. data/spec/extensions/no_auto_literal_strings_spec.rb +1 -1
  148. data/spec/extensions/pg_enum_spec.rb +16 -1
  149. data/spec/extensions/pg_interval_spec.rb +11 -2
  150. data/spec/extensions/pg_loose_count_spec.rb +5 -0
  151. data/spec/extensions/pg_row_spec.rb +25 -0
  152. data/spec/extensions/prepared_statements_spec.rb +10 -1
  153. data/spec/extensions/query_spec.rb +2 -2
  154. data/spec/extensions/schema_dumper_spec.rb +2 -2
  155. data/spec/extensions/schema_spec.rb +2 -2
  156. data/spec/extensions/set_overrides_spec.rb +7 -3
  157. data/spec/extensions/sql_expr_spec.rb +0 -1
  158. data/spec/extensions/subset_conditions_spec.rb +6 -6
  159. data/spec/extensions/table_select_spec.rb +24 -12
  160. data/spec/extensions/to_dot_spec.rb +4 -4
  161. data/spec/extensions/whitelist_security_spec.rb +131 -0
  162. data/spec/integration/dataset_test.rb +9 -5
  163. data/spec/integration/model_test.rb +2 -0
  164. data/spec/integration/plugin_test.rb +2 -2
  165. data/spec/integration/spec_helper.rb +1 -1
  166. data/spec/model/associations_spec.rb +39 -11
  167. data/spec/model/base_spec.rb +44 -24
  168. data/spec/model/class_dataset_methods_spec.rb +18 -16
  169. data/spec/model/dataset_methods_spec.rb +4 -4
  170. data/spec/model/eager_loading_spec.rb +84 -24
  171. data/spec/model/model_spec.rb +97 -63
  172. data/spec/model/record_spec.rb +21 -13
  173. metadata +13 -2
@@ -36,25 +36,34 @@ module Sequel
36
36
  attr_accessor :prefix
37
37
  end
38
38
 
39
- # Print the message and possibly backtrace to the output.
40
- def self.deprecate(method, instead=nil)
41
- return unless output
42
- message = instead ? "#{method} is deprecated and will be removed in Sequel 5. #{instead}." : method
43
- message = "#{prefix}#{message}" if prefix
44
- output.puts(message)
45
- case b = backtrace_filter
46
- when Integer
47
- caller.each do |c|
48
- b -= 1
49
- output.puts(c)
50
- break if b <= 0
39
+ if RUBY_VERSION < '1.9'
40
+ # :nocov:
41
+ def self.deprecate(_method, _instead=nil)
42
+ # Sequel 5 will drop ruby 1.8 support completely, so it doesn't make sense to issue deprecation
43
+ # warnings on ruby 1.8.
44
+ end
45
+ # :nocov:
46
+ else
47
+ # Print the message and possibly backtrace to the output.
48
+ def self.deprecate(method, instead=nil)
49
+ return unless output
50
+ message = instead ? "#{method} is deprecated and will be removed in Sequel 5. #{instead}." : method
51
+ message = "#{prefix}#{message}" if prefix
52
+ output.puts(message)
53
+ case b = backtrace_filter
54
+ when Integer
55
+ caller.each do |c|
56
+ b -= 1
57
+ output.puts(c)
58
+ break if b <= 0
59
+ end
60
+ when true
61
+ caller.each{|c| output.puts(c)}
62
+ when Proc
63
+ caller.each_with_index{|line, line_no| output.puts(line) if b.call(line, line_no)}
51
64
  end
52
- when true
53
- caller.each{|c| output.puts(c)}
54
- when Proc
55
- caller.each_with_index{|line, line_no| output.puts(line) if b.call(line, line_no)}
65
+ nil
56
66
  end
57
- nil
58
67
  end
59
68
 
60
69
  # If using ruby 2.3+, use Module#deprecate_constant to deprecate the constant,
@@ -70,7 +70,7 @@ module Sequel
70
70
 
71
71
  def identifier_input_method=(v)
72
72
  Sequel::Deprecation.deprecate("Dataset#identifier_input_method=", "Explicitly load the identifier_mangling extension if you would like to use this")
73
- raise_if_frozen!("identifier_input_method=")
73
+ raise_if_frozen!(%w"identifier_input_method= with_identifier_input_method")
74
74
  skip_symbol_cache!
75
75
  @opts[:identifier_input_method] = v
76
76
  end
@@ -81,7 +81,7 @@ module Sequel
81
81
 
82
82
  def identifier_output_method=(v)
83
83
  Sequel::Deprecation.deprecate("Dataset#identifier_output_method=", "Explicitly load the identifier_mangling extension if you would like to use this")
84
- raise_if_frozen!("identifier_output_method=")
84
+ raise_if_frozen!(%w"identifier_output_method= with_identifier_output_method")
85
85
  @opts[:identifier_output_method] = v
86
86
  end
87
87
 
@@ -0,0 +1,74 @@
1
+ # frozen-string-literal: true
2
+ #
3
+ # The auto_literal_strings extension treats string values passed as filter
4
+ # arguments as SQL query fragments. This is the behavior of previous
5
+ # versions of Sequel. Using this extension makes using raw SQL fragments
6
+ # easier, since you don't need to wrap them with Sequel.lit, but also makes
7
+ # it easier to introduce SQL injection vulnerabilities into the application.
8
+ # It is only recommended to use this extension for
9
+ # backwards compatibility with previous versions of Sequel.
10
+ #
11
+ # With this extension, if a single string is given, it is used as an SQL
12
+ # query fragment:
13
+ #
14
+ # ds = DB[:table].extension(:auto_literal_strings)
15
+ # ds.where("name > 'A'")
16
+ # # SELECT * FROM table WHERE (name > 'A')
17
+ #
18
+ # If additional arguments are given, they are used as placeholders:
19
+ #
20
+ # ds.where("name > ?", "A")
21
+ # # SELECT * FROM table WHERE (name > 'A')
22
+ #
23
+ # Named placeholders can also be used with a hash:
24
+ #
25
+ # ds.where("name > :a", :a=>"A")
26
+ # # SELECT * FROM table WHERE (name > 'A')
27
+ #
28
+ # This extension also allows the use of a plain string passed to Dataset#update:
29
+ #
30
+ # ds.update("column = column + 1")
31
+ # # UPDATE table SET column = column + 1
32
+ #
33
+ # Related module: Sequel::Dataset::AutoLiteralStrings
34
+
35
+ #
36
+ module Sequel
37
+ class Dataset
38
+ module AutoLiteralStrings
39
+ # Treat plain strings as literal strings, and arrays where the first element
40
+ # is a string as a literal string with placeholders.
41
+ def filter_expr(expr = nil)
42
+ case expr
43
+ when LiteralString
44
+ super
45
+ when String
46
+ super(LiteralString.new(expr))
47
+ when Array
48
+ if (sexpr = expr.first).is_a?(String)
49
+ super(SQL::PlaceholderLiteralString.new(sexpr, expr[1..-1], true))
50
+ else
51
+ super
52
+ end
53
+ else
54
+ super
55
+ end
56
+ end
57
+
58
+ # Treat plain strings as literal strings.
59
+ def update_sql(values=OPTS)
60
+ case values
61
+ when LiteralString
62
+ super
63
+ when String
64
+ super(LiteralString.new(values))
65
+ else
66
+ super
67
+ end
68
+ end
69
+ end
70
+
71
+ register_extension(:auto_literal_strings, AutoLiteralStrings)
72
+ end
73
+ end
74
+
@@ -29,6 +29,7 @@ module Sequel
29
29
  super
30
30
  end
31
31
  end
32
+ # SEQUEL5: Make this an empty module, since it will be the default behavior
32
33
  end
33
34
 
34
35
  Database.register_extension(:from_block, Database::FromBlock)
@@ -56,7 +56,7 @@ module Sequel
56
56
  datasets = datasets.collect{|ta, ds| [ta, ds, ds.row_proc]}
57
57
  # Use the manually set graph aliases, if any, otherwise
58
58
  # use the ones automatically created by .graph
59
- column_aliases = @opts[:graph_aliases] || @opts[:graph][:column_aliases]
59
+ column_aliases = @opts[:graph_aliases] || @opts[:graph][:column_aliases] # SEQUEL5: Remove :graph_aliases support
60
60
  fetch_rows(sql) do |r|
61
61
  graph = {}
62
62
  # Create the sub hashes, one per table
@@ -144,7 +144,7 @@ module Sequel
144
144
 
145
145
  # Set the method to call on identifiers going into the database for this dataset
146
146
  def identifier_input_method=(v)
147
- raise_if_frozen!("identifier_input_method=")
147
+ raise_if_frozen!(%w"identifier_input_method= with_identifier_input_method")
148
148
  skip_symbol_cache!
149
149
  @opts[:identifier_input_method] = v
150
150
  end
@@ -157,7 +157,7 @@ module Sequel
157
157
 
158
158
  # Set the method to call on identifiers coming the database for this dataset
159
159
  def identifier_output_method=(v)
160
- raise_if_frozen!("identifier_output_method=")
160
+ raise_if_frozen!(%w"identifier_output_method= with_identifier_output_method")
161
161
  @opts[:identifier_output_method] = v
162
162
  end
163
163
 
@@ -448,9 +448,9 @@ module Sequel
448
448
  @directory = directory
449
449
  @allow_missing_migration_files = opts[:allow_missing_migration_files]
450
450
  @files = get_migration_files
451
- schema, table = @db.send(:schema_and_table, opts[:table] || self.class.const_get(:DEFAULT_SCHEMA_TABLE))
451
+ schema, table = @db.send(:schema_and_table, opts[:table] || default_schema_table)
452
452
  @table = schema ? Sequel::SQL::QualifiedIdentifier.new(schema, table) : table
453
- @column = opts[:column] || self.class.const_get(:DEFAULT_SCHEMA_COLUMN)
453
+ @column = opts[:column] || default_schema_column
454
454
  @ds = schema_dataset
455
455
  @use_transactions = opts[:use_transactions]
456
456
  end
@@ -482,7 +482,7 @@ module Sequel
482
482
  def load_migration_file(file)
483
483
  n = Migration.descendants.length
484
484
  load(file)
485
- raise Error, "Migration file not containing a single migration detected" unless n + 1 == Migration.descendants.length
485
+ raise Error, "Migration file #{file.inspect} not containing a single migration detected" unless n + 1 == Migration.descendants.length
486
486
  end
487
487
 
488
488
  # Remove all migration classes. Done by the migrator to ensure that
@@ -507,6 +507,8 @@ module Sequel
507
507
  class IntegerMigrator < Migrator
508
508
  DEFAULT_SCHEMA_COLUMN = :version
509
509
  DEFAULT_SCHEMA_TABLE = :schema_info
510
+ Sequel::Deprecation.deprecate_constant(self, :DEFAULT_SCHEMA_COLUMN)
511
+ Sequel::Deprecation.deprecate_constant(self, :DEFAULT_SCHEMA_TABLE)
510
512
 
511
513
  Error = Migrator::Error
512
514
 
@@ -574,6 +576,16 @@ module Sequel
574
576
  ds.get(column) || 0
575
577
  end
576
578
 
579
+ # The default column storing schema version.
580
+ def default_schema_column
581
+ :version
582
+ end
583
+
584
+ # The default table storing schema version.
585
+ def default_schema_table
586
+ :schema_info
587
+ end
588
+
577
589
  # Returns any found migration files in the supplied directory.
578
590
  def get_migration_files
579
591
  files = []
@@ -656,6 +668,8 @@ module Sequel
656
668
  class TimestampMigrator < Migrator
657
669
  DEFAULT_SCHEMA_COLUMN = :filename
658
670
  DEFAULT_SCHEMA_TABLE = :schema_migrations
671
+ Sequel::Deprecation.deprecate_constant(self, :DEFAULT_SCHEMA_COLUMN)
672
+ Sequel::Deprecation.deprecate_constant(self, :DEFAULT_SCHEMA_TABLE)
659
673
 
660
674
  Error = Migrator::Error
661
675
 
@@ -699,7 +713,7 @@ module Sequel
699
713
  # Convert the schema_info table to the new schema_migrations table format,
700
714
  # using the version of the schema_info table and the current migration files.
701
715
  def convert_from_schema_info
702
- v = db[IntegerMigrator::DEFAULT_SCHEMA_TABLE].get(IntegerMigrator::DEFAULT_SCHEMA_COLUMN)
716
+ v = db[:schema_info].get(:version)
703
717
  ds = db.from(table)
704
718
  files.each do |path|
705
719
  f = File.basename(path)
@@ -709,6 +723,16 @@ module Sequel
709
723
  end
710
724
  end
711
725
 
726
+ # The default column storing migration filenames.
727
+ def default_schema_column
728
+ :filename
729
+ end
730
+
731
+ # The default table storing migration filenames.
732
+ def default_schema_table
733
+ :schema_migrations
734
+ end
735
+
712
736
  # Returns filenames of all applied migrations
713
737
  def get_applied_migrations
714
738
  am = ds.select_order_map(column)
@@ -82,3 +82,5 @@ module Sequel
82
82
  register_extension(:no_auto_literal_strings, NoAutoLiteralStrings)
83
83
  end
84
84
  end
85
+
86
+ # SEQUEL5: Make extension empty
@@ -163,7 +163,7 @@ END_MIG
163
163
  end
164
164
  end
165
165
 
166
- # Recreate the column in the passed Schema::Generator from the given name and parsed database schema.
166
+ # Recreate the column in the passed Schema::CreateTableGenerator from the given name and parsed database schema.
167
167
  def recreate_column(name, schema, gen, options)
168
168
  if options[:single_pk] && schema_autoincrementing_primary_key?(schema)
169
169
  type_hash = options[:same_db] ? {:type=>schema[:db_type]} : column_schema_to_ruby_type(schema)
@@ -242,7 +242,7 @@ END_MIG
242
242
  end
243
243
  end
244
244
 
245
- # Return a Schema::Generator object that will recreate the
245
+ # Return a Schema::CreateTableGenerator object that will recreate the
246
246
  # table's schema. Takes the same options as dump_schema_migration.
247
247
  def dump_table_generator(table, options=OPTS)
248
248
  s = schema(table, options).dup
@@ -304,7 +304,7 @@ END_MIG
304
304
  gen.dump_indexes(meth=>table, :ignore_errors=>!options[:same_db])
305
305
  end
306
306
 
307
- # Convert the parsed index information into options to the Generators index method.
307
+ # Convert the parsed index information into options to the CreateTableGenerator's index method.
308
308
  def index_to_generator_opts(table, name, index_opts, options=OPTS)
309
309
  h = {}
310
310
  if options[:index_names] != false && default_index_name(table, index_opts[:columns]) != name.to_s
@@ -380,7 +380,7 @@ END_MIG
380
380
  end
381
381
 
382
382
  module Schema
383
- class Generator
383
+ class CreateTableGenerator
384
384
  # Dump this generator's columns to a string that could be evaled inside
385
385
  # another instance to represent the same columns
386
386
  def dump_columns
@@ -26,7 +26,9 @@
26
26
  #
27
27
  module Sequel
28
28
  module Sequel3DatasetMethods
29
- COMMA = Dataset::COMMA
29
+ COMMA = ', '
30
+ Sequel::Deprecation.deprecate_constant(self, :COMMA)
31
+
30
32
  # Change the database for this dataset.
31
33
  def db=(v)
32
34
  raise_if_frozen!("db=")
@@ -119,8 +121,8 @@ module Sequel
119
121
  n = naked
120
122
  cols = n.columns
121
123
  csv = String.new
122
- csv << "#{cols.join(COMMA)}\r\n" if include_column_titles
123
- n.each{|r| csv << "#{cols.collect{|c| r[c]}.join(COMMA)}\r\n"}
124
+ csv << "#{cols.join(', ')}\r\n" if include_column_titles
125
+ n.each{|r| csv << "#{cols.collect{|c| r[c]}.join(', ')}\r\n"}
124
126
  csv
125
127
  end
126
128
  end
@@ -18,6 +18,8 @@
18
18
  #
19
19
  # Related module: Sequel::SetOverrides
20
20
 
21
+ Sequel::Deprecation.deprecate("The set_overrides extension", "Please consider maintaining it yourself as an external sequel extension if you want to continue using it")
22
+
21
23
  #
22
24
  module Sequel
23
25
  module SetOverrides
@@ -46,9 +46,9 @@ module Sequel
46
46
  def complex_expression_sql_append(sql, op, args)
47
47
  case op
48
48
  when :IN, :"NOT IN"
49
- vals = args.at(1)
49
+ vals = args[1]
50
50
  if vals.is_a?(Array) && vals.any?(&:nil?)
51
- cols = args.at(0)
51
+ cols = args[0]
52
52
  vals = vals.compact
53
53
  c = Sequel::SQL::BooleanExpression
54
54
  if op == :IN
@@ -0,0 +1,44 @@
1
+ # frozen-string-literal: true
2
+ #
3
+ # These modifies virtual row blocks so that you can pass a block
4
+ # when calling a method to change the behavior. It only exists
5
+ # for backwards compatibility with previous Sequel versions, and
6
+ # is not recommended for new applications.
7
+ #
8
+ # To load the extension:
9
+ #
10
+ # Sequel.extension :virtual_row_method_block
11
+
12
+ #
13
+ module Sequel
14
+ module SQL
15
+ class VirtualRow < BasicObject
16
+ include(Module.new do
17
+ # Handle blocks passed to methods and change the behavior.
18
+ def method_missing(m, *args, &block)
19
+ if block
20
+ if args.empty?
21
+ Function.new(m)
22
+ else
23
+ case args.shift
24
+ when :*
25
+ Function.new(m, *args).*
26
+ when :distinct
27
+ Function.new(m, *args).distinct
28
+ when :over
29
+ opts = args.shift || OPTS
30
+ f = Function.new(m, *::Kernel.Array(opts[:args]))
31
+ f = f.* if opts[:*]
32
+ f.over(opts)
33
+ else
34
+ Kernel.raise(Error, 'unsupported VirtualRow method argument used with block')
35
+ end
36
+ end
37
+ else
38
+ super
39
+ end
40
+ end
41
+ end)
42
+ end
43
+ end
44
+ end
@@ -33,11 +33,13 @@ module Sequel
33
33
 
34
34
  # Class methods added to model that call the method of the same name on the dataset
35
35
  DATASET_METHODS = (Dataset::ACTION_METHODS + Dataset::QUERY_METHODS + [:each_server, :where_all, :where_each, :where_single_value]) -
36
- [:and, :or, :[], :columns, :columns!, :delete, :update, :add_graph_aliases, :first, :first!]
36
+ [:and, :or, :[], :columns, :columns!, :delete, :update, :add_graph_aliases] # SEQUEL5: Remove set_graph_aliases
37
37
 
38
38
  # Boolean settings that can be modified at the global, class, or instance level.
39
39
  BOOLEAN_SETTINGS = [:typecast_empty_string_to_nil, :typecast_on_assignment, :strict_param_setting, \
40
- :raise_on_save_failure, :raise_on_typecast_failure, :require_modification, :use_after_commit_rollback, :use_transactions]
40
+ :raise_on_save_failure, :raise_on_typecast_failure, :require_modification, :use_transactions,
41
+ :use_after_commit_rollback # SEQUEL5: Remove
42
+ ]
41
43
 
42
44
  # Hooks that are called before an action. Can return false to not do the action. When
43
45
  # overriding these, it is recommended to call +super+ as the last line of your method,
@@ -64,14 +66,16 @@ module Sequel
64
66
  # Class instance variables that are inherited in subclasses. If the value is <tt>:dup</tt>, dup is called
65
67
  # on the superclass's instance variable when creating the instance variable in the subclass.
66
68
  # If the value is +nil+, the superclass's instance variable is used directly in the subclass.
67
- INHERITED_INSTANCE_VARIABLES = {:@allowed_columns=>:dup,
69
+ INHERITED_INSTANCE_VARIABLES = {
70
+ :@allowed_columns=>:dup, # SEQUEL5: Remove
68
71
  :@dataset_method_modules=>:dup, :@primary_key=>nil, :@use_transactions=>nil,
69
72
  :@raise_on_save_failure=>nil, :@require_modification=>nil, :@restrict_primary_key=>nil,
70
73
  :@simple_pk=>nil, :@simple_table=>nil, :@strict_param_setting=>nil,
71
74
  :@typecast_empty_string_to_nil=>nil, :@typecast_on_assignment=>nil,
72
75
  :@raise_on_typecast_failure=>nil, :@plugins=>:dup, :@setter_methods=>nil,
73
76
  :@use_after_commit_rollback=>nil, :@fast_pk_lookup_sql=>nil,
74
- :@fast_instance_delete_sql=>nil, :@finders=>:dup, :@finder_loaders=>:dup,
77
+ :@fast_instance_delete_sql=>nil,
78
+ :@finders=>:dup, :@finder_loaders=>:dup, # SEQUEL5: Remove
75
79
  :@db=>nil, :@default_set_fields_options=>:dup, :@require_valid_table=>nil,
76
80
  :@cache_anonymous_models=>nil, :@dataset_module_class=>nil}
77
81
 
@@ -84,7 +88,7 @@ module Sequel
84
88
  # (i.e. it ends with =).
85
89
  SETTER_METHOD_REGEXP = /=\z/
86
90
 
87
- @allowed_columns = nil
91
+ @allowed_columns = nil # SEQUEL5: Remove
88
92
  @cache_anonymous_models = true
89
93
  @db = nil
90
94
  @db_schema = nil
@@ -92,8 +96,8 @@ module Sequel
92
96
  @dataset_method_modules = []
93
97
  @default_eager_limit_strategy = true
94
98
  @default_set_fields_options = {}
95
- @finders = {}
96
- @finder_loaders = {}
99
+ @finders = {} # SEQUEL5: Remove
100
+ @finder_loaders = {} # SEQUEL5: Remove
97
101
  @overridable_methods_module = nil
98
102
  @fast_pk_lookup_sql = nil
99
103
  @fast_instance_delete_sql = nil