sequel 4.43.0 → 4.44.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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +40 -0
  3. data/doc/active_record.rdoc +2 -2
  4. data/doc/code_order.rdoc +15 -0
  5. data/doc/dataset_filtering.rdoc +1 -1
  6. data/doc/model_dataset_method_design.rdoc +132 -0
  7. data/doc/opening_databases.rdoc +2 -2
  8. data/doc/release_notes/4.44.0.txt +125 -0
  9. data/lib/sequel/adapters/jdbc.rb +5 -1
  10. data/lib/sequel/adapters/jdbc/as400.rb +1 -1
  11. data/lib/sequel/adapters/postgres.rb +23 -14
  12. data/lib/sequel/core.rb +1 -1
  13. data/lib/sequel/database/schema_generator.rb +27 -0
  14. data/lib/sequel/dataset/actions.rb +1 -1
  15. data/lib/sequel/dataset/query.rb +5 -1
  16. data/lib/sequel/extensions/eval_inspect.rb +4 -4
  17. data/lib/sequel/extensions/implicit_subquery.rb +48 -0
  18. data/lib/sequel/extensions/to_dot.rb +1 -1
  19. data/lib/sequel/model.rb +3 -5
  20. data/lib/sequel/model/associations.rb +107 -4
  21. data/lib/sequel/model/base.rb +98 -12
  22. data/lib/sequel/model/dataset_module.rb +1 -1
  23. data/lib/sequel/plugins/active_model.rb +11 -3
  24. data/lib/sequel/plugins/association_dependencies.rb +7 -0
  25. data/lib/sequel/plugins/auto_validations.rb +10 -0
  26. data/lib/sequel/plugins/blacklist_security.rb +13 -4
  27. data/lib/sequel/plugins/class_table_inheritance.rb +11 -0
  28. data/lib/sequel/plugins/column_conflicts.rb +8 -0
  29. data/lib/sequel/plugins/composition.rb +12 -2
  30. data/lib/sequel/plugins/constraint_validations.rb +12 -0
  31. data/lib/sequel/plugins/csv_serializer.rb +9 -0
  32. data/lib/sequel/plugins/defaults_setter.rb +6 -0
  33. data/lib/sequel/plugins/force_encoding.rb +4 -3
  34. data/lib/sequel/plugins/hook_class_methods.rb +6 -0
  35. data/lib/sequel/plugins/input_transformer.rb +9 -0
  36. data/lib/sequel/plugins/insert_returning_select.rb +8 -0
  37. data/lib/sequel/plugins/instance_hooks.rb +4 -3
  38. data/lib/sequel/plugins/json_serializer.rb +9 -0
  39. data/lib/sequel/plugins/lazy_attributes.rb +7 -0
  40. data/lib/sequel/plugins/many_through_many.rb +13 -2
  41. data/lib/sequel/plugins/nested_attributes.rb +7 -0
  42. data/lib/sequel/plugins/pg_array_associations.rb +18 -2
  43. data/lib/sequel/plugins/pg_row.rb +3 -3
  44. data/lib/sequel/plugins/pg_typecast_on_load.rb +7 -0
  45. data/lib/sequel/plugins/prepared_statements.rb +2 -2
  46. data/lib/sequel/plugins/prepared_statements_safe.rb +7 -0
  47. data/lib/sequel/plugins/serialization.rb +9 -0
  48. data/lib/sequel/plugins/single_table_inheritance.rb +13 -1
  49. data/lib/sequel/plugins/subclasses.rb +15 -1
  50. data/lib/sequel/plugins/touch.rb +7 -0
  51. data/lib/sequel/plugins/tree.rb +7 -0
  52. data/lib/sequel/plugins/typecast_on_load.rb +7 -0
  53. data/lib/sequel/plugins/update_refresh.rb +24 -13
  54. data/lib/sequel/plugins/validation_class_methods.rb +13 -0
  55. data/lib/sequel/sql.rb +28 -0
  56. data/lib/sequel/version.rb +1 -1
  57. data/spec/adapters/postgres_spec.rb +18 -15
  58. data/spec/core/dataset_spec.rb +5 -0
  59. data/spec/core/expression_filters_spec.rb +33 -0
  60. data/spec/extensions/active_model_spec.rb +15 -1
  61. data/spec/extensions/association_dependencies_spec.rb +8 -0
  62. data/spec/extensions/auto_validations_spec.rb +8 -0
  63. data/spec/extensions/blacklist_security_spec.rb +6 -0
  64. data/spec/extensions/class_table_inheritance_spec.rb +9 -0
  65. data/spec/extensions/column_conflicts_spec.rb +6 -0
  66. data/spec/extensions/composition_spec.rb +8 -0
  67. data/spec/extensions/constraint_validations_plugin_spec.rb +12 -0
  68. data/spec/extensions/csv_serializer_spec.rb +7 -0
  69. data/spec/extensions/defaults_setter_spec.rb +7 -0
  70. data/spec/extensions/force_encoding_spec.rb +14 -0
  71. data/spec/extensions/hook_class_methods_spec.rb +10 -0
  72. data/spec/extensions/implicit_subquery_spec.rb +60 -0
  73. data/spec/extensions/input_transformer_spec.rb +10 -0
  74. data/spec/extensions/insert_returning_select_spec.rb +6 -0
  75. data/spec/extensions/json_serializer_spec.rb +7 -0
  76. data/spec/extensions/lazy_attributes_spec.rb +6 -0
  77. data/spec/extensions/many_through_many_spec.rb +44 -0
  78. data/spec/extensions/nested_attributes_spec.rb +5 -0
  79. data/spec/extensions/pg_array_associations_spec.rb +46 -0
  80. data/spec/extensions/pg_typecast_on_load_spec.rb +5 -0
  81. data/spec/extensions/prepared_statements_safe_spec.rb +5 -0
  82. data/spec/extensions/serialization_spec.rb +7 -0
  83. data/spec/extensions/single_table_inheritance_spec.rb +19 -2
  84. data/spec/extensions/subclasses_spec.rb +13 -0
  85. data/spec/extensions/to_dot_spec.rb +1 -1
  86. data/spec/extensions/touch_spec.rb +6 -0
  87. data/spec/extensions/tree_spec.rb +6 -0
  88. data/spec/extensions/typecast_on_load_spec.rb +6 -0
  89. data/spec/extensions/update_refresh_spec.rb +7 -1
  90. data/spec/extensions/validation_class_methods_spec.rb +13 -0
  91. data/spec/model/association_reflection_spec.rb +177 -0
  92. data/spec/model/associations_spec.rb +16 -0
  93. data/spec/model/dataset_methods_spec.rb +59 -0
  94. data/spec/model/model_spec.rb +59 -0
  95. metadata +8 -2
@@ -39,7 +39,7 @@ module Sequel
39
39
  end
40
40
 
41
41
  meths = (<<-METHS).split.map(&:to_sym)
42
- distinct grep group group_and_count group_append
42
+ distinct eager grep group group_and_count group_append
43
43
  limit offset order order_append order_prepend
44
44
  select select_all select_append select_group server
45
45
  METHS
@@ -18,6 +18,9 @@ module Sequel
18
18
  # # Make the Album class active_model compliant
19
19
  # Album.plugin :active_model
20
20
  module ActiveModel
21
+ # The default string to join composite primary keys with in to_param.
22
+ DEFAULT_TO_PARAM_JOINER = '-'.freeze
23
+
21
24
  # ActiveModel compliant error class
22
25
  class Errors < Sequel::Model::Errors
23
26
  # Add autovivification so that #[] always returns an array.
@@ -28,6 +31,14 @@ module Sequel
28
31
 
29
32
  module ClassMethods
30
33
  include ::ActiveModel::Naming
34
+
35
+ # Cache model_name and to_partial path value before freezing.
36
+ def freeze
37
+ model_name
38
+ _to_partial_path
39
+
40
+ super
41
+ end
31
42
 
32
43
  # Class level cache for to_partial_path.
33
44
  def _to_partial_path
@@ -36,9 +47,6 @@ module Sequel
36
47
  end
37
48
 
38
49
  module InstanceMethods
39
- # The default string to join composite primary keys with in to_param.
40
- DEFAULT_TO_PARAM_JOINER = '-'.freeze
41
-
42
50
  # Record that an object was destroyed, for later use by
43
51
  # destroyed?
44
52
  def after_destroy
@@ -73,6 +73,13 @@ module Sequel
73
73
  end
74
74
  end
75
75
 
76
+ # Freeze association dependencies when freezing model class.
77
+ def freeze
78
+ @association_dependencies.freeze.each_value(&:freeze)
79
+
80
+ super
81
+ end
82
+
76
83
  Plugins.inherited_instance_variables(self, :@association_dependencies=>:hash_dup)
77
84
  end
78
85
 
@@ -127,6 +127,16 @@ module Sequel
127
127
  @auto_validate_types
128
128
  end
129
129
 
130
+ # Freeze auto_validation settings when freezing model class.
131
+ def freeze
132
+ @auto_validate_not_null_columns.freeze
133
+ @auto_validate_explicit_not_null_columns.freeze
134
+ @auto_validate_max_length_columns.freeze
135
+ @auto_validate_unique_columns.freeze
136
+
137
+ super
138
+ end
139
+
130
140
  # Skip automatic validations for the given validation type (:not_null, :types, :unique).
131
141
  # If :all is given as the type, skip all auto validations.
132
142
  def skip_auto_validations(type)
@@ -15,12 +15,25 @@ module Sequel
15
15
  # # Make the Album class support the blacklist security features.
16
16
  # Album.plugin :blacklist_security
17
17
  module BlacklistSecurity
18
+ # Special array subclass used for marking methods to be removed.
19
+ class ExceptionList < Array
20
+ end
21
+
18
22
  module ClassMethods
19
23
  # Which columns are specifically restricted in a call to set/update/new/etc.
20
24
  # (default: not set). Some columns are restricted regardless of
21
25
  # this setting, such as the primary key column and columns in Model::RESTRICTED_SETTER_METHODS.
22
26
  attr_reader :restricted_columns
23
27
 
28
+ Plugins.inherited_instance_variables(self, :@restricted_columns=>:dup)
29
+
30
+ # Freeze restricted columns when freezing model class.
31
+ def freeze
32
+ @restricted_columns.freeze
33
+
34
+ super
35
+ end
36
+
24
37
  # Set the columns to restrict when using mass assignment (e.g. +set+). Using this means that
25
38
  # attempts to call setter methods for the columns listed here will cause an
26
39
  # exception or be silently skipped (based on the +strict_param_setting+ setting).
@@ -53,10 +66,6 @@ module Sequel
53
66
  end
54
67
 
55
68
  module InstanceMethods
56
- # Special array subclass used for marking methods to be removed.
57
- class ExceptionList < Array
58
- end
59
-
60
69
  # Set all values using the entries in the hash, except for the keys
61
70
  # given in except. You should probably use +set_fields+ or +set_only+
62
71
  # instead of this method, as blacklist approaches to security are a bad idea.
@@ -245,6 +245,17 @@ module Sequel
245
245
  # Alias to sti_model_map, for backwards compatibility.
246
246
  def cti_model_map; sti_model_map; end
247
247
 
248
+ # Freeze CTI information when freezing model class.
249
+ def freeze
250
+ @cti_models.freeze
251
+ @cti_tables.freeze
252
+ @cti_instance_dataset.freeze
253
+ @cti_table_columns.freeze
254
+ @cti_table_map.freeze
255
+
256
+ super
257
+ end
258
+
248
259
  Plugins.inherited_instance_variables(self, :@cti_models=>nil, :@cti_tables=>nil, :@cti_table_columns=>nil, :@cti_instance_dataset=>nil, :@cti_table_map=>nil)
249
260
 
250
261
  def inherited(subclass)
@@ -60,6 +60,14 @@ module Sequel
60
60
  columns.find_all{|c| mod.method_defined?("#{c}=")}.each{|c| set_column_conflict!(c)}
61
61
  end
62
62
 
63
+ # Freeze column conflict information when freezing model class.
64
+ def freeze
65
+ @get_column_conflicts.freeze
66
+ @set_column_conflicts.freeze
67
+
68
+ super
69
+ end
70
+
63
71
  # Set the given column as one with a getter method conflict.
64
72
  def get_column_conflict!(column)
65
73
  @get_column_conflicts[column.to_sym] = @get_column_conflicts[column.to_s] = column.to_sym
@@ -58,7 +58,10 @@ module Sequel
58
58
  module Composition
59
59
  # Define the necessary class instance variables.
60
60
  def self.apply(model)
61
- model.instance_eval{@compositions = {}}
61
+ model.instance_eval do
62
+ @compositions = {}
63
+ include(@composition_module ||= Module.new)
64
+ end
62
65
  end
63
66
 
64
67
  module ClassMethods
@@ -130,7 +133,6 @@ module Sequel
130
133
 
131
134
  # Define getter and setter methods for the composition object.
132
135
  def define_composition_accessor(name, opts=OPTS)
133
- include(@composition_module ||= Module.new) unless composition_module
134
136
  composer = opts[:composer]
135
137
  composition_module.class_eval do
136
138
  define_method(name) do
@@ -148,6 +150,14 @@ module Sequel
148
150
  end
149
151
  end
150
152
  end
153
+
154
+ # Freeze composition information when freezing model class.
155
+ def freeze
156
+ compositions.freeze.each_value(&:freeze)
157
+ composition_module.freeze
158
+
159
+ super
160
+ end
151
161
  end
152
162
 
153
163
  module InstanceMethods
@@ -90,6 +90,18 @@ module Sequel
90
90
  Plugins.inherited_instance_variables(self, :@constraint_validations_table=>nil, :@constraint_validation_options=>:hash_dup)
91
91
  Plugins.after_set_dataset(self, :parse_constraint_validations)
92
92
 
93
+ # Freeze constraint validations data when freezing model class.
94
+ def freeze
95
+ @constraint_validations.freeze.each(&:freeze)
96
+ @constraint_validation_reflections.freeze.each_value do |v|
97
+ v.freeze
98
+ v.each(&:freeze)
99
+ end
100
+ @constraint_validation_options.freeze.each_value(&:freeze)
101
+
102
+ super
103
+ end
104
+
93
105
  private
94
106
 
95
107
  # If the database has not already parsed constraint validation
@@ -95,6 +95,15 @@ module Sequel
95
95
  end
96
96
  end
97
97
 
98
+ # Freeze csv serializier opts when freezing model class
99
+ def freeze
100
+ @csv_serializer_opts.freeze.each_value do |v|
101
+ v.freeze if v.is_a?(Array) || v.is_a?(Hash)
102
+ end
103
+
104
+ super
105
+ end
106
+
98
107
  # Attempt to parse a single instance from the given CSV string
99
108
  def from_csv(csv, opts = {})
100
109
  new.from_csv(csv, opts)
@@ -36,6 +36,12 @@ module Sequel
36
36
 
37
37
  Plugins.after_set_dataset(self, :set_default_values)
38
38
 
39
+ # Freeze default values when freezing model class
40
+ def freeze
41
+ @default_values.freeze
42
+ super
43
+ end
44
+
39
45
  private
40
46
 
41
47
  # Parse the cached database schema for this model and set the default values appropriately.
@@ -58,15 +58,16 @@ module Sequel
58
58
 
59
59
  # Force the encoding for all string values in the given row hash.
60
60
  def force_hash_encoding(row)
61
- fe = model.forced_encoding
62
- row.values.each{|v| v.force_encoding(fe) if v.is_a?(String)} if fe
61
+ if fe = model.forced_encoding
62
+ row.each_value{|v| v.force_encoding(fe) if v.is_a?(String) && !v.is_a?(Sequel::SQL::Blob)}
63
+ end
63
64
  row
64
65
  end
65
66
 
66
67
  # Force the encoding of all returned strings to the model's forced_encoding.
67
68
  def typecast_value(column, value)
68
69
  s = super
69
- if s.is_a?(String) && (fe = model.forced_encoding)
70
+ if s.is_a?(String) && !s.is_a?(Sequel::SQL::Blob) && (fe = model.forced_encoding)
70
71
  s = s.dup if s.frozen?
71
72
  s.force_encoding(fe)
72
73
  end
@@ -82,6 +82,12 @@ module Sequel
82
82
  class_eval("def #{hook}; model.hook_blocks(:#{hook}){|b| return false if instance_eval(&b) == false}; end", __FILE__, __LINE__)
83
83
  end
84
84
  end
85
+
86
+ # Freeze hooks when freezing model class.
87
+ def freeze
88
+ @hooks.freeze.each_value(&:freeze)
89
+ super
90
+ end
85
91
 
86
92
  # Returns true if there are any hook blocks for the given hook.
87
93
  def has_hooks?(hook)
@@ -55,6 +55,15 @@ module Sequel
55
55
  @skip_input_transformer_columns[transformer_name] = []
56
56
  end
57
57
 
58
+ # Freeze input transformers when freezing model class
59
+ def freeze
60
+ @input_transformers.freeze
61
+ @input_transformer_order.freeze
62
+ @skip_input_transformer_columns.freeze.each_value(&:freeze)
63
+
64
+ super
65
+ end
66
+
58
67
  # Set columns that the transformer should skip.
59
68
  def skip_input_transformer(transformer_name, *columns)
60
69
  @skip_input_transformer_columns[transformer_name].concat(columns).uniq!
@@ -30,6 +30,14 @@ module Sequel
30
30
  # The dataset to use to insert new rows. For internal use only.
31
31
  attr_reader :instance_insert_dataset
32
32
 
33
+ # Freeze instance insert dataset when freezing model class.
34
+ def freeze
35
+ super
36
+
37
+ @instance_insert_dataset.freeze if @instance_insert_dataset
38
+ self
39
+ end
40
+
33
41
  private
34
42
 
35
43
  # When reseting the instance dataset, also reset the instance_insert_dataset.
@@ -29,10 +29,11 @@ module Sequel
29
29
  # # Add the instance hook methods just to Album instances
30
30
  # Album.plugin :instance_hooks
31
31
  module InstanceHooks
32
+ BEFORE_HOOKS = Sequel::Model::BEFORE_HOOKS
33
+ AFTER_HOOKS = Sequel::Model::AFTER_HOOKS
34
+ HOOKS = BEFORE_HOOKS + AFTER_HOOKS
35
+
32
36
  module InstanceMethods
33
- BEFORE_HOOKS = Sequel::Model::BEFORE_HOOKS
34
- AFTER_HOOKS = Sequel::Model::AFTER_HOOKS
35
- HOOKS = BEFORE_HOOKS + AFTER_HOOKS
36
37
  HOOKS.each{|h| class_eval(<<-END , __FILE__, __LINE__+1)}
37
38
  def #{h}_hook(&block)
38
39
  raise Sequel::Error, "can't add hooks to frozen object" if frozen?
@@ -152,6 +152,15 @@ module Sequel
152
152
  # The default opts to use when serializing model objects to JSON.
153
153
  attr_reader :json_serializer_opts
154
154
 
155
+ # Freeze json serializier opts when freezing model class
156
+ def freeze
157
+ @json_serializer_opts.freeze.each_value do |v|
158
+ v.freeze if v.is_a?(Array) || v.is_a?(Hash)
159
+ end
160
+
161
+ super
162
+ end
163
+
155
164
  # Attempt to parse a single instance from the given JSON string,
156
165
  # with options passed to InstanceMethods#from_json_node.
157
166
  def from_json(json, opts=OPTS)
@@ -42,6 +42,13 @@ module Sequel
42
42
  # be overridden and call super to get the lazy attribute behavior
43
43
  attr_accessor :lazy_attributes_module
44
44
 
45
+ # Freeze lazy attributes module when freezing model class.
46
+ def freeze
47
+ @lazy_attributes_module.freeze if @lazy_attributes_module
48
+
49
+ super
50
+ end
51
+
45
52
  # Remove the given attributes from the list of columns selected by default.
46
53
  # For each attribute given, create an accessor method that allows a lazy
47
54
  # lookup of the attribute. Each attribute should be given as a symbol.
@@ -81,7 +81,7 @@ module Sequel
81
81
  module ManyThroughMany
82
82
  # The AssociationReflection subclass for many_through_many associations.
83
83
  class ManyThroughManyAssociationReflection < Sequel::Model::Associations::ManyToManyAssociationReflection
84
- Sequel::Model::Associations::ASSOCIATION_TYPES[:many_through_many] = self
84
+ Sequel.synchronize{Sequel::Model::Associations::ASSOCIATION_TYPES[:many_through_many] = self}
85
85
 
86
86
  # many_through_many and one_through_many associations can be clones
87
87
  def cloneable?(ref)
@@ -102,6 +102,17 @@ module Sequel
102
102
  END
103
103
  end
104
104
 
105
+ FINALIZE_SETTINGS = superclass::FINALIZE_SETTINGS.merge(
106
+ :associated_key_table=>:associated_key_table,
107
+ :edges=>:edges,
108
+ :final_edge=>:final_edge,
109
+ :final_reverse_edge=>:final_reverse_edge,
110
+ :reverse_edges=>:reverse_edges
111
+ ).freeze
112
+ def finalize_settings
113
+ FINALIZE_SETTINGS
114
+ end
115
+
105
116
  # The alias for the first join table.
106
117
  def join_table_alias
107
118
  final_reverse_edge[:alias]
@@ -181,7 +192,7 @@ module Sequel
181
192
  end
182
193
 
183
194
  class OneThroughManyAssociationReflection < ManyThroughManyAssociationReflection
184
- Sequel::Model::Associations::ASSOCIATION_TYPES[:one_through_many] = self
195
+ Sequel.synchronize{Sequel::Model::Associations::ASSOCIATION_TYPES[:one_through_many] = self}
185
196
  include Sequel::Model::Associations::SingularAssociationReflection
186
197
  end
187
198
 
@@ -85,6 +85,13 @@ module Sequel
85
85
  # call be overridden and call super to get the default behavior
86
86
  attr_accessor :nested_attributes_module
87
87
 
88
+ # Freeze nested_attributes_module when freezing model class.
89
+ def freeze
90
+ @nested_attributes_module.freeze if @nested_attributes_module
91
+
92
+ super
93
+ end
94
+
88
95
  # Allow nested attributes to be set for the given associations. Options:
89
96
  # :destroy :: Allow destruction of nested records.
90
97
  # :fields :: If provided, should be an Array or proc. If it is an array,
@@ -75,7 +75,7 @@ module Sequel
75
75
  module PgArrayAssociations
76
76
  # The AssociationReflection subclass for many_to_pg_array associations.
77
77
  class ManyToPgArrayAssociationReflection < Sequel::Model::Associations::AssociationReflection
78
- Sequel::Model::Associations::ASSOCIATION_TYPES[:many_to_pg_array] = self
78
+ Sequel.synchronize{Sequel::Model::Associations::ASSOCIATION_TYPES[:many_to_pg_array] = self}
79
79
 
80
80
  def array_type
81
81
  cached_fetch(:array_type) do
@@ -122,6 +122,13 @@ module Sequel
122
122
  nil
123
123
  end
124
124
 
125
+ FINALIZE_SETTINGS = superclass::FINALIZE_SETTINGS.merge(
126
+ :array_type=>:array_type
127
+ ).freeze
128
+ def finalize_settings
129
+ FINALIZE_SETTINGS
130
+ end
131
+
125
132
  # Handle silent failure of add/remove methods if raise_on_save_failure is false.
126
133
  def handle_silent_modification_failure?
127
134
  self[:raise_on_save_failure] == false
@@ -177,7 +184,7 @@ module Sequel
177
184
 
178
185
  # The AssociationReflection subclass for pg_array_to_many associations.
179
186
  class PgArrayToManyAssociationReflection < Sequel::Model::Associations::AssociationReflection
180
- Sequel::Model::Associations::ASSOCIATION_TYPES[:pg_array_to_many] = self
187
+ Sequel.synchronize{Sequel::Model::Associations::ASSOCIATION_TYPES[:pg_array_to_many] = self}
181
188
 
182
189
  def array_type
183
190
  cached_fetch(:array_type) do
@@ -229,6 +236,15 @@ module Sequel
229
236
  nil
230
237
  end
231
238
 
239
+ FINALIZE_SETTINGS = superclass::FINALIZE_SETTINGS.merge(
240
+ :array_type=>:array_type,
241
+ :primary_key=>:primary_key,
242
+ :primary_key_method=>:primary_key_method
243
+ ).freeze
244
+ def finalize_settings
245
+ FINALIZE_SETTINGS
246
+ end
247
+
232
248
  # Handle silent failure of add/remove methods if raise_on_save_failure is false
233
249
  # and save_after_modify is true.
234
250
  def handle_silent_modification_failure?
@@ -52,6 +52,9 @@ module Sequel
52
52
  # DB[:company].insert(:name=>'MS', :address=>
53
53
  # Address.load(:street=>'123 Foo St', :city=>'Bar Town', :zip=>'12345'))
54
54
  module PgRow
55
+ ROW = 'ROW'.freeze
56
+ CAST = '::'.freeze
57
+
55
58
  # When loading the extension, make sure the database has the pg_row extension
56
59
  # loaded, load the custom database extensions, and automatically register the
57
60
  # row type if the model has a dataset.
@@ -70,9 +73,6 @@ module Sequel
70
73
  end
71
74
 
72
75
  module InstanceMethods
73
- ROW = 'ROW'.freeze
74
- CAST = '::'.freeze
75
-
76
76
  # Literalize the model instance and append it to the sql.
77
77
  def sql_literal_append(ds, sql)
78
78
  sql << ROW