lib/duckdb/result.rb in duckdb-1.1.0.1 vs lib/duckdb/result.rb in duckdb-1.1.1.0
- old
+ new
@@ -32,33 +32,33 @@
class << self
def new
raise DuckDB::Error, 'DuckDB::Result cannot be instantiated directly.'
end
- def use_chunk_each=(value)
+ def use_chunk_each=(value) # :nodoc:
raise('`changing DuckDB::Result.use_chunk_each to false` was deprecated.') unless value
warn('`DuckDB::Result.use_chunk_each=` will be deprecated.')
true
end
- def use_chunk_each?
+ def use_chunk_each? # :nodoc:
warn('`DuckDB::Result.use_chunk_each?` will be deprecated.')
true
end
end
- def each
+ def each(&)
if streaming?
return _chunk_stream unless block_given?
- _chunk_stream { |row| yield row }
+ _chunk_stream(&)
else
return chunk_each unless block_given?
- chunk_each { |row| yield row }
+ chunk_each(&)
end
end
# returns return type. The return value is one of the following symbols:
# :invalid, :changed_rows, :nothing, :query_result
@@ -89,9 +89,17 @@
def statement_type
i = _statement_type
Converter::IntToSym.statement_type_to_sym(i)
end
+ # returns all available ENUM type values of the specified column index.
+ # require 'duckdb'
+ # db = DuckDB::Database.open('duckdb_database')
+ # con = db.connect
+ # con.execute("CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy', 'πΎπΎΦ
Ι π')")
+ # con.execute("CREATE TABLE enums (id INTEGER, mood mood)")
+ # result = con.query('SELECT * FROM enums')
+ # result.enum_dictionary_values(1) # => ['sad', 'ok', 'happy', 'πΎπΎΦ
Ι π']
def enum_dictionary_values(col_index)
values = []
_enum_dictionary_size(col_index).times do |i|
values << _enum_dictionary_value(col_index, i)
end