module Prostore::TUI::ColumnTypes

Overview

Pure column-type detection and value interpretation.

All functions take primitives (portable type tag, SQL type_text, raw string values) so callers needn't pass widget state. Use this anywhere the UI needs to ask "is this a bool / time / how do I render its value?"

Defined in:

prostore/tui/column_types.cr

Class Method Summary

Class Method Detail

def self.bool?(portable_type : String | Nil, type_text : String) : Bool #

True if the column stores booleans. Prefers the prostore portable type tag; otherwise inspects the SQL type text.


[View source]
def self.bool_display(val : String) : String #

Canonical human-readable bool form.


[View source]
def self.bool_truthy?(val : String | Nil) : Bool #

Interpret common truthy representations. Used to normalise across SQLite (0/1), Postgres (true/false), and user input ("yes"/"on"/…).


[View source]
def self.decimal?(portable_type : String | Nil, type_text : String) : Bool #

True if the column stores a fixed-precision decimal.


[View source]
def self.enum?(portable_type : String | Nil) : Bool #

True if the column stores a native Crystal enum (either backed by member name as TEXT — enum_string — or by underlying int — enum_int). See ADR-0016. Pure portable-type check; no SQL type_text fallback since enums are a prostore-only concept and never appear in unmanaged databases.


[View source]
def self.enum_int?(portable_type : String | Nil) : Bool #

[View source]
def self.enum_string?(portable_type : String | Nil) : Bool #

[View source]
def self.float?(portable_type : String | Nil, type_text : String) : Bool #

True if the column stores a binary floating-point number (Float32/Float64).


[View source]
def self.int?(portable_type : String | Nil, type_text : String) : Bool #

True if the column stores an integer. Prefers the portable type tag; otherwise inspects the SQL type text for the common integer families.


[View source]
def self.numeric?(portable_type : String | Nil, type_text : String) : Bool #

True if the column stores any numeric value — int, float, or decimal.


[View source]
def self.searchable_text?(portable_type : String | Nil, type_text : String) : Bool #

True if the column stores free-form text suitable for LIKE search. Prefers the prostore portable type tag ("string"); otherwise falls back to inspecting the SQL type text for the common text families. Intentionally narrow — UUID / JSON / etc. are excluded for now.


[View source]
def self.time?(portable_type : String | Nil, type_text : String) : Bool #

True if the column stores a date / time / timestamp.


[View source]