Semantius Logo

Fields

On this page

When a record is added to or deleted from fields, the database structure is updated to match: each field is mapped to a column of its entity’s table. Adding a record adds the column, and deleting it drops the column with its values.

The field record

ColumnMeaning
id<table_name>.<field_name>, such as tickets.status. Generated, and it follows a rename.
table_nameThe entity. Cannot change (90221).
field_nameThe column’s name: a-z, 0-9 and _, starting with a letter, unique in the entity. A leading _ is reserved (90224), and the length is limited by the names generated from it (90276).
titleThe label in forms and grids. Required.
descriptionWhat the field holds. It becomes the column’s comment.
formatWhat the field holds and how it is stored. Default text. See Formats.
input_typedefault, required, readonly, disabled or hidden. required is enforced by the database; see Required fields.
default_valueThe value a new record gets. See Defaults.
field_orderThe field’s position in forms and grids. Left at 0, it is set to 10 more than the highest position below 900000. created_at and updated_at sit at 999998 and 999999.
widthThe field’s width in forms: default, s, m or w.
searchableAdds the field to the entity’s full-text search.
unique_valueNo two records may hold the same value. Empty values (null, and '' for text) are not compared. Only single fields: there is no uniqueness across several fields.
enum_valuesFor an enum, the allowed values: a list of strings, or of objects {"value", "label", "description", "color", "icon"}.
precisionDecimal places of a number, 0 to 18. Default 2.
reference_table, reference_delete_modeThe entity a reference or parent field points at, and what happens when that record is deleted. See Relationships.
relationship_labelThe verb for the relationship in diagrams and navigation. Default has.
singular_label_parent, plural_label_parentHow the parent’s list of children names these records.
is_pkWhether the field is the key. Cannot change (90222).
ctypeSet by the platform. See Derived types.
cube_typeThe field’s role in the entity’s analytics cube: dimension or measure, auto to let the platform choose, or disabled to leave it out.
catalog_field_codeThe catalog field the field came from. Write-once (90202).
input_type_rule, rollupAn input mode rule and a rollup definition.

There is no required column: a field is required when its input_type is required.

Required fields

The database refuses a record (90258) whose required field holds no value:

  • null, for the formats that allow it;
  • blank or whitespace-only text, and '' for an enum;
  • {}, [], null or "" for JSON;
  • empty binary data, and 0 for a rating.

Numbers, booleans and durations always hold a value. A parent field needs no check of its own: a record without its parent is refused by the reference. A field with any input_type_rule gets no database check, since the rule decides when it is required.

Defaults

default_valueA new record gets
A number, true, false or textThat value, converted to the column’s type.
today, tomorrow, yesterday, now, $today, $nowOn a date or date-time field, the day or moment of each insert, in UTC. A time field takes now and $now only. Elsewhere they are refused (90284).
$user_id or CURRENT_USEROn a reference or parent field to users, the signed-in user. $user_id is refused on any other field (90283), and so is CURRENT_USER, except on a text field, where it stores the name of the database role the request runs as, which is the same for every user.
CURRENT_TIMESTAMP, CURRENT_DATE, now(), gen_random_uuid() and a few other SQL functionsThe function’s result at each insert.
EmptyThe empty value of the format: see Formats.

A default holds at most 200 characters, and no ;, --, /* or control characters. Changing a default affects new records only.

Changing a field

  • Format. A format can change only to one with the same column type: text to email or enum, int32 to rating. Anything else, such as int32 to int64 or text to date, is refused (90223): drop the field, which loses its values, and create it again. A reference takes the type of the key it points at, so text can become a reference to an entity with a text key, but not one to users, whose key is a number.
  • Required. Making a field required, or adding a required field to a table that has records, is refused while records would break the check (90259). Give a new required field a default that passes.
  • Enum values. Removing a value that records still hold is refused (23514).
  • Precision. Changing it rewrites the column, and lowering it rounds the stored values.
  • Renaming renames the column and keeps its values. It is refused while a rule names the field (90275), because rules are never rewritten: change the rule first. Rollup definitions are rewritten.
  • Deleting drops the column with its values. It is refused while a rollup depends on the field (90266). A rule that reads a deleted field is not refused and reads null.
  • Core fields (the key, the label and the timestamps) cannot be deleted (90217), renamed (90218, the label excepted), or given a new format (90219) or default (90220, the label excepted).

Derived types

ctype tells what kind of column a field is. The platform sets it; a client cannot (90214).

ctypeThe field is
''An ordinary field.
idThe key.
labelThe label column.
computed_labelThe label column, written by a computed field.
auditcreated_at or updated_at.
coreA column of the platform’s own tables.
computedWritten by a computed field. Forms show it disabled.
rollupA rollup field.