sequel 4.47.0 → 4.48.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.
Files changed (177) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +134 -0
  3. data/Rakefile +1 -1
  4. data/doc/release_notes/4.48.0.txt +293 -0
  5. data/lib/sequel/adapters/ado/access.rb +2 -1
  6. data/lib/sequel/adapters/do/postgres.rb +5 -2
  7. data/lib/sequel/adapters/ibmdb.rb +24 -7
  8. data/lib/sequel/adapters/jdbc.rb +36 -22
  9. data/lib/sequel/adapters/jdbc/db2.rb +12 -3
  10. data/lib/sequel/adapters/jdbc/derby.rb +4 -5
  11. data/lib/sequel/adapters/jdbc/oracle.rb +16 -2
  12. data/lib/sequel/adapters/jdbc/postgresql.rb +43 -18
  13. data/lib/sequel/adapters/jdbc/sqlanywhere.rb +9 -7
  14. data/lib/sequel/adapters/jdbc/sqlserver.rb +11 -4
  15. data/lib/sequel/adapters/mock.rb +24 -19
  16. data/lib/sequel/adapters/mysql.rb +17 -16
  17. data/lib/sequel/adapters/mysql2.rb +4 -5
  18. data/lib/sequel/adapters/oracle.rb +5 -9
  19. data/lib/sequel/adapters/postgres.rb +89 -102
  20. data/lib/sequel/adapters/shared/db2.rb +22 -6
  21. data/lib/sequel/adapters/shared/mssql.rb +5 -4
  22. data/lib/sequel/adapters/shared/mysql.rb +75 -24
  23. data/lib/sequel/adapters/shared/postgres.rb +196 -94
  24. data/lib/sequel/adapters/shared/sqlanywhere.rb +23 -10
  25. data/lib/sequel/adapters/shared/sqlite.rb +72 -82
  26. data/lib/sequel/adapters/sqlanywhere.rb +4 -1
  27. data/lib/sequel/adapters/sqlite.rb +5 -3
  28. data/lib/sequel/adapters/swift/postgres.rb +5 -2
  29. data/lib/sequel/adapters/tinytds.rb +0 -5
  30. data/lib/sequel/adapters/utils/mysql_mysql2.rb +1 -1
  31. data/lib/sequel/adapters/utils/pg_types.rb +2 -76
  32. data/lib/sequel/core.rb +2 -2
  33. data/lib/sequel/database/connecting.rb +5 -5
  34. data/lib/sequel/database/dataset.rb +6 -3
  35. data/lib/sequel/database/misc.rb +1 -1
  36. data/lib/sequel/database/query.rb +3 -0
  37. data/lib/sequel/database/schema_methods.rb +1 -1
  38. data/lib/sequel/dataset/actions.rb +18 -10
  39. data/lib/sequel/dataset/graph.rb +1 -1
  40. data/lib/sequel/dataset/misc.rb +1 -0
  41. data/lib/sequel/dataset/prepared_statements.rb +3 -3
  42. data/lib/sequel/dataset/query.rb +19 -8
  43. data/lib/sequel/extensions/core_extensions.rb +4 -1
  44. data/lib/sequel/extensions/duplicate_columns_handler.rb +1 -1
  45. data/lib/sequel/extensions/empty_array_ignore_nulls.rb +3 -0
  46. data/lib/sequel/extensions/filter_having.rb +2 -0
  47. data/lib/sequel/extensions/freeze_datasets.rb +2 -0
  48. data/lib/sequel/extensions/from_block.rb +1 -1
  49. data/lib/sequel/extensions/graph_each.rb +2 -2
  50. data/lib/sequel/extensions/hash_aliases.rb +2 -0
  51. data/lib/sequel/extensions/identifier_mangling.rb +0 -7
  52. data/lib/sequel/extensions/meta_def.rb +2 -0
  53. data/lib/sequel/extensions/migration.rb +6 -6
  54. data/lib/sequel/extensions/no_auto_literal_strings.rb +1 -1
  55. data/lib/sequel/extensions/pagination.rb +1 -1
  56. data/lib/sequel/extensions/pg_array.rb +207 -130
  57. data/lib/sequel/extensions/pg_hstore.rb +38 -20
  58. data/lib/sequel/extensions/pg_inet.rb +18 -6
  59. data/lib/sequel/extensions/pg_interval.rb +19 -12
  60. data/lib/sequel/extensions/pg_json.rb +25 -14
  61. data/lib/sequel/extensions/pg_json_ops.rb +2 -2
  62. data/lib/sequel/extensions/pg_range.rb +133 -100
  63. data/lib/sequel/extensions/pg_range_ops.rb +4 -3
  64. data/lib/sequel/extensions/pg_row.rb +68 -39
  65. data/lib/sequel/extensions/pg_row_ops.rb +11 -5
  66. data/lib/sequel/extensions/query_literals.rb +2 -0
  67. data/lib/sequel/extensions/ruby18_symbol_extensions.rb +2 -0
  68. data/lib/sequel/extensions/s.rb +1 -1
  69. data/lib/sequel/extensions/schema_dumper.rb +24 -24
  70. data/lib/sequel/extensions/sequel_3_dataset_methods.rb +3 -1
  71. data/lib/sequel/extensions/sequel_4_dataset_methods.rb +83 -0
  72. data/lib/sequel/extensions/set_overrides.rb +2 -2
  73. data/lib/sequel/extensions/string_agg.rb +0 -1
  74. data/lib/sequel/extensions/symbol_aref.rb +0 -4
  75. data/lib/sequel/model.rb +25 -57
  76. data/lib/sequel/model/associations.rb +14 -5
  77. data/lib/sequel/model/base.rb +96 -32
  78. data/lib/sequel/plugins/association_pks.rb +73 -46
  79. data/lib/sequel/plugins/association_proxies.rb +1 -1
  80. data/lib/sequel/plugins/auto_validations.rb +6 -2
  81. data/lib/sequel/plugins/boolean_readers.rb +1 -1
  82. data/lib/sequel/plugins/caching.rb +19 -13
  83. data/lib/sequel/plugins/class_table_inheritance.rb +19 -10
  84. data/lib/sequel/plugins/column_conflicts.rb +7 -2
  85. data/lib/sequel/plugins/column_select.rb +1 -1
  86. data/lib/sequel/plugins/csv_serializer.rb +8 -8
  87. data/lib/sequel/plugins/defaults_setter.rb +10 -0
  88. data/lib/sequel/plugins/eager_each.rb +1 -1
  89. data/lib/sequel/plugins/force_encoding.rb +2 -2
  90. data/lib/sequel/plugins/hook_class_methods.rb +9 -12
  91. data/lib/sequel/plugins/identifier_columns.rb +2 -0
  92. data/lib/sequel/plugins/instance_filters.rb +3 -1
  93. data/lib/sequel/plugins/instance_hooks.rb +17 -9
  94. data/lib/sequel/plugins/json_serializer.rb +17 -10
  95. data/lib/sequel/plugins/lazy_attributes.rb +8 -7
  96. data/lib/sequel/plugins/modification_detection.rb +3 -0
  97. data/lib/sequel/plugins/nested_attributes.rb +5 -1
  98. data/lib/sequel/plugins/pg_array_associations.rb +5 -0
  99. data/lib/sequel/plugins/prepared_statements.rb +1 -0
  100. data/lib/sequel/plugins/rcte_tree.rb +4 -4
  101. data/lib/sequel/plugins/serialization.rb +3 -10
  102. data/lib/sequel/plugins/single_table_inheritance.rb +2 -2
  103. data/lib/sequel/plugins/split_values.rb +6 -5
  104. data/lib/sequel/plugins/static_cache.rb +31 -25
  105. data/lib/sequel/plugins/subset_conditions.rb +3 -1
  106. data/lib/sequel/plugins/table_select.rb +1 -1
  107. data/lib/sequel/plugins/touch.rb +2 -1
  108. data/lib/sequel/plugins/validation_class_methods.rb +5 -6
  109. data/lib/sequel/plugins/validation_helpers.rb +2 -4
  110. data/lib/sequel/plugins/xml_serializer.rb +4 -4
  111. data/lib/sequel/sql.rb +2 -2
  112. data/lib/sequel/version.rb +1 -1
  113. data/spec/adapters/db2_spec.rb +115 -14
  114. data/spec/adapters/mysql_spec.rb +78 -28
  115. data/spec/adapters/oracle_spec.rb +24 -24
  116. data/spec/adapters/postgres_spec.rb +38 -24
  117. data/spec/adapters/sqlanywhere_spec.rb +88 -86
  118. data/spec/adapters/sqlite_spec.rb +29 -24
  119. data/spec/core/connection_pool_spec.rb +17 -0
  120. data/spec/core/database_spec.rb +6 -0
  121. data/spec/core/dataset_spec.rb +46 -36
  122. data/spec/core/schema_spec.rb +16 -0
  123. data/spec/core/spec_helper.rb +1 -0
  124. data/spec/core_extensions_spec.rb +6 -2
  125. data/spec/extensions/active_model_spec.rb +1 -1
  126. data/spec/extensions/arbitrary_servers_spec.rb +1 -1
  127. data/spec/extensions/association_pks_spec.rb +34 -2
  128. data/spec/extensions/auto_literal_strings_spec.rb +5 -1
  129. data/spec/extensions/auto_validations_spec.rb +2 -0
  130. data/spec/extensions/boolean_readers_spec.rb +1 -1
  131. data/spec/extensions/boolean_subsets_spec.rb +1 -1
  132. data/spec/extensions/class_table_inheritance_spec.rb +48 -2
  133. data/spec/extensions/column_conflicts_spec.rb +11 -0
  134. data/spec/extensions/connection_validator_spec.rb +1 -1
  135. data/spec/extensions/dataset_associations_spec.rb +8 -8
  136. data/spec/extensions/defaults_setter_spec.rb +1 -1
  137. data/spec/extensions/filter_having_spec.rb +5 -3
  138. data/spec/extensions/hash_aliases_spec.rb +3 -1
  139. data/spec/extensions/identifier_columns_spec.rb +3 -1
  140. data/spec/extensions/implicit_subquery_spec.rb +4 -2
  141. data/spec/extensions/json_serializer_spec.rb +18 -0
  142. data/spec/extensions/lazy_attributes_spec.rb +3 -3
  143. data/spec/extensions/meta_def_spec.rb +9 -0
  144. data/spec/extensions/migration_spec.rb +3 -3
  145. data/spec/extensions/nested_attributes_spec.rb +14 -3
  146. data/spec/extensions/no_auto_literal_strings_spec.rb +8 -4
  147. data/spec/extensions/pg_array_associations_spec.rb +29 -18
  148. data/spec/extensions/pg_array_spec.rb +44 -25
  149. data/spec/extensions/pg_hstore_spec.rb +10 -0
  150. data/spec/extensions/pg_inet_spec.rb +26 -0
  151. data/spec/extensions/pg_interval_spec.rb +20 -0
  152. data/spec/extensions/pg_json_spec.rb +24 -0
  153. data/spec/extensions/pg_range_spec.rb +98 -14
  154. data/spec/extensions/pg_row_spec.rb +14 -4
  155. data/spec/extensions/prepared_statements_safe_spec.rb +1 -1
  156. data/spec/extensions/query_literals_spec.rb +3 -1
  157. data/spec/extensions/schema_dumper_spec.rb +96 -98
  158. data/spec/extensions/sequel_3_dataset_methods_spec.rb +10 -6
  159. data/spec/extensions/sequel_4_dataset_methods_spec.rb +121 -0
  160. data/spec/extensions/single_table_inheritance_spec.rb +1 -1
  161. data/spec/extensions/spec_helper.rb +7 -1
  162. data/spec/extensions/static_cache_spec.rb +75 -24
  163. data/spec/extensions/string_agg_spec.rb +1 -1
  164. data/spec/extensions/touch_spec.rb +9 -0
  165. data/spec/extensions/validation_helpers_spec.rb +9 -3
  166. data/spec/extensions/whitelist_security_spec.rb +26 -0
  167. data/spec/integration/dataset_test.rb +45 -44
  168. data/spec/integration/plugin_test.rb +20 -0
  169. data/spec/integration/prepared_statement_test.rb +3 -0
  170. data/spec/integration/schema_test.rb +21 -1
  171. data/spec/integration/transaction_test.rb +40 -40
  172. data/spec/model/class_dataset_methods_spec.rb +14 -4
  173. data/spec/model/dataset_methods_spec.rb +12 -3
  174. data/spec/model/model_spec.rb +8 -0
  175. metadata +6 -4
  176. data/spec/adapters/firebird_spec.rb +0 -405
  177. data/spec/adapters/informix_spec.rb +0 -100
@@ -6,11 +6,17 @@ module Sequel
6
6
  module DB2
7
7
  Sequel::Database.set_shared_adapter_scheme(:db2, self)
8
8
 
9
+ # SEQUEL5: Remove
9
10
  @use_clob_as_blob = false
10
-
11
11
  class << self
12
- # Whether to use clob as the generic File type, true by default.
13
- attr_accessor :use_clob_as_blob
12
+ def use_clob_as_blob
13
+ Sequel::Deprecation.deprecate("Sequel::DB2.use_clob_as_blob", "Call this method on the Database instance")
14
+ @use_clob_as_blob
15
+ end
16
+ def use_clob_as_blob=(v)
17
+ Sequel::Deprecation.deprecate("Sequel::DB2.use_clob_as_blob=", "Call this method on the Database instance")
18
+ @use_clob_as_blob = v
19
+ end
14
20
  end
15
21
 
16
22
  module DatabaseMethods
@@ -21,6 +27,16 @@ module Sequel
21
27
  NULL = ''.freeze
22
28
  Sequel::Deprecation.deprecate_constant(self, :NULL)
23
29
 
30
+ # Whether to use clob as the generic File type, false by default.
31
+ #attr_accessor :use_clob_as_blob # SEQUEL5
32
+
33
+ # SEQUEL5: Remove
34
+ attr_writer :use_clob_as_blob
35
+ def use_clob_as_blob
36
+ v = @use_clob_as_blob
37
+ v.nil? ? Sequel::DB2.instance_variable_get(:@use_clob_as_blob) : v
38
+ end
39
+
24
40
  # DB2 always uses :db2 as it's database type
25
41
  def database_type
26
42
  :db2
@@ -250,7 +266,7 @@ module Sequel
250
266
 
251
267
  # Treat clob as blob if use_clob_as_blob is true
252
268
  def schema_column_type(db_type)
253
- (::Sequel::DB2::use_clob_as_blob && db_type.downcase == 'clob') ? :blob : super
269
+ (use_clob_as_blob && db_type.downcase == 'clob') ? :blob : super
254
270
  end
255
271
 
256
272
  # SQL to set the transaction isolation level
@@ -263,7 +279,7 @@ module Sequel
263
279
  # use this for blob value:
264
280
  # cast(X'fffefdfcfbfa' as blob(2G))
265
281
  def type_literal_generic_file(column)
266
- ::Sequel::DB2::use_clob_as_blob ? :clob : :blob
282
+ use_clob_as_blob ? :clob : :blob
267
283
  end
268
284
 
269
285
  # DB2 uses smallint to store booleans.
@@ -433,7 +449,7 @@ module Sequel
433
449
 
434
450
  # DB2 uses a literal hexidecimal number for blob strings
435
451
  def literal_blob_append(sql, v)
436
- if ::Sequel::DB2.use_clob_as_blob
452
+ if db.use_clob_as_blob
437
453
  super
438
454
  else
439
455
  sql << "BLOB(X'" << v.unpack("H*").first << "')"
@@ -540,7 +540,6 @@ module Sequel
540
540
  CONSTANT_MAP = {:CURRENT_DATE=>'CAST(CURRENT_TIMESTAMP AS DATE)'.freeze, :CURRENT_TIME=>'CAST(CURRENT_TIMESTAMP AS TIME)'.freeze}#.freeze # SEQUEL5
541
541
  EXTRACT_MAP = {:year=>"yy", :month=>"m", :day=>"d", :hour=>"hh", :minute=>"n", :second=>"s"}#.freeze # SEQUEL5
542
542
  #EXTRACT_MAP.each_value(&:freeze) # SEQUEL5
543
- NON_SQL_OPTIONS = (Dataset::NON_SQL_OPTIONS + [:disable_insert_output, :mssql_unicode_strings]).freeze
544
543
  LIMIT_ALL = Object.new.freeze
545
544
 
546
545
  BOOL_TRUE = '1'.freeze
@@ -629,6 +628,8 @@ module Sequel
629
628
  Sequel::Deprecation.deprecate_constant(self, :ROWS_ONLY)
630
629
  FETCH_NEXT = " FETCH NEXT ".freeze
631
630
  Sequel::Deprecation.deprecate_constant(self, :FETCH_NEXT)
631
+ NON_SQL_OPTIONS = (Dataset::NON_SQL_OPTIONS + [:disable_insert_output, :mssql_unicode_strings]).freeze
632
+ Sequel::Deprecation.deprecate_constant(self, :NON_SQL_OPTIONS)
632
633
 
633
634
  Dataset.def_mutation_method(:disable_insert_output, :output, :module=>self)
634
635
  Dataset.def_sql_method(self, :delete, %w'with delete limit from output from2 where')
@@ -637,6 +638,7 @@ module Sequel
637
638
 
638
639
  # Allow overriding of the mssql_unicode_strings option at the dataset level.
639
640
  def mssql_unicode_strings=(v)
641
+ Sequel::Deprecation.deprecate("Dataset#mssql_unicode_strings=", "Switch to using with_mssql_unicode_strings, which returns a modified copy")
640
642
  @opts[:mssql_unicode_strings] = v
641
643
  end
642
644
 
@@ -1048,9 +1050,8 @@ module Sequel
1048
1050
  is_2008_or_later? ? :values : :union
1049
1051
  end
1050
1052
 
1051
- # Dataset options that do not affect the generated SQL.
1052
- def non_sql_options
1053
- NON_SQL_OPTIONS
1053
+ def non_sql_option?(key)
1054
+ super || key == :disable_insert_output || key == :mssql_unicode_strings
1054
1055
  end
1055
1056
 
1056
1057
  def select_into_sql(sql)
@@ -12,32 +12,54 @@ module Sequel
12
12
  end
13
13
  end
14
14
 
15
+ # SEQUEL5: Remove
15
16
  @convert_tinyint_to_bool = true
16
-
17
+ @default_charset = nil
18
+ @default_collate = nil
19
+ @default_engine = nil
17
20
  class << self
18
- # Sequel converts the column type tinyint(1) to a boolean by default when
19
- # using the native MySQL or Mysql2 adapter. You can turn off the conversion by setting
20
- # this to false. This setting is ignored when connecting to MySQL via the do or jdbc
21
- # adapters, both of which automatically do the conversion.
22
- attr_accessor :convert_tinyint_to_bool
21
+ def convert_tinyint_to_bool
22
+ Sequel::Deprecation.deprecate("Sequel::MySQL.convert_tinyint_to_bool", "Call this method on the Database instance")
23
+ @convert_tinyint_to_bool
24
+ end
25
+ def convert_tinyint_to_bool=(v)
26
+ Sequel::Deprecation.deprecate("Sequel::MySQL.convert_tinyint_to_bool=", "Call this method on the Database instance")
27
+ @convert_tinyint_to_bool = v
28
+ end
23
29
 
24
- # Set the default charset used for CREATE TABLE. You can pass the
25
- # :charset option to create_table to override this setting.
26
- attr_accessor :default_charset
30
+ def default_charset
31
+ Sequel::Deprecation.deprecate("Sequel::MySQL.default_charset", "Call this method on the Database instance")
32
+ @default_charset
33
+ end
34
+ def default_charset=(v)
35
+ Sequel::Deprecation.deprecate("Sequel::MySQL.default_charset=", "Call this method on the Database instance")
36
+ @default_charset = v
37
+ end
27
38
 
28
- # Set the default collation used for CREATE TABLE. You can pass the
29
- # :collate option to create_table to override this setting.
30
- attr_accessor :default_collate
39
+ def default_collate
40
+ Sequel::Deprecation.deprecate("Sequel::MySQL.default_collate", "Call this method on the Database instance")
41
+ @default_collate
42
+ end
43
+ def default_collate=(v)
44
+ Sequel::Deprecation.deprecate("Sequel::MySQL.default_collate=", "Call this method on the Database instance")
45
+ @default_collate = v
46
+ end
31
47
 
32
- # Set the default engine used for CREATE TABLE. You can pass the
33
- # :engine option to create_table to override this setting.
34
- attr_accessor :default_engine
48
+ def default_engine
49
+ Sequel::Deprecation.deprecate("Sequel::MySQL.default_engine", "Call this method on the Database instance")
50
+ @default_engine
51
+ end
52
+ def default_engine=(v)
53
+ Sequel::Deprecation.deprecate("Sequel::MySQL.default_engine=", "Call this method on the Database instance")
54
+ @default_engine = v
55
+ end
35
56
  end
36
57
 
37
58
  # Methods shared by Database instances that connect to MySQL,
38
59
  # currently supported by the native and JDBC adapters.
39
60
  module DatabaseMethods
40
61
  include UnmodifiedIdentifiers::DatabaseMethods
62
+ include Sequel::Database::SplitAlterTable
41
63
 
42
64
  AUTO_INCREMENT = 'AUTO_INCREMENT'.freeze
43
65
  Sequel::Deprecation.deprecate_constant(self, :AUTO_INCREMENT)
@@ -49,8 +71,36 @@ module Sequel
49
71
  CAST_TYPES = {String=>:CHAR, Integer=>:SIGNED, Time=>:DATETIME, DateTime=>:DATETIME, Numeric=>:DECIMAL, BigDecimal=>:DECIMAL, File=>:BINARY}#.freeze # SEQUEL5
50
72
  COLUMN_DEFINITION_ORDER = [:collate, :null, :default, :unique, :primary_key, :auto_increment, :references]#.freeze # SEQUEL5
51
73
 
52
- include Sequel::Database::SplitAlterTable
53
74
 
75
+ # Set the default charset used for CREATE TABLE. You can pass the
76
+ # :charset option to create_table to override this setting.
77
+ #attr_accessor :default_charset # SEQUEL5
78
+
79
+ # Set the default collation used for CREATE TABLE. You can pass the
80
+ # :collate option to create_table to override this setting.
81
+ #attr_accessor :default_collate # SEQUEL5
82
+
83
+ # Set the default engine used for CREATE TABLE. You can pass the
84
+ # :engine option to create_table to override this setting.
85
+ #attr_accessor :default_engine # SEQUEL5
86
+
87
+ # SEQUEL5: Remove
88
+ attr_writer :default_charset
89
+ def default_charset
90
+ v = @default_charset
91
+ v.nil? ? Sequel::MySQL.instance_variable_get(:@default_charset) : v
92
+ end
93
+ attr_writer :default_collate
94
+ def default_collate
95
+ v = @default_collate
96
+ v.nil? ? Sequel::MySQL.instance_variable_get(:@default_collate) : v
97
+ end
98
+ attr_writer :default_engine
99
+ def default_engine
100
+ v = @default_engine
101
+ v.nil? ? Sequel::MySQL.instance_variable_get(:@default_engine) : v
102
+ end
103
+
54
104
  # MySQL's cast rules are restrictive in that you can't just cast to any possible
55
105
  # database type.
56
106
  def cast_type_literal(type)
@@ -375,9 +425,9 @@ module Sequel
375
425
 
376
426
  # Use MySQL specific syntax for engine type and character encoding
377
427
  def create_table_sql(name, generator, options = OPTS)
378
- engine = options.fetch(:engine, Sequel::MySQL.default_engine)
379
- charset = options.fetch(:charset, Sequel::MySQL.default_charset)
380
- collate = options.fetch(:collate, Sequel::MySQL.default_collate)
428
+ engine = options.fetch(:engine, default_engine)
429
+ charset = options.fetch(:charset, default_charset)
430
+ collate = options.fetch(:collate, default_collate)
381
431
  generator.constraints.sort_by{|c| (c[:type] == :primary_key) ? -1 : 1}
382
432
 
383
433
  # Proc for figuring out the primary key for a given table.
@@ -669,10 +719,11 @@ module Sequel
669
719
  Sequel::Deprecation.deprecate_constant(self, :CURRENT_TIMESTAMP_56)
670
720
  ONLY_OFFSET = ",18446744073709551615".freeze
671
721
  Sequel::Deprecation.deprecate_constant(self, :ONLY_OFFSET)
722
+ NON_SQL_OPTIONS = (Dataset::NON_SQL_OPTIONS + [:insert_ignore, :update_ignore, :on_duplicate_key_update]).freeze
723
+ Sequel::Deprecation.deprecate_constant(self, :NON_SQL_OPTIONS)
672
724
 
673
725
  MATCH_AGAINST = ["MATCH ".freeze, " AGAINST (".freeze, ")".freeze].freeze
674
726
  MATCH_AGAINST_BOOLEAN = ["MATCH ".freeze, " AGAINST (".freeze, " IN BOOLEAN MODE)".freeze].freeze
675
- NON_SQL_OPTIONS = (Dataset::NON_SQL_OPTIONS + [:insert_ignore, :update_ignore, :on_duplicate_key_update]).freeze
676
727
 
677
728
  Dataset.def_sql_method(self, :delete, %w'delete from where order limit')
678
729
  Dataset.def_sql_method(self, :insert, %w'insert ignore into columns values on_duplicate_key_update')
@@ -791,7 +842,7 @@ module Sequel
791
842
  # Raises an error on use of :full_outer type, since MySQL doesn't support it.
792
843
  def join_table(type, table, expr=nil, opts=OPTS, &block)
793
844
  type = :inner if (type == :cross) && !expr.nil?
794
- raise(Sequel::Error, "MySQL doesn't support FULL OUTER JOIN") if type == :full_outer
845
+ raise(Sequel::Error, "MySQL doesn't support FULL OUTER JOIN or NATURAL FULL JOIN") if type == :full_outer || type == :natural_full
795
846
  super(type, table, expr, opts, &block)
796
847
  end
797
848
 
@@ -802,6 +853,7 @@ module Sequel
802
853
  when :straight
803
854
  'STRAIGHT_JOIN'
804
855
  when :natural_inner
856
+ Sequel::Deprecation.deprecate(":natural_inner join type being converted to NATURAL LEFT JOIN on MySQL", "Use :natural_left join type for NATURAL LEFT JOIN, or :natural join type for NATURAL JOIN")
805
857
  'NATURAL LEFT JOIN'
806
858
  else
807
859
  super
@@ -1055,9 +1107,8 @@ module Sequel
1055
1107
  :values
1056
1108
  end
1057
1109
 
1058
- # Dataset options that do not affect the generated SQL.
1059
- def non_sql_options
1060
- NON_SQL_OPTIONS
1110
+ def non_sql_option?(key)
1111
+ super || key == :insert_ignore || key == :update_ignore || key == :on_duplicate_key_update
1061
1112
  end
1062
1113
 
1063
1114
  def select_only_offset_sql(sql)
@@ -1,25 +1,17 @@
1
1
  # frozen-string-literal: true
2
2
 
3
- Sequel.require %w'pg_types unmodified_identifiers', 'adapters/utils'
3
+ Sequel.require %w'adapters/utils/unmodified_identifiers'
4
4
 
5
5
  module Sequel
6
6
  # Top level module for holding all PostgreSQL-related modules and classes
7
- # for Sequel. There are a few module level accessors that are added via
8
- # metaprogramming. These are:
9
- #
10
- # client_min_messages :: Change the minimum level of messages that PostgreSQL will send to the
11
- # the client. The PostgreSQL default is NOTICE, the Sequel default is
12
- # WARNING. Set to nil to not change the server default. Overridable on
13
- # a per instance basis via the :client_min_messages option.
14
- # force_standard_strings :: Set to false to not force the use of standard strings. Overridable
15
- # on a per instance basis via the :force_standard_strings option.
16
- #
17
- # It is not recommened you use these module-level accessors. Instead,
18
- # use the database option to make the setting per-Database.
19
- #
20
- # All adapters that connect to PostgreSQL support the following option in
21
- # addition to those mentioned above:
7
+ # for Sequel. All adapters that connect to PostgreSQL support the following options:
22
8
  #
9
+ # :client_min_messages :: Change the minimum level of messages that PostgreSQL will send to the
10
+ # the client. The PostgreSQL default is NOTICE, the Sequel default is
11
+ # WARNING. Set to nil to not change the server default. Overridable on
12
+ # a per instance basis via the :client_min_messages option.
13
+ # :force_standard_strings :: Set to false to not force the use of standard strings. Overridable
14
+ # on a per instance basis via the :force_standard_strings option.
23
15
  # :search_path :: Set the schema search_path for this Database's connections.
24
16
  # Allows to to set which schemas do not need explicit
25
17
  # qualification, and in which order to check the schemas when
@@ -27,6 +19,88 @@ module Sequel
27
19
  module Postgres
28
20
  Sequel::Database.set_shared_adapter_scheme(:postgres, self)
29
21
 
22
+ NAN = 0.0/0.0
23
+ PLUS_INFINITY = 1.0/0.0
24
+ MINUS_INFINITY = -1.0/0.0
25
+
26
+ NAN_STR = 'NaN'.freeze
27
+ Sequel::Deprecation.deprecate_constant(self, :NAN_STR)
28
+ PLUS_INFINITY_STR = 'Infinity'.freeze
29
+ Sequel::Deprecation.deprecate_constant(self, :PLUS_INFINITY_STR)
30
+ MINUS_INFINITY_STR = '-Infinity'.freeze
31
+ Sequel::Deprecation.deprecate_constant(self, :MINUS_INFINITY_STR)
32
+ TRUE_STR = 't'.freeze
33
+ Sequel::Deprecation.deprecate_constant(self, :TRUE_STR)
34
+ DASH_STR = '-'.freeze
35
+ Sequel::Deprecation.deprecate_constant(self, :DASH_STR)
36
+
37
+ TYPE_TRANSLATOR = tt = Class.new do
38
+ def boolean(s) s == 't' end
39
+ def integer(s) s.to_i end
40
+ def float(s)
41
+ case s
42
+ when 'NaN'
43
+ NAN
44
+ when 'Infinity'
45
+ PLUS_INFINITY
46
+ when '-Infinity'
47
+ MINUS_INFINITY
48
+ else
49
+ s.to_f
50
+ end
51
+ end
52
+ def date(s) ::Date.new(*s.split('-').map(&:to_i)) end
53
+ def bytea(str)
54
+ str = if str =~ /\A\\x/
55
+ # PostgreSQL 9.0+ bytea hex format
56
+ str[2..-1].gsub(/(..)/){|s| s.to_i(16).chr}
57
+ else
58
+ # Historical PostgreSQL bytea escape format
59
+ str.gsub(/\\(\\|'|[0-3][0-7][0-7])/) {|s|
60
+ if s.size == 2 then s[1,1] else s[1,3].oct.chr end
61
+ }
62
+ end
63
+ ::Sequel::SQL::Blob.new(str)
64
+ end
65
+ end.new#.freeze # SEQUEL5
66
+
67
+ # Type OIDs for string types used by PostgreSQL. These types don't
68
+ # have conversion procs associated with them (since the data is
69
+ # already in the form of a string).
70
+ STRING_TYPES = [18, 19, 25, 1042, 1043] # SEQUEL5: Remove
71
+
72
+ # Hash with type name strings/symbols and callable values for converting PostgreSQL types.
73
+ # Non-builtin types that don't have fixed numbers should use this to register
74
+ # conversion procs.
75
+ PG_NAMED_TYPES = {} unless defined?(PG_NAMED_TYPES)
76
+ PG_NAMED__TYPES = PG_NAMED_TYPES
77
+ Sequel::Deprecation.deprecate_constant(self, :PG_NAMED_TYPES)
78
+
79
+ # Hash with integer keys and callable values for converting PostgreSQL types.
80
+ PG_TYPES = {} unless defined?(PG_TYPES)
81
+
82
+ #CONVERSION_PROCS = {} # SEQUEL5
83
+
84
+ {
85
+ [16] => tt.method(:boolean),
86
+ [17] => tt.method(:bytea),
87
+ [20, 21, 23, 26] => tt.method(:integer),
88
+ [700, 701] => tt.method(:float),
89
+ [1700] => ::BigDecimal.method(:new),
90
+ [1083, 1266] => ::Sequel.method(:string_to_time),
91
+ [1082] => ::Sequel.method(:string_to_date),
92
+ [1184, 1114] => ::Sequel.method(:database_to_application_timestamp),
93
+ }.each do |k,v|
94
+ k.each do |n|
95
+ PG_TYPES[n] = v
96
+ #CONVERSION_PROCS[n] = v # SEQUEL5
97
+ end
98
+ end
99
+ PG__TYPES = PG_TYPES
100
+ Sequel::Deprecation.deprecate_constant(self, :PG_TYPES)
101
+
102
+ #CONVERSION_PROCS.freeze # SEQUEL5
103
+
30
104
  module MockAdapterDatabaseMethods
31
105
  def bound_variable_arg(arg, conn)
32
106
  arg
@@ -45,26 +119,30 @@ module Sequel
45
119
  end
46
120
  end
47
121
 
48
- # Array of exceptions that need to be converted. JDBC
49
- # uses NativeExceptions, the native adapter uses PGError.
50
122
  CONVERTED_EXCEPTIONS = []
123
+ Sequel::Deprecation.deprecate_constant(self, :CONVERTED_EXCEPTIONS)
51
124
 
125
+ # SEQUEL5: Remove
52
126
  @client_min_messages = :warning
53
127
  @force_standard_strings = true
54
-
55
128
  class << self
56
- # By default, Sequel sets the minimum level of log messages sent to the client
57
- # to WARNING, where PostgreSQL uses a default of NOTICE. This is to avoid a lot
58
- # of mostly useless messages when running migrations, such as a couple of lines
59
- # for every serial primary key field.
60
- attr_accessor :client_min_messages
61
-
62
- # By default, Sequel forces the use of standard strings, so that
63
- # '\\' is interpreted as \\ and not \. While PostgreSQL <9.1 defaults
64
- # to interpreting plain strings, newer versions use standard strings by
65
- # default. Sequel assumes that SQL standard strings will be used. Setting
66
- # this to false means Sequel will use the database's default.
67
- attr_accessor :force_standard_strings
129
+ def client_min_messages
130
+ Sequel::Deprecation.deprecate("Sequel::Postgres.client_min_messages", "Use the :client_min_messages Database option instead")
131
+ @client_min_messages
132
+ end
133
+ def client_min_messages=(v)
134
+ Sequel::Deprecation.deprecate("Sequel::Postgres.client_min_messages=", "Use the :client_min_messages Database option instead")
135
+ @client_min_messages = v
136
+ end
137
+
138
+ def force_standard_strings
139
+ Sequel::Deprecation.deprecate("Sequel::Postgres.force_standard_strings", "Use the :force_standard_strings Database option instead")
140
+ @force_standard_strings
141
+ end
142
+ def force_standard_strings=(v)
143
+ Sequel::Deprecation.deprecate("Sequel::Postgres.force_standard_strings=", "Use the :force_standard_strings Database option instead")
144
+ @force_standard_strings = v
145
+ end
68
146
  end
69
147
 
70
148
  class CreateTableGenerator < Sequel::Schema::CreateTableGenerator
@@ -179,6 +257,12 @@ module Sequel
179
257
  # having callable values for the conversion proc for that type.
180
258
  attr_reader :conversion_procs
181
259
 
260
+ # Set a conversion proc for the given oid. The callable can
261
+ # be passed either as a argument or a block.
262
+ def add_conversion_proc(oid, callable=Proc.new)
263
+ conversion_procs[oid] = callable
264
+ end
265
+
182
266
  # Add a conversion proc for a named type. This should be used
183
267
  # for types without fixed OIDs, which includes all types that
184
268
  # are not included in a default PostgreSQL installation. If
@@ -190,7 +274,12 @@ module Sequel
190
274
  Sequel::Deprecation.deprecate("Sequel::PG_NAMED_TYPES", "Call Database#add_named_conversion_proc directly for each database you want to support the #{name} type")
191
275
  end
192
276
  end
193
- add_named_conversion_procs(conversion_procs, name=>block)
277
+ add_named_conversion_procs(conversion_procs, name=>block) # SEQUEL5: Remove
278
+ # SEQUEL5:
279
+ #unless oid = from(:pg_type).where(:typtype=>['b', 'e'], :typname=>name.to_s).get(:oid)
280
+ # raise Error, "No matching type in pg_type for #{name.inspect}"
281
+ #end
282
+ #add_conversion_proc(oid, block) # SEQUEL5
194
283
  end
195
284
 
196
285
  # Commit an existing prepared transaction with the given transaction
@@ -316,68 +405,67 @@ module Sequel
316
405
  def foreign_key_list(table, opts=OPTS)
317
406
  m = output_identifier_meth
318
407
  schema, _ = opts.fetch(:schema, schema_and_table(table))
319
- range = 0...32
320
408
  oid = regclass_oid(table)
321
409
 
322
- base_ds = metadata_dataset.
410
+ if server_version >= 90500
411
+ cpos = Sequel.expr{array_position(co[:conkey], att[:attnum])}
412
+ rpos = Sequel.expr{array_position(co[:confkey], att2[:attnum])}
413
+ else
414
+ range = 0...32
415
+ cpos = Sequel.expr{SQL::CaseExpression.new(range.map{|x| [SQL::Subscript.new(co[:conkey], [x]), x]}, 32, att[:attnum])}
416
+ rpos = Sequel.expr{SQL::CaseExpression.new(range.map{|x| [SQL::Subscript.new(co[:confkey], [x]), x]}, 32, att2[:attnum])}
417
+ end
418
+
419
+ ds = metadata_dataset.
323
420
  from{pg_constraint.as(:co)}.
324
421
  join(Sequel[:pg_class].as(:cl), :oid=>:conrelid).
422
+ join(Sequel[:pg_attribute].as(:att), :attrelid=>:oid, :attnum=>SQL::Function.new(:ANY, Sequel[:co][:conkey])).
423
+ join(Sequel[:pg_class].as(:cl2), :oid=>Sequel[:co][:confrelid]).
424
+ join(Sequel[:pg_attribute].as(:att2), :attrelid=>:oid, :attnum=>SQL::Function.new(:ANY, Sequel[:co][:confkey])).
425
+ order{[co[:conname], cpos]}.
325
426
  where{{
326
427
  cl[:relkind]=>'r',
327
428
  co[:contype]=>'f',
328
- cl[:oid]=>oid}}
329
-
330
- # We split the parsing into two separate queries, which are merged manually later.
331
- # This is because PostgreSQL stores both the referencing and referenced columns in
332
- # arrays, and I don't know a simple way to not create a cross product, as PostgreSQL
333
- # doesn't appear to have a function that takes an array and element and gives you
334
- # the index of that element in the array.
335
-
336
- ds = base_ds.
337
- join(Sequel[:pg_attribute].as(:att), :attrelid=>:oid, :attnum=>SQL::Function.new(:ANY, Sequel[:co][:conkey])).
338
- order{[
339
- co[:conname],
340
- SQL::CaseExpression.new(range.map{|x| [SQL::Subscript.new(co[:conkey], [x]), x]}, 32, att[:attnum])]}.
429
+ cl[:oid]=>oid,
430
+ cpos=>rpos
431
+ }}.
341
432
  select{[
342
433
  co[:conname].as(:name),
343
434
  att[:attname].as(:column),
344
435
  co[:confupdtype].as(:on_update),
345
436
  co[:confdeltype].as(:on_delete),
346
- SQL::BooleanExpression.new(:AND, co[:condeferrable], co[:condeferred]).as(:deferrable)]}
347
-
348
- ref_ds = base_ds.
349
- join(Sequel[:pg_class].as(:cl2), :oid=>Sequel[:co][:confrelid]).
350
- join(Sequel[:pg_attribute].as(:att2), :attrelid=>:oid, :attnum=>SQL::Function.new(:ANY, Sequel[:co][:confkey])).
351
- order{[
352
- co[:conname],
353
- SQL::CaseExpression.new(range.map{|x| [SQL::Subscript.new(co[:confkey], [x]), x]}, 32, att2[:attnum])]}.
354
- select{[
355
- co[:conname].as(:name),
356
437
  cl2[:relname].as(:table),
357
- att2[:attname].as(:refcolumn)]}
438
+ att2[:attname].as(:refcolumn),
439
+ SQL::BooleanExpression.new(:AND, co[:condeferrable], co[:condeferred]).as(:deferrable)
440
+ ]}
358
441
 
359
442
  # If a schema is given, we only search in that schema, and the returned :table
360
443
  # entry is schema qualified as well.
361
444
  if schema
362
- ref_ds = ref_ds.join(Sequel[:pg_namespace].as(:nsp2), :oid=>Sequel[:cl2][:relnamespace]).
445
+ ds = ds.join(Sequel[:pg_namespace].as(:nsp2), :oid=>Sequel[:cl2][:relnamespace]).
363
446
  select_append{nsp2[:nspname].as(:schema)}
364
447
  end
365
448
 
366
449
  h = {}
367
450
  fklod_map = FOREIGN_KEY_LIST_ON_DELETE_MAP
451
+
368
452
  ds.each do |row|
369
453
  if r = h[row[:name]]
370
454
  r[:columns] << m.call(row[:column])
455
+ r[:key] << m.call(row[:refcolumn])
371
456
  else
372
- h[row[:name]] = {:name=>m.call(row[:name]), :columns=>[m.call(row[:column])], :on_update=>fklod_map[row[:on_update]], :on_delete=>fklod_map[row[:on_delete]], :deferrable=>row[:deferrable]}
457
+ h[row[:name]] = {
458
+ :name=>m.call(row[:name]),
459
+ :columns=>[m.call(row[:column])],
460
+ :key=>[m.call(row[:refcolumn])],
461
+ :on_update=>fklod_map[row[:on_update]],
462
+ :on_delete=>fklod_map[row[:on_delete]],
463
+ :deferrable=>row[:deferrable],
464
+ :table=>schema ? SQL::QualifiedIdentifier.new(m.call(row[:schema]), m.call(row[:table])) : m.call(row[:table])
465
+ }
373
466
  end
374
467
  end
375
- ref_ds.each do |row|
376
- r = h[row[:name]]
377
- r[:table] ||= schema ? SQL::QualifiedIdentifier.new(m.call(row[:schema]), m.call(row[:table])) : m.call(row[:table])
378
- r[:key] ||= []
379
- r[:key] << m.call(row[:refcolumn])
380
- end
468
+
381
469
  h.values
382
470
  end
383
471
 
@@ -391,9 +479,18 @@ module Sequel
391
479
  # Use the pg_* system tables to determine indexes on a table
392
480
  def indexes(table, opts=OPTS)
393
481
  m = output_identifier_meth
394
- range = 0...32
395
- attnums = server_version >= 80100 ? SQL::Function.new(:ANY, Sequel[:ind][:indkey]) : range.map{|x| SQL::Subscript.new(Sequel[:ind][:indkey], [x])}
396
482
  oid = regclass_oid(table, opts)
483
+
484
+ if server_version >= 90500
485
+ order = [Sequel[:indc][:relname], Sequel.function(:array_position, Sequel[:ind][:indkey], Sequel[:att][:attnum])]
486
+ else
487
+ range = 0...32
488
+ order = [Sequel[:indc][:relname], SQL::CaseExpression.new(range.map{|x| [SQL::Subscript.new(Sequel[:ind][:indkey], [x]), x]}, 32, Sequel[:att][:attnum])]
489
+ attnums = range.map{|x| SQL::Subscript.new(Sequel[:ind][:indkey], [x])} unless server_version >= 80100
490
+ end
491
+
492
+ attnums ||= SQL::Function.new(:ANY, Sequel[:ind][:indkey])
493
+
397
494
  ds = metadata_dataset.
398
495
  from{pg_class.as(:tab)}.
399
496
  join(Sequel[:pg_index].as(:ind), :indrelid=>:oid).
@@ -407,7 +504,7 @@ module Sequel
407
504
  :indpred=>nil,
408
505
  :indisvalid=>true,
409
506
  tab[:oid]=>oid}}.
410
- order{[indc[:relname], SQL::CaseExpression.new(range.map{|x| [SQL::Subscript.new(ind[:indkey], [x]), x]}, 32, att[:attnum])]}.
507
+ order(*order).
411
508
  select{[indc[:relname].as(:name), ind[:indisunique].as(:unique), att[:attname].as(:column), con[:condeferrable].as(:deferrable)]}
412
509
 
413
510
  ds = ds.where(:indisready=>true, :indcheckxmin=>false) if server_version >= 80300
@@ -478,9 +575,9 @@ module Sequel
478
575
  run "REFRESH MATERIALIZED VIEW#{' CONCURRENTLY' if opts[:concurrently]} #{quote_schema_table(name)}"
479
576
  end
480
577
 
481
- # Reset the database's conversion procs, requires a server query if there
482
- # any named types.
578
+ # SEQUEL5: Remove
483
579
  def reset_conversion_procs
580
+ Sequel::Deprecation.deprecate('Database#reset_conversion_procs', 'There should no longer be a need to reset conversion procs')
484
581
  @conversion_procs = get_conversion_procs
485
582
  conversion_procs_updated
486
583
  @conversion_procs
@@ -626,8 +723,7 @@ module Sequel
626
723
 
627
724
  private
628
725
 
629
- # Do a type name-to-oid lookup using the database and update the procs
630
- # with the related proc if the database supports the type.
726
+ # SEQUEL5: Remove
631
727
  def add_named_conversion_procs(procs, named_procs)
632
728
  unless (named_procs).empty?
633
729
  convert_named_procs_to_procs(named_procs).each do |oid, pr|
@@ -730,9 +826,10 @@ module Sequel
730
826
  def connection_configuration_sqls
731
827
  sqls = []
732
828
 
733
- sqls << "SET standard_conforming_strings = ON" if typecast_value_boolean(@opts.fetch(:force_standard_strings, Postgres.force_standard_strings))
829
+ sqls << "SET standard_conforming_strings = ON" if typecast_value_boolean(@opts.fetch(:force_standard_strings, Postgres.instance_variable_get(:@force_standard_strings))) # , true)) # SEQUEL5
734
830
 
735
- if (cmm = @opts.fetch(:client_min_messages, Postgres.client_min_messages)) && !cmm.to_s.empty?
831
+ cmm = @opts.fetch(:client_min_messages, Postgres.instance_variable_get(:@client_min_messages)) # , :warning) # SEQUEL5
832
+ if cmm && !cmm.to_s.empty?
736
833
  cmm = cmm.to_s.upcase.strip
737
834
  unless VALID_CLIENT_MIN_MESSAGES.include?(cmm)
738
835
  raise Error, "Unsupported client_min_messages setting: #{cmm}"
@@ -775,12 +872,12 @@ module Sequel
775
872
  end
776
873
  end
777
874
 
778
- # Callback used when conversion procs are updated.
875
+ # SEQUEL5: Remove
779
876
  def conversion_procs_updated
780
877
  nil
781
878
  end
782
879
 
783
- # Convert the hash of named conversion procs into a hash a oid conversion procs.
880
+ # SEQUEL5: Remove
784
881
  def convert_named_procs_to_procs(named_procs)
785
882
  h = {}
786
883
  from(:pg_type).where(:typtype=>['b', 'e'], :typname=>named_procs.keys.map(&:to_s)).select_map([:oid, :typname]).each do |oid, name|
@@ -789,12 +886,12 @@ module Sequel
789
886
  h
790
887
  end
791
888
 
792
- # Copy the conversion procs related to the given oids from PG_TYPES into
793
- # the conversion procs for this instance.
889
+ # SEQUEL5: Remove
794
890
  def copy_conversion_procs(oids)
891
+ Sequel::Deprecation.deprecate("Database#copy_conversion_procs", "There is no reason to use this anymore")
795
892
  procs = conversion_procs
796
893
  oids.each do |oid|
797
- procs[oid] = PG_TYPES[oid]
894
+ procs[oid] = PG__TYPES[oid]
798
895
  end
799
896
  conversion_procs_updated
800
897
  end
@@ -965,11 +1062,6 @@ module Sequel
965
1062
  create_view_sql_append_columns("CREATE #{'OR REPLACE 'if options[:replace]}#{'TEMPORARY 'if options[:temp]}#{'RECURSIVE ' if options[:recursive]}#{'MATERIALIZED ' if options[:materialized]}VIEW #{quote_schema_table(name)}", options[:columns] || options[:recursive])
966
1063
  end
967
1064
 
968
- # The errors that the main adapters can raise, depends on the adapter being used
969
- def database_error_classes
970
- CONVERTED_EXCEPTIONS
971
- end
972
-
973
1065
  # SQL for dropping a function from the database.
974
1066
  def drop_function_sql(name, opts=OPTS)
975
1067
  "DROP FUNCTION#{' IF EXISTS' if opts[:if_exists]} #{name}#{sql_function_args(opts[:args])}#{' CASCADE' if opts[:cascade]}"
@@ -1017,9 +1109,9 @@ module Sequel
1017
1109
  ds.where{{pg_namespace[:nspname]=>expr}}
1018
1110
  end
1019
1111
 
1020
- # Return a hash with oid keys and callable values, used for converting types.
1112
+ # SEQUEL5: Remove
1021
1113
  def get_conversion_procs
1022
- procs = PG_TYPES.dup
1114
+ procs = PG__TYPES.dup
1023
1115
  procs[1184] = procs[1114] = method(:to_application_timestamp)
1024
1116
  unless PG_NAMED__TYPES.empty?
1025
1117
  Sequel::Deprecation.deprecate("Sequel::PG_NAMED_TYPES", "Call Database#add_named_conversion_proc directly for each Database instance where you want to support the following type(s): #{PG_NAMED__TYPES.keys.join(', ')}")
@@ -1056,8 +1148,10 @@ module Sequel
1056
1148
  @primary_keys = {}
1057
1149
  @primary_key_sequences = {}
1058
1150
  @supported_types = {}
1059
- @conversion_procs = PG_TYPES.dup
1060
- reset_conversion_procs
1151
+ @conversion_procs = get_conversion_procs # SEQUEL5: Remove
1152
+ conversion_procs_updated # SEQUEL5: Remove
1153
+ # @conversion_procs = CONVERSION_PROCS.dup # SEQUEL5
1154
+ # procs[1184] = procs[1114] = method(:to_application_timestamp) # SEQUEL5
1061
1155
  end
1062
1156
 
1063
1157
  # Backbone of the tables and views support.
@@ -1299,16 +1393,24 @@ module Sequel
1299
1393
  AS = ' AS '.freeze
1300
1394
  Sequel::Deprecation.deprecate_constant(self, :AS)
1301
1395
  XOR_OP = ' # '.freeze
1396
+ Sequel::Deprecation.deprecate_constant(self, :XOR_OP)
1302
1397
  CRLF = "\r\n".freeze
1398
+ Sequel::Deprecation.deprecate_constant(self, :CRLF)
1303
1399
  BLOB_RE = /[\000-\037\047\134\177-\377]/n.freeze
1400
+ Sequel::Deprecation.deprecate_constant(self, :BLOB_RE)
1304
1401
  WINDOW = " WINDOW ".freeze
1402
+ Sequel::Deprecation.deprecate_constant(self, :WINDOW)
1305
1403
  SELECT_VALUES = "VALUES ".freeze
1404
+ Sequel::Deprecation.deprecate_constant(self, :SELECT_VALUES)
1306
1405
  EMPTY_STRING = ''.freeze
1406
+ Sequel::Deprecation.deprecate_constant(self, :EMPTY_STRING)
1307
1407
  SKIP_LOCKED = " SKIP LOCKED".freeze
1408
+ Sequel::Deprecation.deprecate_constant(self, :SKIP_LOCKED)
1409
+ NON_SQL_OPTIONS = (Dataset::NON_SQL_OPTIONS + [:cursor, :insert_conflict]).freeze
1410
+ Sequel::Deprecation.deprecate_constant(self, :NON_SQL_OPTIONS)
1308
1411
 
1309
1412
  NULL = LiteralString.new('NULL').freeze
1310
- LOCK_MODES = ['ACCESS SHARE', 'ROW SHARE', 'ROW EXCLUSIVE', 'SHARE UPDATE EXCLUSIVE', 'SHARE', 'SHARE ROW EXCLUSIVE', 'EXCLUSIVE', 'ACCESS EXCLUSIVE'].each(&:freeze)
1311
- NON_SQL_OPTIONS = (Dataset::NON_SQL_OPTIONS + [:cursor, :insert_conflict]).freeze
1413
+ LOCK_MODES = ['ACCESS SHARE', 'ROW SHARE', 'ROW EXCLUSIVE', 'SHARE UPDATE EXCLUSIVE', 'SHARE', 'SHARE ROW EXCLUSIVE', 'EXCLUSIVE', 'ACCESS EXCLUSIVE'].each(&:freeze)#.freeze # SEQUEL5
1312
1414
 
1313
1415
  Dataset.def_sql_method(self, :delete, [['if server_version >= 90100', %w'with delete from using where returning'], ['else', %w'delete from using where returning']])
1314
1416
  Dataset.def_sql_method(self, :insert, [['if server_version >= 90500', %w'with insert into columns values conflict returning'], ['elsif server_version >= 90100', %w'with insert into columns values returning'], ['else', %w'insert into columns values returning']])
@@ -1768,7 +1870,7 @@ module Sequel
1768
1870
  sql << "'" << v.gsub("'", "''") << "'"
1769
1871
  end
1770
1872
 
1771
- # PostgreSQL uses FALSE for false values
1873
+ # PostgreSQL uses true for true values
1772
1874
  def literal_true
1773
1875
  'true'
1774
1876
  end
@@ -1779,8 +1881,8 @@ module Sequel
1779
1881
  end
1780
1882
 
1781
1883
  # Dataset options that do not affect the generated SQL.
1782
- def non_sql_options
1783
- NON_SQL_OPTIONS
1884
+ def non_sql_option?(key)
1885
+ super || key == :cursor || key == :insert_conflict
1784
1886
  end
1785
1887
 
1786
1888
  # PostgreSQL requires parentheses around compound datasets if they use