Pedestal - Coercing id path-params to integer

13 views
Skip to first unread message

Valentín Fernández

unread,
Aug 25, 2024, 11:42:50 PM8/25/24
to pedestal-users
Hi, I'm new to Clojure and Pedestal.

I was having this error when executing a "get-user-by-id" sql query, cause my id param was passed as a String, and my id field type is a integer in the postgresql database:

[{:type org.postgresql.util.PSQLException
;    :message "ERROR: operator does not exist: integer = character varying\n  Hint: No operator matches the given name and argument types. You might need to add explicit type casts.\n  Position: 296"
;    :at [org.postgresql.core.v3.QueryExecutorImpl receiveErrorResponse "QueryExecutorImpl.java" 2725]}]

I solved this with this interceptor: Is this a good way to solve this error, or there is a better approach to this issue?
coerce-id-interceptor.png

Thanks a lot!
Reply all
Reply to author
Forward
0 new messages