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
This might be a terrible idea but I'm raising it just in case!
Would it be possible to provide support for optional parameters in .sql files? For instance maybe :id? would create a parameter that will not error when a value is omitted.
My use case is that I'm looking into creating a single updateById.sql file for one of my entities, and I'd like to allow calling code to only pass the fields that need to be updated. I'd be constructing the query itself to omit updates to fields with no value, for instance using something like:
UPDATE some_table SET
column_1 = COALESCE(:param_1?, column_1),
column_2 = COALESCE(:param_2?, column_2)
WHERE id = some_id;
Currently if I don't pass values to param_1 and param_2 tinypg will throw a Missing expected key error.
The text was updated successfully, but these errors were encountered:
One more use case -- I'd like to have a select query that can optionally take limit / offset values.
Ideally I could pass NULL to my limit in the event that I don't want to limit in a given instance, so the query would be something like LIMIT :limit and accept null
I'm realizing maybe the name of this issue should be translate undefined values to NULL since that would be more flexible and solve the problem directly.
This might be a terrible idea but I'm raising it just in case!
Would it be possible to provide support for optional parameters in
.sql
files? For instance maybe:id?
would create a parameter that will not error when a value is omitted.My use case is that I'm looking into creating a single
updateById.sql
file for one of my entities, and I'd like to allow calling code to only pass the fields that need to be updated. I'd be constructing the query itself to omit updates to fields with no value, for instance using something like:Currently if I don't pass values to param_1 and param_2 tinypg will throw a
Missing expected key
error.The text was updated successfully, but these errors were encountered: