-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translate Guid.NewGuid() #695
Comments
Can you please post full details on what happens (exception stack trace, etc.)? Npgsql is definitely supposed to translate |
Some version info would be useful here too (e.g. PostgreSQL, Npgsql provider). I could see this getting caught up in an evaluatable filter and the ordering being done on the client (i.e. no exception, just log warnings about local eval). But that's just speculation without version info. |
"PostgreSQL 9.6.10, compiled by Visual C++ build 1800, 64-bit" The code looks like this: var result = query.OrderBy(item => Guid.NewGuid()).Skip(offset_value).Take(limit_value).ToArray(); There is no exception. As I see it just calls query like |
@eshangin Thanks for supplying the additional information. @roji It looks like we don't actually have a method translator for Am I overlooking something, or should we add the translator? Design notes
|
The problem here is in the To workaround the issue create an extension you want and a database function. For example: // Requires pgcrypto
[DbFunction]
public static Guid GenRandomUuid() => throw new NotImplementedException(); |
The goal is to make random ordering. We could use |
@austindrenski you're right - seems like we're missing a translator for If we do add support out-of-the-box, and the user uses As @YohDeadfall says, the user can choose between the two extensions - although from my PostgreSQL experience What do you guys think? I'm not totally against the idea of a plugin, but it seems easier and more natural to just have it in. |
On an unrelated note, does it make sense to think about translating |
Ah that's right, I forgot that we do something similar with Do you mean |
@austindrenski great, will look forward to your PR. Of course you're right - I meant But to go back to the original question: the fact that |
Ope, you're right. I had that backwards (again). We should be good to translate it. |
Hi. Today tried to apply
.OrderBy(item => Guid.NewGuid())
to get items in random order but as I see Npgsql unable to translate it to Postgres query. In case of MsSQL it works and translates toorder by newid()
query.I think it will be good to have the same kind feature in Npgsql. Maybe it could be in
EF.Functions
, I'm not sure...The text was updated successfully, but these errors were encountered: