Class: ClickHouse::SQL::BindIndexManager

Inherits:
Object
  • Object
show all
Defined in:
lib/clickhouse/sql/bind_index_manager.rb

Overview

Emits sequential $1-style bind markers when rendering redacted SQL, so every typed placeholder in a query gets a stable positional marker suitable for external log aggregation.

Derived from GitLab's MIT-licensed click_house-client gem; see LICENSE.

Instance Method Summary collapse

Constructor Details

#initialize(start_index = 1) ⇒ BindIndexManager

Returns a new instance of BindIndexManager.

Parameters:

  • start_index (Integer) (defaults to: 1)

    Index of the first bind marker.



12
13
14
# File 'lib/clickhouse/sql/bind_index_manager.rb', line 12

def initialize(start_index = 1)
  @current_index = start_index
end

Instance Method Details

#next_bind_strString

Returns the next positional bind marker.

Returns:

  • (String)

    Bind marker such as $1.



19
20
21
22
23
# File 'lib/clickhouse/sql/bind_index_manager.rb', line 19

def next_bind_str
  bind_str = "$#{@current_index}"
  @current_index += 1
  bind_str
end