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

Remove lookup of JsonTypeMapping via JsonElement #32192

Open
roji opened this issue Oct 30, 2023 · 2 comments
Open

Remove lookup of JsonTypeMapping via JsonElement #32192

roji opened this issue Oct 30, 2023 · 2 comments

Comments

@roji
Copy link
Member

roji commented Oct 30, 2023

In order to find the provider's JsonTypeMapping, our code currently does a standard lookup with CLR type JsonElement (as a sort of special value). The problem is that some provider's actually do support JsonElement as a real property CLR type; in addition, if a user defines a JsonElement property on some entity type, this type mapping will be return, and things will likely fail in some unpredictable way.

We should find another way to look up the JsonTypeMapping, e.g. define some special CLR type instead of JsonElement that could be used, or introduce a new API or something.

/cc @maumar

@maumar
Copy link
Contributor

maumar commented Oct 31, 2023

dummy clr type sounds good to me

@roji
Copy link
Member Author

roji commented Feb 23, 2024

This is unfortunately more than a cleanup - the current hacky way of doing things in EFCore.PG unfortunately doesn't take care of literal generation, which is necessary e.g. when adding a column to an existing table (for the default value). There, CSharpHelper.UnknownLiteral is used, which just does a type mapping lookup based on the CLR type (JsonElement), retrieving the owned JSON type mapping rather than the non-owned one.

See npgsql/efcore.pg#3107 (comment) for more details.

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

No branches or pull requests

4 participants