Class: ClickhouseRuby::ActiveRecord::RelationExtensions::PrewhereChain
- Inherits:
-
Object
- Object
- ClickhouseRuby::ActiveRecord::RelationExtensions::PrewhereChain
- Defined in:
- lib/clickhouse_ruby/active_record/relation_extensions.rb
Overview
Chain object for prewhere.not syntax
Allows negation of prewhere conditions:
Model.prewhere.not(deleted: true)
# PREWHERE NOT(deleted = 1)
Instance Method Summary collapse
-
#initialize(relation) ⇒ PrewhereChain
constructor
A new instance of PrewhereChain.
-
#not(opts, *rest) ⇒ ActiveRecord::Relation
Negate the prewhere conditions.
Constructor Details
#initialize(relation) ⇒ PrewhereChain
Returns a new instance of PrewhereChain.
359 360 361 |
# File 'lib/clickhouse_ruby/active_record/relation_extensions.rb', line 359 def initialize(relation) @relation = relation end |
Instance Method Details
#not(opts, *rest) ⇒ ActiveRecord::Relation
Negate the prewhere conditions
368 369 370 371 372 373 374 375 376 377 378 379 380 |
# File 'lib/clickhouse_ruby/active_record/relation_extensions.rb', line 368 def not(opts, *rest) condition_to_negate = case opts when Hash build_combined_condition(opts) when String Arel.sql(@relation.sanitize_sql_array([opts, *rest])) else opts end negated = Arel::Nodes::Not.new(condition_to_negate) @relation.prewhere!(negated) end |