Skip to content

Make annotations available in TypeMappingInfo #14000

Open
@roji

Description

@roji

When constructed from an IProperty, TypeMappingInfo currently extracts various information from it (e.g. ClrType), but does not keep the IProperty itself. This makes it impossible for the type mapper to access any annotations applied to the property which could influence the mapping.

For a concrete example, PostgreSQL PostGIS supports the following store type: GEOMETRY (POINT,4326). This acts as a constraint on the column to only accept points with SRID 4326. Now, we can add ForNpgsqlHasSrid() extension method just like Sqlite, but we have no way to flow this information into Npgsql's relational type mapping, to make it construct the right store type string.

As a workaround, I can catch this annotation in my MigrationsSqlGenerator, take the partial store type given by the mapping, and patch it to contain the SRID. However, this really seems like a hack (not to mention that spatial support is implemented in a plugin and MigrationsSqlGenerator is part of the provider). If the mapping could access the annotation, it would be able to generate a complete store type and this wouldn't be needed.

/cc @austindrenski

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions