Arrays and Lists
Typr provides full support for array and list types across databases that support them.
Database Supportβ
| Database | Array Syntax | Element Types |
|---|---|---|
| PostgreSQL | text[], int4[] | All scalar types |
| DuckDB | LIST(varchar), LIST(integer) | All scalar types |
| MariaDB | - | No array support |
| Oracle | VARRAY, Nested Table | Via collection types |
| SQL Server | - | No array support |
| DB2 | - | No array support |
PostgreSQL Arraysβ
PostgreSQL arrays are mapped to Java/Kotlin/Scala arrays:
EmployeeRow
Optional<List<String>> skills,
Optional<List<String>> certifications,
Arrays work seamlessly:
text[]βList<String>int4[]βList<Integer>/List<Int>boolean[]βList<Boolean>
DuckDB Listsβ
DuckDB uses LIST types which map similarly to Java arrays:
EmployeeRow
Optional<List<String>> skills,
Optional<List<String>> certifications,
Optional<List<Boolean>> weeklyAvailability,
DuckDB also supports nested types like:
STRUCTtypes β Generated as record/data classMAPtypes β See Map Types
Limitationsβ
Multidimensional arrays: PostgreSQL supports multidimensional arrays, but Typr currently generates single-dimension arrays. Nested arrays may be added in the future.
NULL elements: Arrays can contain NULL elements. Use Optional inside the array or check for nulls when processing.