Skip to content
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

Extension UseFsharpTypes() interferes with the npgsql translation for where statement on jsonb columns #159

Open
thomrad opened this issue Oct 31, 2023 · 0 comments

Comments

@thomrad
Copy link

thomrad commented Oct 31, 2023

Hello!

I have a postgres database which hosts json data in a table with a column using the datatype jsonb. When trying to query a specific json value, the translation into the correct sql statement is wrong.

Npgsql actually has that feature for the correct translation, but it won't get applied.

The setup I am using:

  • PostgreSQL 16.0.1
  • Npgsql.EntityFrameworkCore.PostgreSQL 7.0.11
  • EntityFrameworkCore.FSharp 6.0.7
  • FSharp.Core 7.0.0

I found out, that when I remove the UseFSharpTypes() extension from the DbContext class, the translation to the correct SQL statement works. If I enable the extension again, it fails.

According to the npgsql documentation, this is how it should be used (translated to F#):

let result = mydbcontext.Table.Where(fun x -> x.data.jsonfieldname = "value").ToList()

This is the correct translation:

SELECT s.data
FROM table AS s
WHERE s.data->>'jsonfieldname' = 'value'

This is the wrong translation when UseFSharpTypes() is enabled:

SELECT s.data
FROM table AS s
WHERE s.data = 'value'

The expected behaviour of course would be the correct translation from the npgsql library.

I have no clue what that issue could be, but my guess is, that the extension does not link to the npgsql library for translation but to the Microsoft version of the framework. I tried to put the extension methods in different orders - UseFSharpTypes() before UseNpgSql() - but that didn't help either.

I hope I gave all the infos for understanding the issue. Your help is very appreciated.

Thank you in advance
Thomas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant