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

Support advanced type mappings in the compiled model #2949

Open
roji opened this issue Nov 15, 2023 · 0 comments
Open

Support advanced type mappings in the compiled model #2949

roji opened this issue Nov 15, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@roji
Copy link
Member

roji commented Nov 15, 2023

Starting with 8.0, type mapping must have a static Default property in order to be supported in the compiled model; the generated code starts with these properties, and clones them to overwrite all the different info in RelationalTypeMappingParameters if necessary (store type, CLR type, etc. etc.).

Most type mappings were made compatible with this scheme in #2948. However, one problematic case is when a type mapping has state that isn't contained within RelationalTypeMappingParameters; since the default value can't get overwritten via the standard Clone (with accepts a RelationalTypeMappingParameters), we must customize the C# code generation in RelationalCSharpRuntimeAnnotationCodeGenerator.Create (for type mappings), adding an additional cloning to apply those custom state data.

Type mappings that require this are:

  • NpgsqlStringTypeMapping (varchar, xml, citext, ltree as string, lquery, ltxtquery
  • NpgsqlULongTypeMapping (xid8)
  • NpgsqlRangeTypeMapping
  • NpgsqlMultirangeTypeMapping
    • Seems to have some codegen issues (array/list over generic type?), probably on the EF side
  • NpgsqlEnumTypeMapping
    • Supported, except where a custom INpgsqlNameTranslator is specified. As the name translator is extracted from the ADO mapping. This is impossible to generate correctly in the compiled model; we can throw specifically for a non-default name translator, otherwise the whole mechanism needs to be rethought (I want to do that for other reasons).

/cc @AndriySvyryd

@roji roji added the enhancement New feature or request label Nov 15, 2023
@roji roji self-assigned this Nov 15, 2023
@roji roji modified the milestones: 8.0.1, 8.0.0 Nov 15, 2023
roji added a commit to roji/efcore.pg that referenced this issue Nov 17, 2023
roji added a commit to roji/efcore.pg that referenced this issue Nov 17, 2023
roji added a commit to roji/efcore.pg that referenced this issue Nov 17, 2023
roji added a commit to roji/efcore.pg that referenced this issue Nov 17, 2023
roji added a commit to roji/efcore.pg that referenced this issue Nov 18, 2023
@roji roji modified the milestones: 8.0.0, 9.0.0 Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant