Sha256: f84645c55e45e3af567c14ef8bf3490998bab3a784fb78aeabb5066dbe43eeb3
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true module DuckDB class Column # # returns column type symbol # `:unknown` means that the column type is unknown/unsupported by ruby-duckdb. # `:invalid` means that the column type is invalid in duckdb. # # require 'duckdb' # db = DuckDB::Database.open # con = db.connect # con.query('CREATE TABLE users (id INTEGER, name VARCHAR(30))') # # users = con.query('SELECT * FROM users') # columns = users.columns # columns.first.type #=> :integer # def type types = %i[ invalid boolean tinyint smallint integer bigint utinyint usmallint uinteger ubigint float double timestamp date time interval hugeint varchar blob decimal timestamp_s timestamp_ms timestamp_ns enum list struct map uuid json ] if Gem::Version.new(DuckDB::LIBRARY_VERSION) >= Gem::Version.new('0.10.0') types[17, 0] = :uhugeint end index = _type return :unknown if index >= types.size types[index] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
duckdb-0.10.0.0 | lib/duckdb/column.rb |