Type mapping

Each language guide below shows how SQL types map to host-language types, how nullability is expressed, and which dependencies are required.

Nullability

Nullability is determined from the schema and the query structure:

  • A column with NOT NULL is non-null.
  • A column without NOT NULL is nullable.
  • PRIMARY KEY columns are implicitly non-null.
  • Columns from the outer side of a LEFT/RIGHT/FULL JOIN are made nullable.
  • Scalar subqueries in the SELECT list produce nullable results.

The sections below show the nullable form alongside the non-null form for each type.


Java

SQL typeNon-nullNullable
BOOLEANbooleanBoolean
SMALLINTshortShort
INTEGER / INTintInteger
BIGINT / BIGSERIALlongLong
REAL / FLOAT4floatFloat
DOUBLE PRECISION / FLOAT8doubleDouble
NUMERIC / DECIMALBigDecimalBigDecimal
TEXT / VARCHAR / CHARStringString
BYTEAbyte[]byte[]
DATELocalDateLocalDate
TIMELocalTimeLocalTime
TIMESTAMPLocalDateTimeLocalDateTime
TIMESTAMPTZOffsetDateTimeOffsetDateTime
INTERVALStringString
UUIDUUIDUUID
JSON / JSONBStringString
type[]List<T>List<T>
UnknownObjectObject

Reference types (String, BigDecimal, etc.) are nullable by passing null. Primitive types (boolean, int, long, etc.) are boxed when the column is nullable.

The generated code uses only java.sql and standard JDK classes. No extra imports are needed for basic types.


Kotlin

SQL typeNon-nullNullable
BOOLEANBooleanBoolean?
SMALLINTShortShort?
INTEGER / INTIntInt?
BIGINT / BIGSERIALLongLong?
REAL / FLOAT4FloatFloat?
DOUBLE PRECISION / FLOAT8DoubleDouble?
NUMERIC / DECIMALBigDecimalBigDecimal?
TEXT / VARCHAR / CHARStringString?
BYTEAByteArrayByteArray?
DATELocalDateLocalDate?
TIMELocalTimeLocalTime?
TIMESTAMPLocalDateTimeLocalDateTime?
TIMESTAMPTZOffsetDateTimeOffsetDateTime?
INTERVALStringString?
UUIDUUIDUUID?
JSON / JSONBStringString?
type[]List<T>List<T>?
UnknownAnyAny?

Rust

SQL typeNon-nullNullable
BOOLEANboolOption<bool>
SMALLINTi16Option<i16>
INTEGER / INTi32Option<i32>
BIGINT / BIGSERIALi64Option<i64>
REAL / FLOAT4f32Option<f32>
DOUBLE PRECISION / FLOAT8f64Option<f64>
NUMERIC / DECIMALrust_decimal::DecimalOption<rust_decimal::Decimal>
TEXT / VARCHAR / CHARStringOption<String>
BYTEA / BLOBVec<u8>Option<Vec<u8>>
DATEtime::DateOption<time::Date>
TIMEtime::TimeOption<time::Time>
TIMESTAMPtime::PrimitiveDateTimeOption<time::PrimitiveDateTime>
TIMESTAMPTZtime::OffsetDateTimeOption<time::OffsetDateTime>
INTERVALStringOption<String>
UUIDuuid::UuidOption<uuid::Uuid>
JSON / JSONBserde_json::ValueOption<serde_json::Value>
type[]Vec<T>Option<Vec<T>>
Unknownserde_json::ValueOption<serde_json::Value>

Enable sqlx features as needed:

sqlx = { version = "0.8", features = [
    "runtime-tokio",
    "postgres",      # or "sqlite" / "mysql"
    "time",          # Date, Time, Timestamp, TimestampTz
    "uuid",          # UUID
    "rust_decimal",  # NUMERIC / DECIMAL
] }

Python

SQL typeNon-nullNullable
BOOLEANboolbool | None
SMALLINT / INTEGER / BIGINTintint | None
REAL / DOUBLE PRECISIONfloatfloat | None
NUMERIC / DECIMALdecimal.Decimaldecimal.Decimal | None
TEXT / VARCHAR / CHARstrstr | None
BYTEA / BLOBbytesbytes | None
DATEdatetime.datedatetime.date | None
TIMEdatetime.timedatetime.time | None
TIMESTAMP / TIMESTAMPTZdatetime.datetimedatetime.datetime | None
INTERVALdatetime.timedeltadatetime.timedelta | None
UUIDuuid.UUIDuuid.UUID | None
JSON (psycopg3)objectobject | None
JSON (sqlite3, mysql-connector)strstr | None
type[]list[T]list[T] | None
UnknownAnyAny | None

All date/time, decimal, and uuid types come from the standard library. psycopg3 automatically deserializes JSON columns to Python objects; sqlite3 and mysql-connector return the raw JSON string.


TypeScript

SQL typeNon-nullNullable
BOOLEANbooleanboolean | null
SMALLINT / INTEGER / BIGINTnumber ⚠️number | null
REAL / DOUBLE PRECISION / NUMERICnumbernumber | null
TEXT / VARCHAR / CHARstringstring | null
BYTEA / BLOBBufferBuffer | null
DATE / TIME / TIMESTAMP / TIMESTAMPTZDateDate | null
INTERVALstringstring | null
UUIDstringstring | null
JSON / JSONBunknownunknown | null
type[]T[]T[] | null
Unknownunknownunknown | null

⚠️ BIGINT maps to number, which loses precision above 2⁵³. Use BigInt in application code if your IDs or values may exceed this range.

All types are built-in to TypeScript/Node.js — no extra dependencies needed for the type annotations themselves.


JavaScript

Type mapping is identical to TypeScript. Types are expressed as JSDoc comments (@typedef, @param, @returns) rather than inline TypeScript syntax, but the underlying types are the same.


Go

SQL typeNon-nullNullable
BOOLEANboolsql.NullBool
SMALLINT / INTEGERint32sql.NullInt32
BIGINT / BIGSERIALint64sql.NullInt64
REAL / DOUBLE PRECISION / NUMERICfloat64sql.NullFloat64
TEXT / VARCHAR / CHARstringsql.NullString
BYTEA / BLOB[]byte[]byte
DATE / TIME / TIMESTAMP / TIMESTAMPTZtime.Timesql.NullTime
INTERVALstringsql.NullString
UUIDstringsql.NullString
JSON / JSONBjson.RawMessagejson.RawMessage
type[][]T[]T
Unknowninterface{}interface{}

All nullable types use the standard database/sql null wrappers. No extra dependencies are required beyond the driver itself.