Class: DuckDB::ColumnDescription

Inherits:
Data
  • Object
show all
Defined in:
lib/duckdb/column_description.rb

Overview

DuckDB::ColumnDescription is an immutable value object describing a single column returned by DuckDB::TableDescription#column_descriptions.

It is defined using Data.define and exposes three attributes:

  • name — the column name as a String

  • logical_type — a DuckDB::LogicalType representing the column’s type

  • has_defaulttrue if the column has a DEFAULT value, false otherwise

A predicate alias has_default? is provided for idiomatic Ruby usage.

Requires DuckDB >= 1.5.0.

require 'duckdb'
db = DuckDB::Database.open
con = db.connect
con.query("CREATE TABLE t (id INTEGER, name VARCHAR DEFAULT 'anon')")

td = DuckDB::TableDescription.new(con, 't')
cd = td.column_descriptions.last
cd.name               #=> "name"
cd.logical_type.type  #=> :varchar
cd.has_default?       #=> true

Instance Attribute Summary collapse

Instance Attribute Details

#has_defaultObject (readonly) Also known as: has_default?

Returns the value of attribute has_default

Returns:

  • (Object)

    the current value of has_default



28
29
30
# File 'lib/duckdb/column_description.rb', line 28

def has_default
  @has_default
end

#logical_typeObject (readonly)

Returns the value of attribute logical_type

Returns:

  • (Object)

    the current value of logical_type



28
29
30
# File 'lib/duckdb/column_description.rb', line 28

def logical_type
  @logical_type
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



28
29
30
# File 'lib/duckdb/column_description.rb', line 28

def name
  @name
end