Class: SqlGenius::Core::ExecutionResult

Inherits:
Object
  • Object
show all
Defined in:
lib/sql_genius/core/execution_result.rb

Overview

Immutable frozen value object returned from Core::QueryRunner#run. Contains the executed columns and (possibly masked) rows plus runtime metrics: row count, wall-clock execution time in milliseconds, and a truncated flag indicating whether the row count reached the applied LIMIT.

This is distinct from Core::Result (which models a plain query result shape) because QueryRunner returns runtime metadata that plain results don’t carry.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(columns:, rows:, execution_time_ms:, truncated:) ⇒ ExecutionResult

Returns a new instance of ExecutionResult.



17
18
19
20
21
22
23
24
# File 'lib/sql_genius/core/execution_result.rb', line 17

def initialize(columns:, rows:, execution_time_ms:, truncated:)
  @columns = columns.freeze
  @rows = rows.freeze
  @row_count = rows.length
  @execution_time_ms = execution_time_ms
  @truncated = truncated
  freeze
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



15
16
17
# File 'lib/sql_genius/core/execution_result.rb', line 15

def columns
  @columns
end

#execution_time_msObject (readonly)

Returns the value of attribute execution_time_ms.



15
16
17
# File 'lib/sql_genius/core/execution_result.rb', line 15

def execution_time_ms
  @execution_time_ms
end

#row_countObject (readonly)

Returns the value of attribute row_count.



15
16
17
# File 'lib/sql_genius/core/execution_result.rb', line 15

def row_count
  @row_count
end

#rowsObject (readonly)

Returns the value of attribute rows.



15
16
17
# File 'lib/sql_genius/core/execution_result.rb', line 15

def rows
  @rows
end

#truncatedObject (readonly)

Returns the value of attribute truncated.



15
16
17
# File 'lib/sql_genius/core/execution_result.rb', line 15

def truncated
  @truncated
end