sqlode/model
Types
pub type AnalyzedQuery {
AnalyzedQuery(
base: ParsedQuery,
params: List(QueryParam),
result_columns: List(ResultItem),
)
}
Constructors
-
AnalyzedQuery( base: ParsedQuery, params: List(QueryParam), result_columns: List(ResultItem), )
pub type Column {
Column(name: String, scalar_type: ScalarType, nullable: Bool)
}
Constructors
-
Column(name: String, scalar_type: ScalarType, nullable: Bool)
pub type ColumnRename {
ColumnRename(table: String, column: String, rename_to: String)
}
Constructors
-
ColumnRename(table: String, column: String, rename_to: String)
pub type EnumDef {
EnumDef(name: String, values: List(String))
}
Constructors
-
EnumDef(name: String, values: List(String))
pub type GleamOutput {
GleamOutput(
out: String,
runtime: Runtime,
type_mapping: TypeMapping,
emit_sql_as_comment: Bool,
emit_exact_table_names: Bool,
omit_unused_models: Bool,
vendor_runtime: Bool,
strict_views: Bool,
query_parameter_limit: option.Option(Int),
)
}
Constructors
-
GleamOutput( out: String, runtime: Runtime, type_mapping: TypeMapping, emit_sql_as_comment: Bool, emit_exact_table_names: Bool, omit_unused_models: Bool, vendor_runtime: Bool, strict_views: Bool, query_parameter_limit: option.Option(Int), )Arguments
- omit_unused_models
-
When True, the generated
models.gleamincludes only tables and enums that are referenced by at least one generated query (directly viasource_table,embed, or via enum types on used tables / query columns / query params). Defaults to False to preserve the existing full-catalog output. - vendor_runtime
-
When True, emit a copy of
sqlode/runtimeinto the output directory asruntime.gleamand rewrite the generated module imports to point at the local copy. The target project no longer needssqlodeas a runtime dependency. Defaults to False so the shared-runtime path stays the default. - strict_views
-
When True, any schema warning from view resolution (unresolvable view columns, dropped views) is promoted to a fatal error. Defaults to True — a partially resolved view is almost always a schema/config mismatch, and letting it reach codegen produces a model that is silently out of sync with the real database. Set to False explicitly to restore the legacy warn-and-continue behaviour for legacy schemas.
- query_parameter_limit
-
When
Some(n),sqlode verifyrejects any analysed query whose inferred parameter count exceedsn.Nonedisables the check. Named after the sqlc setting of the same name so migrating users can port the config directly.
pub type Macro {
MacroArg(index: Int, name: String)
MacroNarg(index: Int, name: String)
MacroSlice(index: Int, name: String)
}
Constructors
-
MacroArg(index: Int, name: String) -
MacroNarg(index: Int, name: String) -
MacroSlice(index: Int, name: String)
pub type Overrides {
Overrides(
type_overrides: List(TypeOverride),
column_renames: List(ColumnRename),
)
}
Constructors
-
Overrides( type_overrides: List(TypeOverride), column_renames: List(ColumnRename), )
pub type ParsedQuery {
ParsedQuery(
name: String,
function_name: String,
command: runtime.QueryCommand,
sql: String,
source_path: String,
param_count: Int,
macros: List(Macro),
)
}
Constructors
-
ParsedQuery( name: String, function_name: String, command: runtime.QueryCommand, sql: String, source_path: String, param_count: Int, macros: List(Macro), )
pub type QueryParam {
QueryParam(
index: Int,
field_name: String,
scalar_type: ScalarType,
nullable: Bool,
is_list: Bool,
)
}
Constructors
-
QueryParam( index: Int, field_name: String, scalar_type: ScalarType, nullable: Bool, is_list: Bool, )
pub type ResultColumn {
ResultColumn(
name: String,
scalar_type: ScalarType,
nullable: Bool,
source_table: option.Option(String),
)
}
Constructors
-
ResultColumn( name: String, scalar_type: ScalarType, nullable: Bool, source_table: option.Option(String), )
pub type ResultItem {
ScalarResult(ResultColumn)
EmbeddedResult(EmbeddedColumn)
}
Constructors
-
ScalarResult(ResultColumn) -
EmbeddedResult(EmbeddedColumn)
pub type ScalarType {
IntType
FloatType
BoolType
StringType
BytesType
DateTimeType
DateType
TimeType
UuidType
JsonType
EnumType(name: String)
CustomType(
name: String,
module: option.Option(String),
underlying: ScalarType,
)
ArrayType(element: ScalarType)
}
Constructors
-
IntType -
FloatType -
BoolType -
StringType -
BytesType -
DateTimeType -
DateType -
TimeType -
UuidType -
JsonType -
EnumType(name: String) -
CustomType( name: String, module: option.Option(String), underlying: ScalarType, ) -
ArrayType(element: ScalarType)
pub type SqlBlock {
SqlBlock(
name: option.Option(String),
engine: Engine,
schema: List(String),
queries: List(String),
gleam: GleamOutput,
overrides: Overrides,
)
}
Constructors
-
SqlBlock( name: option.Option(String), engine: Engine, schema: List(String), queries: List(String), gleam: GleamOutput, overrides: Overrides, )
pub type TypeMapping {
StringMapping
RichMapping
StrongMapping
}
Constructors
-
StringMapping -
RichMapping -
StrongMapping
pub type TypeOverride {
DbTypeOverride(
db_type: String,
gleam_type: String,
nullable: option.Option(Bool),
)
ColumnOverride(
table: String,
column: String,
gleam_type: String,
)
}
Constructors
-
DbTypeOverride( db_type: String, gleam_type: String, nullable: option.Option(Bool), ) -
ColumnOverride(table: String, column: String, gleam_type: String)
Values
pub fn empty_overrides() -> Overrides
pub fn engine_to_string(engine: Engine) -> String
pub fn is_result_command(command: runtime.QueryCommand) -> Bool
pub fn parse_engine(value: String) -> Result(Engine, String)
pub fn parse_query_command(
value: String,
) -> Result(runtime.QueryCommand, String)
pub fn parse_runtime(value: String) -> Result(Runtime, String)
pub fn parse_sql_type(
type_text: String,
) -> Result(ScalarType, Nil)
Parse a SQL type name into a ScalarType by normalizing the type token (lowercasing, stripping modifiers and array markers, collapsing whitespace) and matching the base name against a fixed table of built-ins.
Used by both schema parsing (CREATE TABLE column types) and query analysis
(PostgreSQL type casts like $1::int). Returns Error(Nil) for unrecognized
types so callers can surface the original text in a precise diagnostic
instead of guessing.
pub fn parse_type_mapping(
value: String,
) -> Result(TypeMapping, String)
pub fn query_command_to_string(
command: runtime.QueryCommand,
) -> String
pub fn runtime_to_string(runtime: Runtime) -> String
pub fn type_mapping_to_string(mapping: TypeMapping) -> String