Class: Sequel::Postgres::JSONBOp
- Inherits:
-
JSONBaseOp
- Object
- SQL::Expression
- SQL::GenericExpression
- SQL::Wrapper
- JSONBaseOp
- Sequel::Postgres::JSONBOp
- Defined in:
- lib/sequel/extensions/pg_json_ops.rb
Overview
Constant Summary collapse
- CONTAIN_ALL =
["(".freeze, " ?& ".freeze, ")".freeze].freeze
- CONTAIN_ANY =
["(".freeze, " ?| ".freeze, ")".freeze].freeze
- CONTAINS =
["(".freeze, " @> ".freeze, ")".freeze].freeze
- CONTAINED_BY =
["(".freeze, " <@ ".freeze, ")".freeze].freeze
- HAS_KEY =
["(".freeze, " ? ".freeze, ")".freeze].freeze
Constants inherited from JSONBaseOp
Sequel::Postgres::JSONBaseOp::GET, Sequel::Postgres::JSONBaseOp::GET_PATH, Sequel::Postgres::JSONBaseOp::GET_PATH_TEXT, Sequel::Postgres::JSONBaseOp::GET_TEXT
Instance Attribute Summary
Attributes inherited from SQL::Wrapper
Instance Method Summary collapse
-
#contain_all(other) ⇒ Object
Check if the receiver contains all of the keys in the given array:.
-
#contain_any(other) ⇒ Object
Check if the receiver contains any of the keys in the given array:.
-
#contained_by(other) ⇒ Object
Check if the other jsonb contains all entries in the receiver:.
-
#contains(other) ⇒ Object
Check if the receiver contains all entries in the other jsonb:.
-
#has_key?(key) ⇒ Boolean
(also: #include?)
Check if the receiver contains the given key:.
-
#pg_jsonb ⇒ Object
Return the receiver, since it is already a JSONBOp.
Methods inherited from JSONBaseOp
#[], #array_elements, #array_elements_text, #array_length, #each, #each_text, #extract, #extract_text, #get_text, #keys, #populate, #populate_set, #to_record, #to_recordset, #typeof
Methods inherited from SQL::Wrapper
Methods included from HStoreOpMethods
Methods included from RangeOpMethods
Methods included from ArrayOpMethods
Methods included from JSONOpMethods
Methods included from InetOpMethods
Methods included from PGRowOp::ExpressionMethods
Methods included from SQL::SubscriptMethods
Methods included from SQL::StringMethods
Methods included from SQL::PatternMatchMethods
Methods included from SQL::OrderMethods
Methods included from SQL::NumericMethods
Methods included from SQL::ComplexExpressionMethods
#extract, #sql_boolean, #sql_number, #sql_string
Methods included from SQL::CastMethods
#cast, #cast_numeric, #cast_string
Methods included from SQL::BooleanMethods
Methods included from SQL::AliasMethods
Methods inherited from SQL::Expression
#==, attr_reader, #eql?, #hash, inherited, #inspect, #lit, #sql_literal
Constructor Details
This class inherits a constructor from Sequel::SQL::Wrapper
Instance Method Details
#contain_all(other) ⇒ Object
Check if the receiver contains all of the keys in the given array:
jsonb_op.contain_all(:a) # (jsonb ?& a)
278 279 280 |
# File 'lib/sequel/extensions/pg_json_ops.rb', line 278 def contain_all(other) bool_op(CONTAIN_ALL, wrap_input_array(other)) end |
#contain_any(other) ⇒ Object
Check if the receiver contains any of the keys in the given array:
jsonb_op.contain_any(:a) # (jsonb ?| a)
285 286 287 |
# File 'lib/sequel/extensions/pg_json_ops.rb', line 285 def contain_any(other) bool_op(CONTAIN_ANY, wrap_input_array(other)) end |
#contained_by(other) ⇒ Object
Check if the other jsonb contains all entries in the receiver:
jsonb_op.contained_by(:h) # (jsonb <@ h)
299 300 301 |
# File 'lib/sequel/extensions/pg_json_ops.rb', line 299 def contained_by(other) bool_op(CONTAINED_BY, wrap_input_jsonb(other)) end |
#contains(other) ⇒ Object
Check if the receiver contains all entries in the other jsonb:
jsonb_op.contains(:h) # (jsonb @> h)
292 293 294 |
# File 'lib/sequel/extensions/pg_json_ops.rb', line 292 def contains(other) bool_op(CONTAINS, wrap_input_jsonb(other)) end |
#has_key?(key) ⇒ Boolean Also known as: include?
Check if the receiver contains the given key:
jsonb_op.has_key?('a') # (jsonb ? 'a')
306 307 308 |
# File 'lib/sequel/extensions/pg_json_ops.rb', line 306 def has_key?(key) bool_op(HAS_KEY, key) end |
#pg_jsonb ⇒ Object
Return the receiver, since it is already a JSONBOp.
312 313 314 |
# File 'lib/sequel/extensions/pg_json_ops.rb', line 312 def pg_jsonb self end |