class Sequel::Postgres::HStoreSubscriptOp

  1. lib/sequel/extensions/pg_hstore_ops.rb
Superclass: Expression

Represents hstore subscripts. This is abstracted because the subscript support depends on the database version.

Methods

Public Class

  1. new

Public Instance

  1. expression
  2. sequel_ast_transform
  3. sub
  4. to_s_append

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_hstore_ops.rb
337 def initialize(expression, sub)
338   @expression = expression
339   @sub = sub
340   freeze
341 end

Public Instance methods

sequel_ast_transform(transformer)

Support transforming of hstore subscripts

[show source]
    # File lib/sequel/extensions/pg_hstore_ops.rb
351 def sequel_ast_transform(transformer)
352   self.class.new(transformer.call(@expression), transformer.call(@sub))
353 end
to_s_append(ds, sql)

Use subscripts instead of -> operator on PostgreSQL 14+

[show source]
    # File lib/sequel/extensions/pg_hstore_ops.rb
344 def to_s_append(ds, sql)
345   server_version = ds.db.server_version
346   frag = server_version && server_version >= 140000 ? SUBSCRIPT : HStoreOp::LOOKUP
347   ds.literal_append(sql, Sequel::SQL::PlaceholderLiteralString.new(frag, [@expression, @sub]))
348 end