Class: Sequel::Postgres::JSONExistsOp
- Inherits:
-
SQL::Expression
- Object
- SQL::Expression
- Sequel::Postgres::JSONExistsOp
- Defined in:
- lib/sequel/extensions/pg_json_ops.rb
Overview
Object representing json_exists calls
Direct Known Subclasses
Instance Attribute Summary collapse
-
#expr ⇒ Object
readonly
Expression (context_item in PostgreSQL terms), usually JSONBaseOp instance.
-
#on_error ⇒ Object
readonly
How to handle errors when evaluating the JSON path expression.
-
#passing ⇒ Object
readonly
Variables to set in the JSON path expression.
-
#path ⇒ Object
readonly
JSON path expression to apply against the expression.
Instance Method Summary collapse
-
#initialize(expr, path, opts = OPTS) ⇒ JSONExistsOp
constructor
See JSONBaseOp#exists for documentation on the options.
-
#sequel_ast_transform(transformer) ⇒ Object
Support transforming of function call expression.
-
#to_s_append(ds, sql) ⇒ Object
Append the SQL function call expression to the SQL.
Methods inherited from SQL::Expression
#==, attr_reader, #clone, #eql?, #hash, inherited, #inspect
Constructor Details
#initialize(expr, path, opts = OPTS) ⇒ JSONExistsOp
See JSONBaseOp#exists for documentation on the options.
906 907 908 909 910 911 912 |
# File 'lib/sequel/extensions/pg_json_ops.rb', line 906 def initialize(expr, path, opts=OPTS) @expr = expr @path = path @passing = opts[:passing] @on_error = opts[:on_error] freeze end |
Instance Attribute Details
#expr ⇒ Object (readonly)
Expression (context_item in PostgreSQL terms), usually JSONBaseOp instance
894 895 896 |
# File 'lib/sequel/extensions/pg_json_ops.rb', line 894 def expr @expr end |
#on_error ⇒ Object (readonly)
How to handle errors when evaluating the JSON path expression
903 904 905 |
# File 'lib/sequel/extensions/pg_json_ops.rb', line 903 def on_error @on_error end |
#passing ⇒ Object (readonly)
Variables to set in the JSON path expression
900 901 902 |
# File 'lib/sequel/extensions/pg_json_ops.rb', line 900 def passing @passing end |
#path ⇒ Object (readonly)
JSON path expression to apply against the expression
897 898 899 |
# File 'lib/sequel/extensions/pg_json_ops.rb', line 897 def path @path end |
Instance Method Details
#sequel_ast_transform(transformer) ⇒ Object
Support transforming of function call expression
923 924 925 926 927 |
# File 'lib/sequel/extensions/pg_json_ops.rb', line 923 def sequel_ast_transform(transformer) opts = {} transform_opts(transformer, opts) self.class.new(transformer.call(@expr), @path, opts) end |
#to_s_append(ds, sql) ⇒ Object
Append the SQL function call expression to the SQL
915 916 917 918 919 920 |
# File 'lib/sequel/extensions/pg_json_ops.rb', line 915 def to_s_append(ds, sql) to_s_append_function_name(ds, sql) to_s_append_args_passing(ds, sql) to_s_append_on_error(ds, sql) sql << ')' end |