sequel 4.39.0 → 4.40.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 (85) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +34 -0
  3. data/README.rdoc +8 -4
  4. data/doc/active_record.rdoc +1 -1
  5. data/doc/advanced_associations.rdoc +7 -7
  6. data/doc/association_basics.rdoc +7 -7
  7. data/doc/cheat_sheet.rdoc +5 -3
  8. data/doc/core_extensions.rdoc +3 -3
  9. data/doc/dataset_filtering.rdoc +1 -1
  10. data/doc/object_model.rdoc +16 -7
  11. data/doc/postgresql.rdoc +3 -3
  12. data/doc/querying.rdoc +3 -3
  13. data/doc/release_notes/4.40.0.txt +179 -0
  14. data/doc/security.rdoc +2 -1
  15. data/doc/sql.rdoc +34 -18
  16. data/doc/testing.rdoc +1 -0
  17. data/doc/virtual_rows.rdoc +11 -2
  18. data/lib/sequel/adapters/jdbc/derby.rb +7 -1
  19. data/lib/sequel/adapters/jdbc/h2.rb +15 -1
  20. data/lib/sequel/adapters/oracle.rb +9 -5
  21. data/lib/sequel/adapters/postgres.rb +0 -1
  22. data/lib/sequel/adapters/shared/cubrid.rb +11 -11
  23. data/lib/sequel/adapters/shared/db2.rb +4 -8
  24. data/lib/sequel/adapters/shared/mssql.rb +41 -28
  25. data/lib/sequel/adapters/shared/mysql.rb +9 -6
  26. data/lib/sequel/adapters/shared/oracle.rb +16 -5
  27. data/lib/sequel/adapters/shared/postgres.rb +84 -45
  28. data/lib/sequel/adapters/shared/sqlanywhere.rb +29 -15
  29. data/lib/sequel/adapters/shared/sqlite.rb +6 -6
  30. data/lib/sequel/core.rb +61 -10
  31. data/lib/sequel/database/connecting.rb +2 -1
  32. data/lib/sequel/database/features.rb +7 -0
  33. data/lib/sequel/database/query.rb +1 -1
  34. data/lib/sequel/database/schema_methods.rb +30 -3
  35. data/lib/sequel/database/transactions.rb +4 -2
  36. data/lib/sequel/dataset/actions.rb +1 -1
  37. data/lib/sequel/dataset/graph.rb +6 -1
  38. data/lib/sequel/dataset/query.rb +14 -7
  39. data/lib/sequel/dataset/sql.rb +2 -2
  40. data/lib/sequel/extensions/core_extensions.rb +2 -1
  41. data/lib/sequel/extensions/pg_row.rb +2 -2
  42. data/lib/sequel/extensions/s.rb +57 -0
  43. data/lib/sequel/extensions/set_overrides.rb +5 -1
  44. data/lib/sequel/extensions/sql_expr.rb +1 -0
  45. data/lib/sequel/extensions/symbol_aref.rb +71 -0
  46. data/lib/sequel/extensions/symbol_aref_refinement.rb +41 -0
  47. data/lib/sequel/extensions/symbol_as.rb +23 -0
  48. data/lib/sequel/extensions/symbol_as_refinement.rb +35 -0
  49. data/lib/sequel/model/base.rb +3 -3
  50. data/lib/sequel/plugins/class_table_inheritance.rb +14 -3
  51. data/lib/sequel/plugins/column_select.rb +4 -2
  52. data/lib/sequel/plugins/dataset_associations.rb +12 -4
  53. data/lib/sequel/plugins/insert_returning_select.rb +1 -1
  54. data/lib/sequel/plugins/mssql_optimistic_locking.rb +1 -1
  55. data/lib/sequel/plugins/prepared_statements.rb +1 -0
  56. data/lib/sequel/sql.rb +40 -8
  57. data/lib/sequel/version.rb +1 -1
  58. data/spec/adapters/firebird_spec.rb +3 -3
  59. data/spec/adapters/mssql_spec.rb +40 -40
  60. data/spec/adapters/mysql_spec.rb +5 -5
  61. data/spec/adapters/oracle_spec.rb +4 -4
  62. data/spec/adapters/postgres_spec.rb +135 -124
  63. data/spec/adapters/spec_helper.rb +1 -0
  64. data/spec/adapters/sqlite_spec.rb +6 -6
  65. data/spec/core/dataset_spec.rb +2 -2
  66. data/spec/core/expression_filters_spec.rb +43 -2
  67. data/spec/core/schema_spec.rb +35 -1
  68. data/spec/core_extensions_spec.rb +27 -0
  69. data/spec/extensions/class_table_inheritance_spec.rb +8 -0
  70. data/spec/extensions/column_select_spec.rb +8 -0
  71. data/spec/extensions/core_refinements_spec.rb +1 -1
  72. data/spec/extensions/dataset_associations_spec.rb +9 -0
  73. data/spec/extensions/insert_returning_select_spec.rb +20 -0
  74. data/spec/extensions/prepared_statements_spec.rb +7 -0
  75. data/spec/extensions/s_spec.rb +60 -0
  76. data/spec/extensions/symbol_aref_refinement_spec.rb +28 -0
  77. data/spec/extensions/symbol_as_refinement_spec.rb +21 -0
  78. data/spec/integration/associations_test.rb +62 -57
  79. data/spec/integration/dataset_test.rb +54 -54
  80. data/spec/integration/eager_loader_test.rb +7 -7
  81. data/spec/integration/plugin_test.rb +20 -20
  82. data/spec/integration/prepared_statement_test.rb +1 -1
  83. data/spec/integration/schema_test.rb +21 -0
  84. data/spec/integration/spec_helper.rb +1 -0
  85. metadata +12 -2
@@ -135,13 +135,14 @@ module Sequel
135
135
  #
136
136
  # # in file sequel/adapters/shared/mydb.rb
137
137
  # module Sequel::MyDB
138
- # Sequel::Database.set_shared_adapter_scheme :mydb, :self
138
+ # Sequel::Database.set_shared_adapter_scheme :mydb, self
139
139
  #
140
140
  # def self.mock_adapter_setup(db)
141
141
  # # ...
142
142
  # end
143
143
  #
144
144
  # module DatabaseMethods
145
+ # extend Sequel::Database::ResetIdentifierMangling
145
146
  # # ...
146
147
  # end
147
148
  #
@@ -108,6 +108,13 @@ module Sequel
108
108
 
109
109
  private
110
110
 
111
+ # Whether the database supports adding primary key constraints on NULLable columns,
112
+ # automatically making them NOT NULL. If false, the columns must be set NOT NULL
113
+ # before the primary key constraint is added.
114
+ def can_add_primary_key_constraint_on_nullable_columns?
115
+ true
116
+ end
117
+
111
118
  # Whether the database supports combining multiple alter table
112
119
  # operations into a single query, false by default.
113
120
  def supports_combining_alter_table_ops?
@@ -159,7 +159,7 @@ module Sequel
159
159
  end
160
160
 
161
161
  cols = schema_parse_table(table_name, opts)
162
- raise(Error, 'schema parsing returned no columns, table probably doesn\'t exist') if cols.nil? || cols.empty?
162
+ raise(Error, "schema parsing returned no columns, table #{table_name.inspect} probably doesn't exist") if cols.nil? || cols.empty?
163
163
 
164
164
  primary_keys = 0
165
165
  auto_increment_set = false
@@ -422,7 +422,15 @@ module Sequel
422
422
 
423
423
  # Apply the operations in the given generator to the table given by name.
424
424
  def apply_alter_table_generator(name, generator)
425
- apply_alter_table(name, generator.operations)
425
+ ops = generator.operations
426
+
427
+ unless can_add_primary_key_constraint_on_nullable_columns?
428
+ if add_pk = ops.find{|op| op[:op] == :add_constraint && op[:type] == :primary_key}
429
+ ops = add_pk[:columns].map{|column| {:op => :set_column_null, :name => column, :null => false}} + ops
430
+ end
431
+ end
432
+
433
+ apply_alter_table(name, ops)
426
434
  end
427
435
 
428
436
  # The class used for alter_table generators.
@@ -558,8 +566,16 @@ module Sequel
558
566
  # Add null/not null SQL fragment to column creation SQL.
559
567
  def column_definition_null_sql(sql, column)
560
568
  null = column.fetch(:null, column[:allow_null])
561
- sql << NOT_NULL if null == false
562
- sql << NULL if null == true
569
+ if null.nil? && !can_add_primary_key_constraint_on_nullable_columns? && column[:primary_key]
570
+ null = false
571
+ end
572
+
573
+ case null
574
+ when false
575
+ sql << NOT_NULL
576
+ when true
577
+ sql << NULL
578
+ end
563
579
  end
564
580
 
565
581
  # Add primary key SQL fragment to column creation SQL.
@@ -702,6 +718,17 @@ module Sequel
702
718
  end
703
719
  end
704
720
  end
721
+
722
+ unless can_add_primary_key_constraint_on_nullable_columns?
723
+ if pk = generator.constraints.find{|op| op[:type] == :primary_key}
724
+ pk[:columns].each do |column|
725
+ if matched_column = generator.columns.find{|gc| gc[:name] == column}
726
+ matched_column[:null] = false
727
+ end
728
+ end
729
+ end
730
+ end
731
+
705
732
  "#{create_table_prefix_sql(name, options)} (#{column_list_sql(generator)})"
706
733
  end
707
734
 
@@ -80,7 +80,7 @@ module Sequel
80
80
  def rollback_checker(opts=OPTS)
81
81
  synchronize(opts[:server]) do |conn|
82
82
  raise Error, "not in a transaction" unless t = _trans(conn)
83
- t[:rollback_checker] ||= proc{t[:rolled_back]}
83
+ t[:rollback_checker] ||= proc{Sequel.synchronize{t[:rolled_back]}}
84
84
  end
85
85
  end
86
86
 
@@ -382,7 +382,9 @@ module Sequel
382
382
  callbacks = transaction_hooks(conn, committed)
383
383
 
384
384
  if transaction_finished?(conn)
385
- @transactions[conn][:rolled_back] = !committed
385
+ h = @transactions[conn]
386
+ rolled_back = !committed
387
+ Sequel.synchronize{h[:rolled_back] = rolled_back}
386
388
  Sequel.synchronize{@transactions.delete(conn)}
387
389
  end
388
390
 
@@ -10,7 +10,7 @@ module Sequel
10
10
  # ---------------------
11
11
 
12
12
  # Action methods defined by Sequel that execute code on the database.
13
- ACTION_METHODS = (<<-METHS).split.map(&:to_sym)
13
+ ACTION_METHODS = (<<-METHS).split.map(&:to_sym).freeze
14
14
  << [] all avg count columns columns! delete each
15
15
  empty? fetch_rows first first! get import insert interval last
16
16
  map max min multi_insert paged_each range select_hash select_hash_groups select_map select_order_map
@@ -246,8 +246,13 @@ module Sequel
246
246
  # double embedded underscores which would be considered an implicit qualified identifier
247
247
  # if not wrapped in an SQL::Identifier.
248
248
  def qualifier_from_alias_symbol(aliaz, identifier)
249
- identifier = identifier.column if identifier.is_a?(SQL::QualifiedIdentifier)
250
249
  case identifier
250
+ when SQL::QualifiedIdentifier
251
+ if identifier.column.is_a?(String)
252
+ Sequel.identifier(aliaz)
253
+ else
254
+ aliaz
255
+ end
251
256
  when SQL::Identifier
252
257
  Sequel.identifier(aliaz)
253
258
  else
@@ -18,23 +18,23 @@ module Sequel
18
18
 
19
19
  # Which options don't affect the SQL generation. Used by simple_select_all?
20
20
  # to determine if this is a simple SELECT * FROM table.
21
- NON_SQL_OPTIONS = [:server, :defaults, :overrides, :graph, :eager, :eager_graph, :graph_aliases]
21
+ NON_SQL_OPTIONS = [:server, :graph, :eager, :eager_graph, :graph_aliases].freeze
22
22
 
23
23
  # These symbols have _join methods created (e.g. inner_join) that
24
24
  # call join_table with the symbol, passing along the arguments and
25
25
  # block from the method call.
26
- CONDITIONED_JOIN_TYPES = [:inner, :full_outer, :right_outer, :left_outer, :full, :right, :left]
26
+ CONDITIONED_JOIN_TYPES = [:inner, :full_outer, :right_outer, :left_outer, :full, :right, :left].freeze
27
27
 
28
28
  # These symbols have _join methods created (e.g. natural_join).
29
29
  # They accept a table argument and options hash which is passed to join_table,
30
30
  # and they raise an error if called with a block.
31
- UNCONDITIONED_JOIN_TYPES = [:natural, :natural_left, :natural_right, :natural_full, :cross]
31
+ UNCONDITIONED_JOIN_TYPES = [:natural, :natural_left, :natural_right, :natural_full, :cross].freeze
32
32
 
33
33
  # All methods that return modified datasets with a joined table added.
34
- JOIN_METHODS = (CONDITIONED_JOIN_TYPES + UNCONDITIONED_JOIN_TYPES).map{|x| "#{x}_join".to_sym} + [:join, :join_table]
34
+ JOIN_METHODS = ((CONDITIONED_JOIN_TYPES + UNCONDITIONED_JOIN_TYPES).map{|x| "#{x}_join".to_sym} + [:join, :join_table]).freeze
35
35
 
36
36
  # Methods that return modified datasets
37
- QUERY_METHODS = (<<-METHS).split.map(&:to_sym) + JOIN_METHODS
37
+ QUERY_METHODS = ((<<-METHS).split.map(&:to_sym) + JOIN_METHODS).freeze
38
38
  add_graph_aliases and distinct except exclude exclude_having exclude_where
39
39
  filter for_update from from_self graph grep group group_and_count group_append group_by having intersect invert
40
40
  limit lock_style naked offset or order order_append order_by order_more order_prepend qualify
@@ -221,7 +221,8 @@ module Sequel
221
221
  # # SELECT * FROM (SELECT id, name FROM items ORDER BY name) AS foo(c1, c2)
222
222
  def from_self(opts=OPTS)
223
223
  fs = {}
224
- @opts.keys.each{|k| fs[k] = nil unless NON_SQL_OPTIONS.include?(k)}
224
+ non_sql = non_sql_options
225
+ @opts.keys.each{|k| fs[k] = nil unless non_sql.include?(k)}
225
226
  clone(fs).from(opts[:alias] ? as(opts[:alias], opts[:column_aliases]) : self)
226
227
  end
227
228
 
@@ -1043,7 +1044,8 @@ module Sequel
1043
1044
  # SELECT * FROM table
1044
1045
  # SELECT table.* FROM table
1045
1046
  def simple_select_all?
1046
- o = @opts.reject{|k,v| v.nil? || NON_SQL_OPTIONS.include?(k)}
1047
+ non_sql = non_sql_options
1048
+ o = @opts.reject{|k,v| v.nil? || non_sql.include?(k)}
1047
1049
  if (f = o[:from]) && f.length == 1 && (f.first.is_a?(Symbol) || f.first.is_a?(SQL::AliasedExpression))
1048
1050
  case o.length
1049
1051
  when 1
@@ -1161,6 +1163,11 @@ module Sequel
1161
1163
  server?(:default)
1162
1164
  end
1163
1165
 
1166
+ # Dataset options that do not affect the generated SQL.
1167
+ def non_sql_options
1168
+ NON_SQL_OPTIONS
1169
+ end
1170
+
1164
1171
  # Treat the +block+ as a virtual_row block if not +nil+ and
1165
1172
  # add the resulting columns to the +columns+ array (modifies +columns+).
1166
1173
  def virtual_row_columns(columns, block)
@@ -761,8 +761,8 @@ module Sequel
761
761
  #
762
762
  # ds.split_qualifiers(:s) # ['s']
763
763
  # ds.split_qualifiers(:t__s) # ['t', 's']
764
- # ds.split_qualifiers(Sequel.qualify(:d, :t__s)) # ['d', 't', 's']
765
- # ds.split_qualifiers(Sequel.qualify(:h__d, :t__s)) # ['h', 'd', 't', 's']
764
+ # ds.split_qualifiers(Sequel[:d][:t__s]) # ['d', 't', 's']
765
+ # ds.split_qualifiers(Sequel[:h__d][:t__s]) # ['h', 'd', 't', 's']
766
766
  def split_qualifiers(table_name, *args)
767
767
  case table_name
768
768
  when SQL::QualifiedIdentifier
@@ -12,6 +12,8 @@ def Sequel.core_extensions?
12
12
  true
13
13
  end
14
14
 
15
+ Sequel.extension :symbol_as
16
+
15
17
  # Sequel extends +Array+ to add methods to implement the SQL DSL.
16
18
  # Most of these methods require that the array not be empty and that it
17
19
  # must consist solely of other arrays that have exactly two elements.
@@ -195,7 +197,6 @@ end
195
197
 
196
198
  # Sequel extends +Symbol+ to add methods to implement the SQL DSL.
197
199
  class Symbol
198
- include Sequel::SQL::AliasMethods
199
200
  include Sequel::SQL::CastMethods
200
201
  include Sequel::SQL::OrderMethods
201
202
  include Sequel::SQL::BooleanMethods
@@ -432,7 +432,7 @@ module Sequel
432
432
 
433
433
  # Get basic oid information for the composite type.
434
434
  ds = from(:pg_type).
435
- select(:pg_type__oid, :typrelid, :typarray).
435
+ select{[pg_type[:oid], :typrelid, :typarray]}.
436
436
  where([[:typtype, 'c'], [:typname, type_name.to_s]])
437
437
  if type_schema
438
438
  ds = ds.join(:pg_namespace, [[:oid, :typnamespace], [:nspname, type_schema.to_s]])
@@ -454,7 +454,7 @@ module Sequel
454
454
  where{attnum > 0}.
455
455
  exclude(:attisdropped).
456
456
  order(:attnum).
457
- select_map([:attname, Sequel.case({0=>:atttypid}, :pg_type__typbasetype, :pg_type__typbasetype).as(:atttypid)])
457
+ select_map{[:attname, Sequel.case({0=>:atttypid}, pg_type[:typbasetype], pg_type[:typbasetype]).as(:atttypid)]}
458
458
  if res.empty?
459
459
  raise Error, "no columns for row type #{db_type.inspect} in database"
460
460
  end
@@ -0,0 +1,57 @@
1
+ # frozen-string-literal: true
2
+ #
3
+ # The s extension adds Sequel::S, a module containing a private #S
4
+ # method that calls Sequel.expr. It's designed as a shortcut so
5
+ # that instead of:
6
+ #
7
+ # Sequel.expr(:column) + 1
8
+ # # or
9
+ # Sequel.expr{column + 1}
10
+ #
11
+ # you can just write:
12
+ #
13
+ # S(:column) + 1
14
+ # # or
15
+ # S{column + 1}
16
+ #
17
+ # To load the extension:
18
+ #
19
+ # Sequel.extension :s
20
+ #
21
+ # Then you can include the Sequel::S module into whatever classes or
22
+ # objects you care about:
23
+ #
24
+ # Sequel::Model.send(:include, Sequel::S) # available in model instance methods
25
+ # Sequel::Model.extend(Sequel::S) # available in model class methods
26
+ # Sequel::Dataset.send(:include, Sequel::S) # available in dataset methods
27
+ #
28
+ # or just into Object if you want it available everywhere:
29
+ #
30
+ # Object.send(:include, Sequel::SQL)
31
+ #
32
+ # If you are using Ruby 2+, and you would like to use refinements, you
33
+ # can use Sequel::S as a refinement, in which case the private #S method
34
+ # will be available on all objects while the refinement is active.
35
+ #
36
+ # using Sequel::S
37
+ #
38
+ # S(:column) + 1
39
+ #
40
+ # Related module: Sequel::S
41
+
42
+
43
+ #
44
+ module Sequel::S
45
+ private
46
+
47
+ # Delegate to Sequel.expr
48
+ def S(*a, &block)
49
+ Sequel.expr(*a, &block)
50
+ end
51
+
52
+ if RUBY_VERSION >= '2.0.0'
53
+ refine Object do
54
+ include Sequel::S
55
+ end
56
+ end
57
+ end
@@ -21,7 +21,6 @@
21
21
  #
22
22
  module Sequel
23
23
  module SetOverrides
24
- Dataset::NON_SQL_OPTIONS.concat([:defaults, :overrides])
25
24
  Dataset.def_mutation_method(:set_defaults, :set_overrides, :module=>self)
26
25
 
27
26
  # Set overrides/defaults for insert hashes
@@ -70,6 +69,11 @@ module Sequel
70
69
  vals = vals.merge(@opts[:overrides]) if @opts[:overrides]
71
70
  vals
72
71
  end
72
+
73
+ # Dataset options that do not affect the generated SQL.
74
+ def non_sql_options
75
+ super + [:defaults, :overrides]
76
+ end
73
77
  end
74
78
 
75
79
  Dataset.register_extension(:set_overrides, SetOverrides)
@@ -14,6 +14,7 @@
14
14
  #
15
15
  # Sequel.extension :sql_expr
16
16
 
17
+ #
17
18
  class Object
18
19
  # Return the object wrapper in an appropriate Sequel expression object.
19
20
  def sql_expr
@@ -0,0 +1,71 @@
1
+ # frozen-string-literal: true
2
+ #
3
+ # The symbol_aref extension makes Symbol#[] support Symbol,
4
+ # Sequel::SQL::Indentifier, and Sequel::SQL::QualifiedIdentifier instances,
5
+ # returning appropriate Sequel::SQL::QualifiedIdentifier instances. It's
6
+ # designed as a shortcut so that instead of:
7
+ #
8
+ # Sequel[:table][:column] # table.column
9
+ #
10
+ # you can just write:
11
+ #
12
+ # :table[:column] # table.column
13
+ #
14
+ # To load the extension:
15
+ #
16
+ # Sequel.extension :symbol_aref
17
+ #
18
+ # If you are using Ruby 2+, and you would like to use refinements, there
19
+ # is a refinement version of this in the symbol_aref_refinement extension.
20
+ #
21
+ # If you are using the ruby18_symbol_extensions, and would like symbol_aref
22
+ # to take affect, load the symbol_aref extension after the
23
+ # ruby18_symbol_extensions.
24
+ #
25
+ # Related module: Sequel::SymbolAref
26
+
27
+ if RUBY_VERSION >= '2.0'
28
+ module Sequel::SymbolAref
29
+ def [](v)
30
+ case v
31
+ when Symbol, Sequel::SQL::Identifier, Sequel::SQL::QualifiedIdentifier
32
+ Sequel::SQL::QualifiedIdentifier.new(self, v)
33
+ else
34
+ super
35
+ end
36
+ end
37
+ end
38
+
39
+ class Symbol
40
+ prepend Sequel::SymbolAref
41
+ end
42
+ else
43
+ class Symbol
44
+ if method_defined?(:[])
45
+ alias_method :aref_before_sequel, :[]
46
+ end
47
+
48
+ if RUBY_VERSION >= '1.9'
49
+ #
50
+ def [](v)
51
+ case v
52
+ when Symbol, Sequel::SQL::Identifier, Sequel::SQL::QualifiedIdentifier
53
+ Sequel::SQL::QualifiedIdentifier.new(self, v)
54
+ else
55
+ aref_before_sequel(v)
56
+ end
57
+ end
58
+ else
59
+ def [](*v)
60
+ arg = v.first if v.length == 1
61
+
62
+ case arg
63
+ when Symbol, Sequel::SQL::Identifier, Sequel::SQL::QualifiedIdentifier
64
+ Sequel::SQL::QualifiedIdentifier.new(self, arg)
65
+ else
66
+ respond_to?(:aref_before_sequel) ? aref_before_sequel(*v) : super(*v)
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,41 @@
1
+ # frozen-string-literal: true
2
+ #
3
+ # The symbol_aref_refinement extension adds a refinement that makes
4
+ # Symbol#[] support Symbol, #Sequel::SQL::Indentifier, and
5
+ # Sequel::SQL::QualifiedIdentifier instances, returning appropriate
6
+ # Sequel::SQL::QualifiedIdentifier instances. It's designed as a
7
+ # shortcut so that instead of:
8
+ #
9
+ # Sequel[:table][:column] # table.column
10
+ #
11
+ # you can just write:
12
+ #
13
+ # :table[:column] # table.column
14
+ #
15
+ # To load the extension:
16
+ #
17
+ # Sequel.extension :symbol_aref_refinement
18
+ #
19
+ # To enable the refinement for the current file:
20
+ #
21
+ # using Sequel::SymbolAref
22
+ #
23
+ # If you would like this extension to be enabled globally instead
24
+ # of as a refinement, use the symbol_aref extension.
25
+ #
26
+ # Related module: Sequel::SymbolAref
27
+
28
+ raise(Sequel::Error, "Refinements require ruby 2.0.0 or greater") unless RUBY_VERSION >= '2.0.0'
29
+
30
+ module Sequel::SymbolAref
31
+ refine Symbol do
32
+ def [](v)
33
+ case v
34
+ when Symbol, Sequel::SQL::Identifier, Sequel::SQL::QualifiedIdentifier
35
+ Sequel::SQL::QualifiedIdentifier.new(self, v)
36
+ else
37
+ super
38
+ end
39
+ end
40
+ end
41
+ end