Fields - advanced
This page is only for users of GSF version 7.1 or earlier.
Click here for details of how to define these details in the current version.
Modularity
Genesis is modular, so if you have a dependency on another module (e.g. Auth), your project naturally inherits all the fields from that module and and they are available in your project.
It makes sense to re-use fields in dependent modules wherever possible; this cuts down your need to define field names that are unique across all modules and the project itself.
Scripting
GPAL is a scripting language that gives engineers plenty of advantages, especially when it comes to repetition.
For example, where you need to create a large number of table fields, say ALGO_PARAM_1
through to ALGO_PARAM_50
, you can introduce for
loops:
val algoParamPrefix = "ALGO_PARAM_"
for(i in 1..51) {
field(name = algoParamPrefix + i, type = STRING)
}
Default empty values and non-nullable STRING fields
You can define an empty
and non-nullable
STRING field as:
field(name = "REFERENCE", type = STRING, default = "", nullable = false)
Although this is a valid set-up by ANSI SQL standards, Oracle currently doesn't support this configuration, leading to failed database writes.
If you want to implement this set-up in Oracle, you have a choice of how to do it:
- Change all default values to have at least one character.
OR
- Provide a
SysDef
level override property:OracleEmptyStringFieldDefaultValue
, with at least one character.
For maximum simplicity and compatibility, consider simply declaring the field as nullable
:
field(name = "REFERENCE", type = STRING)
Precision and scale
The Genesis platform has predetermined column sizes, so the platform automatically translates the field types into the most suitable precision and scale.
The tables below provide details of the translation for each field type, depending on the database technology used.
Postgres
Genesis data type | POSTGRES data type |
---|---|
INT | int4 |
STRING | varchar(64) |
DATE | int8 |
DATETIME | int8 |
ENUM | varchar(64) |
LONG | int8 |
SHORT | int2 |
DOUBLE | float8 |
BIGDECIMAL | numeric(20, 5) |
NANO_TIMESTAMP | int8 |
RAW | bytea |
ORACLE
Genesis data type | ORACLE data type |
---|---|
INT | NUMBER(38,0) |
STRING | VARCHAR2(64) |
DATE | NUMBER |
DATETIME | NUMBER |
ENUM | VARCHAR2(64) |
LONG | NUMBER |
SHORT | NUMBER(38,0) |
DOUBLE | FLOAT |
BIGDECIMAL | NUMBER(20,5) |
NANO_TIMESTAMP | NUMBER |
RAW | BLOB |
SQL SERVER
Genesis data type | SQL SERVER data type | SQL SERVER data length | SQL SERVER data scale | SQL SERVER data precision |
---|---|---|---|---|
INT | int | 4 | 10 | |
STRING | nvarchar | 64 | ||
DATE | bigint | 8 | 19 | |
DATETIME | bigint | 8 | 19 | |
ENUM | nvarchar | 64 | ||
LONG | bigint | 8 | 19 | |
SHORT | smallint | 2 | 5 | |
DOUBLE | float | 8 | 53 | |
BIGDECIMAL | numeric | 13 | 5 | 20 |
NANO_TIMESTAMP | bigint | 8 | 19 | |
RAW | varbinary | -1 |