Class: Tarantool::Client::PreparedStatement

Inherits:
Object
  • Object
show all
Defined in:
tarantool-client/lib/tarantool/client/prepared_statement.rb

Overview

Server-side prepared SQL statement. Runs through the client or stream that prepared it.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, perform) ⇒ PreparedStatement

Returns a new instance of PreparedStatement.



9
10
11
12
# File 'tarantool-client/lib/tarantool/client/prepared_statement.rb', line 9

def initialize(id, perform)
  @id = id
  @perform = perform
end

Instance Attribute Details

#id ⇒ Object (readonly)

Returns the value of attribute id.



7
8
9
# File 'tarantool-client/lib/tarantool/client/prepared_statement.rb', line 7

def id
  @id
end

Instance Method Details

#close(timeout: nil) ⇒ Object



18
19
20
21
22
# File 'tarantool-client/lib/tarantool/client/prepared_statement.rb', line 18

def close(timeout: nil)
  @perform.call(Protocol::Requests::Prepare.new(statement: id), timeout:)

  nil
end

#execute(bindings = [], timeout: nil) ⇒ Object



14
15
16
# File 'tarantool-client/lib/tarantool/client/prepared_statement.rb', line 14

def execute(bindings = [], timeout: nil)
  SqlResult.from_response(@perform.call(Protocol::Requests::Execute.new(statement: id, bindings:), timeout:))
end