AshScylla.DataLayer.SchemaUtils (AshScylla v1.0.7)

Copy Markdown View Source

Shared schema utilities for table names, column analysis, and identifier quoting.

Centralizes functions that were previously duplicated across AshScylla.DataLayer.SchemaMigration, AshScylla.Migration, AshScylla.DataLayer.MaterializedView, and AshScylla.ResourceGenerator.

Summary

Functions

Returns the table name for a resource.

Quotes a CQL identifier (table name, column name, etc.) for safe use in CQL strings.

Resolves a type name for a UDT, sanitizing it for safe CQL interpolation.

Returns the list of columns that cannot have secondary indexes.

Functions

get_table_name(resource)

@spec get_table_name(module()) :: String.t()

Returns the table name for a resource.

Checks the DSL table/1 config first, then falls back to deriving from the module name (using domain prefix if available).

quote_name(name)

@spec quote_name(atom() | String.t()) :: String.t() | no_return()

Quotes a CQL identifier (table name, column name, etc.) for safe use in CQL strings.

Uses double-quote escaping per CQL spec. Delegates validation to AshScylla.Identifier.validate/1.

quote_name_unchecked(name)

@spec quote_name_unchecked(String.t()) :: String.t()

sanitize_type_name(type_name)

@spec sanitize_type_name(String.t() | atom()) :: String.t()

Resolves a type name for a UDT, sanitizing it for safe CQL interpolation.

unindexable_columns(resource)

@spec unindexable_columns(module()) :: [atom()]

Returns the list of columns that cannot have secondary indexes.

Currently this is only the sole partition key column (ScyllaDB forbids it). Returns an empty list for composite partition keys or resources without a clear single partition key.