#9118·gel

SQL `DATE_TRUNC` query `ExecutionError` / `FATAL: list index out of range`

Author: jackfischerCreated Nov 10, 2025Updated Nov 25, 2025
  • Gel Version: 6.11 and 7.0
  • Gel CLI Version: 7.9.0
  • OS Version:

Steps to Reproduce:

Run the following SQL,

sql
SELECT 
	DATE_TRUNC('month', al."createdDatetime") as log_date,
    COUNT(*) as log_count
FROM "AuditLog" al
GROUP BY DATE_TRUNC('month', al."createdDatetime")

Gel protocol: ExecutionError: could not determine data type of parameter $2 SQL protocol: FATAL: list index out of range

Schema:

esdl
module default {

    type AuditLog {
        required createdDatetime: datetime {
            default := datetime_current();
        }
    }

}