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
It seems there is some kind of query parameters name conflict when heavelly using Expression. I used parameters userId and now in expression and helpers method and I got exception:
Exception message:
`Npgsql.PostgresException: '42601: syntax error at or near ":"`
When I change params to userId2 and now2 in Expression or GetQuery method this starts to work.
Current workaround for me: ensure all parameters have unique names. This is not robust solution, but for a moment it works.
BeforeExecute
-- PostgreSQL.15 PostgreSQL
DECLARE @userId Uuid -- GuidSET @userId ='1e81691f-8bbe-495b-89ca-b28ace9c7a7f'::uuid
DECLARE @now_1 Timestamp-- DateTime2SET @now_1 ='2023-08-23 09:30:34.265'::timestampSELECTkey_data_result.id,
detail.category_idFROM
(
SELECT DISTINCTx.idFROM
media_items x
WHERE
(EXISTS(
SELECT*FROM
media_item_user_share y
WHEREx.id=y.media_item_idANDy.user_id= :userId ANDy.expires_at> :now
) OR EXISTS(
SELECT*FROM
media_item_user_share y_1
WHEREx.id=y_1.media_item_idANDy_1.created_by_id= :userId ANDy_1.expires_at> :now
))
) key_data_result
INNER JOIN media_item_to_media_item_categories detail ONkey_data_result.id=detail.media_item_id
Error
Exception: Npgsql.PostgresException
Message : 42601: syntax error at or near ":"
At the first SQL (from server's log) I see named parameter :now which should not be there. As far as I know, Npgsl should replace it with positional one, but didn't for some reason.
Second thing, which I noticed is that problem rises at second query execution. At first one all works fine. Is there some cache involved?
Good day!
It seems there is some kind of query parameters name conflict when heavelly using Expression. I used parameters
userId
andnow
in expression and helpers method and I got exception:When I change params to
userId2
andnow2
inExpression
orGetQuery
method this starts to work.Current workaround for me: ensure all parameters have unique names. This is not robust solution, but for a moment it works.
Steps to reproduce
Wrong SQL seen in logs:
Environment details
Linq To DB
version: 5.2.2Database (with version): PostgreSQL 15
ADO.NET Provider (with version): Npgsql 7.0.4
Operating system: Windows 10
.NET Version: 7.0
The text was updated successfully, but these errors were encountered: