Sha256: 1902a87ed6a112df39375c2bd2875bf25c35eb32e6c19d527a73c74cd8c24ad4
Contents?: true
Size: 1.1 KB
Versions: 23
Compression:
Stored size: 1.1 KB
Contents
module Blazer module Adapters class SalesforceAdapter < BaseAdapter def run_statement(statement, comment) columns = [] rows = [] error = nil # remove comments manually statement = statement.gsub(/--.+/, "") # only supports single line /* */ comments # regex not perfect, but should be good enough statement = statement.gsub(/\/\*.+\*\//, "") # remove trailing semicolon statement = statement.sub(/;\s*\z/, "") begin response = client.query(statement) rows = response.map { |r| r.to_hash.except("attributes").values } columns = rows.any? ? response.first.to_hash.except("attributes").keys : [] rescue => e error = e.message end [columns, rows, error] end def tables # cache @tables ||= client.describe.select { |r| r.queryable }.map(&:name) end def preview_statement "SELECT Id FROM {table} LIMIT 10" end protected def client @client ||= Restforce.new end end end end
Version data entries
23 entries across 23 versions & 1 rubygems