PostgreSQL¶
Scythe's primary and most complete dialect. All features are supported.
Supported features¶
- Enums --
CREATE TYPE ... AS ENUM (...)parsed and mapped toenum::name - Composite types --
CREATE TYPE ... AS (...)mapped tocomposite::name - Arrays --
TEXT[],INTEGER[], etc. mapped toarray<T> - JSONB / JSON -- mapped to
json; typed JSON via@json_typedannotation - Views -- resolved through underlying table definitions
- Domains --
CREATE DOMAINresolved to base type with NOT NULL propagation - Range types --
int4range,tstzrange, etc. mapped torange<T> - Network types --
INET,CIDR,MACADDRmapped toinet
Type mapping table¶
| PostgreSQL Type | Neutral Type | Notes |
|---|---|---|
SERIAL / INTEGER / INT4 |
int32 |
SERIAL implies NOT NULL |
BIGSERIAL / BIGINT / INT8 |
int64 |
|
SMALLSERIAL / SMALLINT / INT2 |
int16 |
|
REAL / FLOAT4 |
float32 |
|
DOUBLE PRECISION / FLOAT8 |
float64 |
|
NUMERIC / DECIMAL |
decimal |
Precision is stripped |
TEXT / VARCHAR / CHAR |
string |
All character types unify to string |
BOOLEAN / BOOL |
bool |
|
BYTEA |
bytes |
|
UUID |
uuid |
|
DATE |
date |
|
TIME / TIME WITHOUT TIME ZONE |
time |
|
TIMETZ / TIME WITH TIME ZONE |
time_tz |
|
TIMESTAMP / TIMESTAMP WITHOUT TIME ZONE |
datetime |
|
TIMESTAMPTZ / TIMESTAMP WITH TIME ZONE |
datetime_tz |
|
INTERVAL |
interval |
|
JSON / JSONB |
json |
|
INET / CIDR / MACADDR |
inet |
|
INTEGER[] |
array<int32> |
Recursive resolution |
TEXT[] |
array<string> |
|
INT4RANGE |
range<int32> |
|
INT8RANGE |
range<int64> |
|
TSTZRANGE |
range<datetime_tz> |
|
DATERANGE |
range<date> |
|
NUMRANGE |
range<decimal> |
|
| User-defined enum | enum::name |
|
| User-defined composite | composite::name |
|
| Domain type | resolves to base | NOT NULL propagated |
PostgreSQL-specific annotations¶
- Parameter placeholders use
$Nsyntax ($1,$2, ...) RETURNINGclause support for:oneand:manyon INSERT/UPDATE/DELETEON CONFLICT(UPSERT) is fully supportedSERIAL/BIGSERIALcolumns are automatically marked NOT NULL
Placeholder syntax¶
PostgreSQL uses positional $N placeholders: