Liking cljdoc? Tell your friends :D

Type Mapping

PG2 provides the following bridge between Postgres and Clojure realms.

Builtin Types

Numbers

PostgresReadingWriting
int2ShortShort, Integer, Long
int4Integerthe same
int8Longthe same
numericBigDecimalMost numeric types
float4FloatFloat, Double
float8Doublethe same

Text

PostgresReadingWriting
varcharStringString, UUID, Symbol, Character
textStringthe same
nameStringthe same
bpcharStringthe same
regprocStringthe same
charCharacterCharacter, 1-char String

Geometry

See the Geometry (line, box, etc) section for more info.

PostgresReadingWriting
pointClojure mapClojure map/vector, SQL string
linethe samethe same
boxthe samethe same
circlethe samethe same
polygonthe samethe same
paththe samethe same
lsegthe samethe same

Misc

PostgresReadingWriting
uuidUUIDUUID, String
jsonany Clojure valueany Clojure value
jsonbthe samethe same
byteabyte[]byte[], ByteBuffer
booleanBooleanBoolean
bitStringbyte[], String

Date & Time

PostgresReadingWriting
timestamptzOffsetDateTimeMost Temporal types (OffsetDateTime, Instant, etc)
timestampLocalDateTimethe same
dateLocalDatethe same
timeLocalTimeLocalTime, LocalTime
timetzOffsetTimeOffsetTime, LocalTime

Arrays

PG2 supports arrays of all types mentioned above. They can have more than one dimension which is useful sometimes for storing matrices. Names of array types always start with an underscore: _int4, for example (an array of int4).

For details, read the Arrays Support section.

The table below renders only a small subset of supported arrays:

PostgresReadingWriting
_int2Vector of shortList of short/int/double
_uuidVector of UUIDList of UUID
_timestamptzVector of OffsetDateTimeList of OffsetDateTime
... (many of them)

Extensions

PG Vector

See PGVector Support.

PostgresReadingWriting
vectorVector of doublesVector, List
sparsevecClojure mapVector, Clojure map

Enums

In Postgres, any enum type created in runtime gets its own id. That causes some problems because, although it's nothing but text, its id differs from the standard text type.

Each enum creates two types, in fact. The first one is an enum itself, and the second is an array type. PG2 supports both of them.

For details, see the Reading Postgres Types In Runtime section.

PostgresReadingWritingComment
fooStringString, Keyword, SymbolA plain enum value
_fooClojure mapVector, Clojure mapArray of enum values

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close