class Cql::Column(T)
- Cql::Column(T)
- Cql::BaseColumn
- Reference
- Object
Overview
A column in a table This class represents a column in a table It provides methods for setting the column type, default value, and constraints It also provides methods for building expressions
Example Creating a new column
schema.build do
table :users do
column :name, String, null: false, default: "John"
column :age, Int32, null: false
end
Direct Known Subclasses
Defined in:
column.crConstructors
Instance Method Summary
- #default : DB::Any
-
#expression
Expressions for this column - @return [Expression::ColumnBuilder] the column expression builder
- #index=(index : Index | Nil)
- #index? : Index | Nil
- #length : Int32 | Nil
- #length=(length : Int32 | Nil)
- #name : Symbol
- #name=(name : Symbol)
- #null? : Bool
- #table : Table | Nil
- #table=(table : Table | Nil)
- #type : Any
- #type=(type : Any)
- #unique? : Bool
-
#validate!(value)
Validate the value - @param value [DB::Any] The value to validate
Constructor Detail
def self.new(name : Symbol, type : T.class, as_name : String | Nil = nil, null : Bool = false, default : DB::Any = nil, unique : Bool = false, size : Int32 | Nil = nil, index : Index | Nil = nil)
#
Instance Method Detail
def expression
#
Expressions for this column
- @return [Expression::ColumnBuilder] the column expression builder
Example
column = Cql::Column.new(:name, String)
column.expression.eq("John")
def validate!(value)
#
Validate the value
- @param value [DB::Any] The value to validate
Example
column = Cql::Column.new(:name, String)
column.validate!("John")