-
Notifications
You must be signed in to change notification settings - Fork 2
DbColumn
do- edited this page Jan 8, 2023
·
35 revisions
DbColumn is an object describing a column of a relation (a regular data table or some similar object like SQL view etc.) in a database.
| Name | Type | Description |
|---|---|---|
name |
String |
Name (identifier) of this column |
comment |
String |
Comment for this column |
type |
String |
Name of the data type |
size |
int |
Maximum size of the data (length for VARCHAR, precision for DECIMAL etc.). The exact meaning (units etc.) and the mere existence meaning depends of the type. |
scale |
int |
For DECIMAL, his synonyms and/or derived types, (NUMERIC etc.) means the length of the fractional part. Must be absent for other types. |
default |
String |
The DEFAULT clause of the corresponding CREATE/ALTER TABLE statement. Always presented as a String, including numeric types. Explicit DEFAULT NULL is defined by a 4-letter string 'NULL'. |
nullable |
Boolean |
false for NOT NULL columns, true otherwise. |
min |
String |
The minimal allowed value. Corresponds to the HTML INPUT's min attribute. May be used in autogenerated validation procedures, forwarded to UI components etc. |
max |
String |
The maximal allowed value. Corresponds to the HTML INPUT's max attribute. May be used in autogenerated validation procedures, forwarded to UI components etc. |
pattern |
String |
The regular expression to test values against. Corresponds to the HTML INPUT's pattern attribute. May be used in autogenerated validation procedures, forwarded to UI components etc. |
The class implements a tiny DSL to build DbColumn objects from formatted strings.
column ::= ( physical | reference ) nullable? ("=" default)? range? re? ("//" comment )?
physical ::= type dimension?
dimension ::= "(" size ("," scale)? ")"
nullable ::= "?" | "!"
range ::= "{" min? ".." max? "}"
re ::= "/" pattern "/"
Where:
- for
reference, see DbReference; - when the
rangeis specified,minormaxmay be omitted, but not both -
default,minandmaxliterals are not delimited, so they must not contain any special characters used by delimiters by the DSL itself (e. g.maxcan't contain'}', but no ordinal type allow such constants, so it's not really a restriction). Round braces (and so, function calls, compound expressions etc.) are allowed indefault. - the
nullableavailability and meaning depends ondefault:
nullable |
deault |
example | The column is... |
|---|---|---|---|
| int | NULLABLE | ||
| defined | int = 0 | NOT NULL | |
! |
int! | NOT NULL | |
? |
defined | int ?= 0 | NULLABLE |
? |
n/a | ||
! |
defined | n/a |