An implicit data type conversion refers to a data type conversion performed automatically by Symfoware Server, without the need to explicitly specify the data type to convert to.
The combination of possible data type conversions differs, depending on whether the expression in the conversion source is a literal.
For non-literals, data types can only be converted to other types within the same range.
For literals, character string literal types can be converted to the target data type. Numeric literals are implicitly converted to specific numeric types. These implicitly converted numeric literals can then have their types converted to match the conversion target data type within the numeric type range. For bit character string literals, only the bit column data type can be specified. The following shows the range of type conversions for literals.
Conversion target | Conversion source | |||
---|---|---|---|---|
Character literal (*1) | Numeric literal(*2) | Bit character string literal | ||
Numeric type | SMALLINT | Y | N | N |
INTEGER | Y | Y (*3) | N | |
BIGINT | Y | Y (*4) | N | |
DECIMAL | Y | Y (*5) | N | |
NUMERIC | Y | Y (*5) | N | |
REAL | Y | N | N | |
DOUBLE PRECISION | Y | N | N | |
SMALLSERIAL | Y | N | N | |
SERIAL | Y | Y (*3) | N | |
BIGSERIAL | Y | Y (*4) | N | |
Currency type | MONEY | Y | N | N |
Character type | CHAR | Y | N | N |
VARCHAR | Y | N | N | |
NCHAR | Y | N | N | |
NCHAR VARYING | Y | N | N | |
TEXT | Y | N | N | |
Binary data type | BYTEA | Y | N | N |
Date/time type | TIMESTAMP WITHOUT TIME ZONE | Y | N | N |
TIMESTAMP WITH TIME ZONE | Y | N | N | |
DATE | Y | N | N | |
TIME WITHOUT TIME ZONE | Y | N | N | |
TIME WITH TIME ZONE | Y | N | N | |
INTERVAL | Y | N | N | |
Boolean type | BOOLEAN | Y | N | N |
Geometric type | POINT | Y | N | N |
LSEG | Y | N | N | |
BOX | Y | N | N | |
PATH | Y | N | N | |
POLYGON | Y | N | N | |
CIRCLE | Y | N | N | |
Network address type | CIDR | Y | N | N |
INET | Y | N | N | |
MACADDR | Y | N | N | |
Bit string type | BIT | Y | N | Y |
BIT VARYING | Y | N | Y | |
Text search type | TSVECTOR | Y | N | N |
TSQUERY | Y | N | N | |
UUID type | UUID | Y | N | N |
XML type | XML | Y | N | N |
JSON type | JSON | Y | N | N |
Y: Can be converted
N: Cannot be converted
*1: Only strings that can be converted to the data type of the conversion target can be specified (such as "1" if the conversion target is a numeric type)
*2: "Y" indicates specific numeric types that are converted first.
*3: Integers that can be expressed as INTEGER types can be specified
*4: Integers that cannot be expressed as INTEGER types, but can be expressed as BIGINT types, can be specified
*5: Integers that cannot be expressed as INTEGER or BIGINT types, but that can be expressed as NUMERIC types, or numeric literals that contain a decimal point or the exponent symbol (e), can be specified
Implicit data type conversions can be used when comparing or storing data.
The conversion rules differ, depending on the reason for converting. Purpose-specific explanations are provided below.