module Ensql::Adapter
@abstract Do not use this module directly.
A common interface for executing SQL
statements and retrieving (or not) their results. Some methods have predefined implementations for convenience that can be improved in the adapters.
Public Instance Methods
fetch_first_column(sql)
click to toggle source
Execute the query and return only the first column of the result. @return <Array>
# File lib/ensql/adapter.rb, line 116 def fetch_first_column(sql) fetch_rows(sql).map(&:values).map(&:first) end
fetch_first_field(sql)
click to toggle source
Execute the query and return only the first field of the first row of the result.
# File lib/ensql/adapter.rb, line 121 def fetch_first_field(sql) fetch_first_row(sql)&.values&.first end
fetch_first_row(sql)
click to toggle source
Execute the query and return only the first row of the result. @return <Hash>
# File lib/ensql/adapter.rb, line 110 def fetch_first_row(sql) fetch_each_row(sql).first end