Represents JSONB subscripts. This is abstracted because the subscript support depends on the database version.
Constants
SUBSCRIPT | = | ["".freeze, "[".freeze, "]".freeze].freeze |
Attributes
expression | [R] |
The expression being subscripted |
sub | [R] |
The subscript to use |
Public Class methods
new(expression, sub)
Set the expression and subscript to the given arguments
[show source]
# File lib/sequel/extensions/pg_json_ops.rb 864 def initialize(expression, sub) 865 @expression = expression 866 @sub = sub 867 freeze 868 end
Public Instance methods
sequel_ast_transform(transformer)
Support transforming of jsonb subscripts
[show source]
# File lib/sequel/extensions/pg_json_ops.rb 878 def sequel_ast_transform(transformer) 879 self.class.new(transformer.call(@expression), transformer.call(@sub)) 880 end
to_s_append(ds, sql)
Use subscripts instead of -> operator on PostgreSQL 14+
[show source]
# File lib/sequel/extensions/pg_json_ops.rb 871 def to_s_append(ds, sql) 872 server_version = ds.db.server_version 873 frag = server_version && server_version >= 140000 ? SUBSCRIPT : JSONOp::GET 874 ds.literal_append(sql, Sequel::SQL::PlaceholderLiteralString.new(frag, [@expression, @sub])) 875 end