You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to open an issue to improve the error messages when errors like Error: UNDEFINED_VALUE: Undefined values are not allowed happen.
Currently it's not easy to know what undefined values are being passed, especially if you're passing multiple interpolated values and are not using 100% TypeScript in the project.
If possible, with a code snippet showing the tagged template literal and which parameter is undefined, similar to the experience when you break JSX code in Next.js:
Agreed, that would be a great improvement, but should at least be done at no cost to performance. Currently the undefined error is thrown before the query string has finished building, but I just did a quick test, and getting an error that includes the part of the string up to the undefined value is pretty easy. Eg.
sql` select name, content from users join posts using(user_id) where user_id = ${undefined} limit 1`
would then throw
Error: UNDEFINED_VALUE: Undefined values are not allowed:
select
name, content
from users
join posts using(user_id)
where user_id = $1
^ is undefined
That solves the raw parameter values, but we'd also need to cover the dynamic ones passed using sql(), but I think that should be doable too.
Activity
porsager commentedon Aug 9, 2022
Agreed, that would be a great improvement, but should at least be done at no cost to performance. Currently the undefined error is thrown before the query string has finished building, but I just did a quick test, and getting an error that includes the part of the string up to the undefined value is pretty easy. Eg.
would then throw
That solves the raw parameter values, but we'd also need to cover the dynamic ones passed using
sql(), but I think that should be doable too.Would the above be good enough?
porsager commentedon Aug 9, 2022
Closing this as we also have #380 :)
[-]Improve error messages of [/-][+]Improve error messages of undefined values[/+]karlhorky commentedon Aug 9, 2022
Or sorry, didn't see this one, I'll comment over there!