Class | Sequel::Postgres::PGRowOp |
In: |
lib/sequel/extensions/pg_row_ops.rb
|
Parent: | SQL::PlaceholderLiteralString |
OPEN | = | '('.freeze |
CLOSE_DOT | = | ').'.freeze |
CLOSE_STAR | = | '.*)'.freeze |
CLOSE_STAR_CAST | = | '.*)::'.freeze |
EMPTY | = | "".freeze |
ROW | = | [OPEN, CLOSE_STAR].freeze |
ROW_CAST | = | [OPEN, CLOSE_STAR_CAST].freeze |
QUALIFY | = | [OPEN, CLOSE_DOT].freeze |
WRAP | = | [EMPTY].freeze |
Access a member of the composite type if given a symbol or an SQL::Identifier. For all other access, assuming the pg_array_ops extension is loaded and that it represents an array access. In either case, return a PgRowOp so that access can be cascaded.
# File lib/sequel/extensions/pg_row_ops.rb, line 106 106: def [](member) 107: case member 108: when Symbol, SQL::Identifier 109: PGRowOp.new(QUALIFY, [self, member]) 110: else 111: PGRowOp.wrap(Sequel.pg_array_op(self)[member]) 112: end 113: end
Use the (identifier.*) syntax to indicate that this expression represents the composite type of one of the tables being referenced, if it has the same name as one of the columns. If the cast_to argument is given, also cast the expression to that type (which should be a symbol representing the composite type). This is used if you want to return whole table row as a composite type.
# File lib/sequel/extensions/pg_row_ops.rb, line 123 123: def splat(cast_to=nil) 124: if args.length > 1 125: raise Error, 'cannot splat a PGRowOp with multiple arguments' 126: end 127: 128: if cast_to 129: PGRowOp.new(ROW_CAST, args + [cast_to]) 130: else 131: PGRowOp.new(ROW, args) 132: end 133: end