Fix reports crash on client churn risk query #50
Reference in New Issue
Block a user
Delete Branch "fix/reports-clients-churn-query"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
/api/reports/clientsendpoint returning 500 Internal Server Errorsqltemplate literal in aHAVINGclause cannot serialize a JavaScriptDateobject — thepostgresdriver throws "The string argument must be of type string or an instance of Buffer"Dateto an ISO string and add an explicit::timestamptzcastRoot cause analysis
The churn risk query passes a
Dateobject directly into a Drizzlesqltagged template:While Drizzle handles
Dateparameters in.where()clauses (via its column-aware type system), rawsqltemplate parameters in.having()are passed directly to thepostgresdriver which cannot serializeDateobjects in this context.Test plan
having()withDatethrows::timestamptzcast resolves the errorCloses #49
🤖 Generated with Claude Code