Class: Sequel::Sqljs::Wrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/bormashino_sequel_sqljs_adapter/sqljs.rb

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Constructor Details

#initialize(jsobject) ⇒ Wrapper

Returns a new instance of Wrapper.



10
11
12
# File 'lib/bormashino_sequel_sqljs_adapter/sqljs.rb', line 10

def initialize(jsobject)
  @db = jsobject
end

Instance Method Details

#exec(sql) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bormashino_sequel_sqljs_adapter/sqljs.rb', line 14

def exec(sql)
  columns = @db.call(:prepareGetColumnNames, sql).to_rb
  ret = @db.call(:exec, sql).to_rb

  if ret.is_a?(Hash) && ret['type'] == 'exception'
    err = Error.new(ret['message']).tap do |e|
      e.set_backtrace(ret['stack'])
    end

    raise err
  end

  { result: ret, columns: }
end

#get_rows_modifiedObject



29
30
31
# File 'lib/bormashino_sequel_sqljs_adapter/sqljs.rb', line 29

def get_rows_modified
  @db.call(:getRowsModified).to_rb
end