sqlode/codegen/common
Values
pub fn catalog_scalar_types(
catalog: model.Catalog,
) -> List(model.ScalarType)
Collect all scalar types from catalog tables.
pub fn custom_type_imports(
scalar_types: List(model.ScalarType),
) -> List(String)
Collect import statements for module-qualified custom types from scalar types.
pub fn escape_string(input: String) -> String
pub fn gleam_fn(
name: String,
params: String,
return_type: String,
body: String,
) -> String
Render a Gleam function declaration as a single string.
gleam_fn(“double”, “x: Int”, “Int”, “x * 2”) → “pub fn double(x: Int) -> Int { x * 2 }”
pub fn gleam_type(name: String, body: String) -> String
Render a single-constructor Gleam type declaration.
gleam_type(“UserId”, “Int”) → “pub type UserId { UserId(Int) }”
pub fn has_slices(params: List(model.QueryParam)) -> Bool
pub fn out_to_module_path(out: String) -> String
Derive the Gleam module path from the output directory. Strips the “src/” prefix so imports match the actual file location. e.g. “src/db” -> “db”, “/abs/path/src/db” -> “db”
pub fn param_scalar_types(
queries: List(model.AnalyzedQuery),
) -> List(model.ScalarType)
Collect all scalar types from query params.
pub fn qualified_field_type(
scalar_type: model.ScalarType,
type_mapping_mode: model.TypeMapping,
) -> String
Render a param / record field’s Gleam type for generated modules
that are NOT models.gleam itself (currently params.gleam and
queries.gleam). They reach the generated EnumType / SetType
definitions and rich-scalar aliases / wrappers through a plain
import db/models, so every external reference must be qualified
with models. — the bare names only work inside models.gleam
where the types are declared. ArrayType recurses so arrays of
enum / set / rich scalars stay qualified.
pub fn queries_have_enum_params(
queries: List(model.AnalyzedQuery),
) -> Bool
pub fn queries_have_enums(
queries: List(model.AnalyzedQuery),
) -> Bool
pub fn queries_have_slices(
queries: List(model.AnalyzedQuery),
) -> Bool
pub fn render_enum_or_set_decoder(
scalar_type: model.ScalarType,
fallback: fn(model.ScalarType) -> String,
) -> String
Wrap the base decoder for EnumType and SetType columns so the
decoded value reaches the consuming record as the generated sum
type (or list of sum-type values for SET) rather than the raw
wire string. fallback is the decoder to use for every other
scalar type (adapter-specific in the caller — e.g. pog’s
decode.bool vs sqlight’s int-to-bool adapter).
pub fn result_scalar_types(
queries: List(model.AnalyzedQuery),
) -> List(model.ScalarType)
Collect all scalar types from query result columns.
pub fn runtime_import_path(gleam: model.GleamOutput) -> String
Import path used by generated modules for the sqlode runtime. When
gleam.vendor_runtime is enabled, the runtime source is written
into <out>/runtime.gleam and the generated code points at that
local copy (e.g. db/runtime). Otherwise the shared
sqlode/runtime dependency is used.