Skip to content

Add type mapping support for additional store type postfix #11896

Closed as not planned
Closed as not planned

Description

@AndriySvyryd

MySQL specifies the store type for an Unicode string in this manner: "VARCHAR(20) CHARACTER SET utf8" which is currently not supported by RelationalTypeMapping.

Activity

  1. added this to the 2.2.0 milestone on May 4, 2018
  2. self-assigned this
    on May 4, 2018
  3. AndriySvyryd commented on May 4, 2018

    @AndriySvyryd
    MemberAuthor

    Instead of computing the store type in the constructor we should do it in a virtual method to allow it to be extended for other special cases like "varchar(max)"

  4. ajcvickers commented on May 4, 2018

    @ajcvickers
    Contributor

    It would be good to consider allowing more general modifiers, such as those use for collations.

  5. roji commented on Jun 20, 2018

    @roji
    Member

    Another relevant and similar case: PostgreSQL allows TIMESTAMP(5) WITH TIME ZONE, where the parentheses define the precision...

  6. modified the milestones: , , 3.0.0 on Sep 11, 2018
  7. 20 remaining items

  8. ajcvickers commented on Feb 10, 2020

    @ajcvickers
    Contributor

    Also see high-level collations issue #19866

  9. roji commented on Mar 27, 2020

    @roji
    Member

    Did a bit of investigations into collations on PostgreSQL.

    MySQL specifies the store type for an Unicode string in this manner: "VARCHAR(20) CHARACTER SET utf8" which is currently not supported by RelationalTypeMapping.

    PostgreSQL supports something that looks similar:

    CREATE TABLE test1 (
        a text COLLATE "de_DE",
        b text COLLATE "es_ES",
        ...
    );

    However, COLLATE is part of the column definition spec and not part of the type name, as the following doesn't work:

    SELECT CAST('hello' AS text COLLATE 'en_US');

    In that sense it's similar to NULL/NOT NULL, or DEFAULT. As a result, at least for PostgreSQL it seems to make more sense to have this as a standard migrations-only annotation rather than to make it part of the type mapping. The situation in MySQL may be similar or not (/cc @lauxjpn).

  10. AndriySvyryd commented on Mar 27, 2020

    @AndriySvyryd
    MemberAuthor

    @roji I agree. Was that the last thing you were going to do for this issue?

  11. removed this from the Backlog milestone on Mar 27, 2020
  12. ajcvickers commented on Mar 30, 2020

    @ajcvickers
    Contributor

    @lauxjpn We discussed this issue today and decided based on @roji's latest work on collation that Npgsql no longer needs us to do anything here. Is this something that is still needed for MySQL?

  13. lauxjpn commented on Mar 31, 2020

    @lauxjpn
    Contributor

    For MySQL, the following statements are valid:

    SELECT CONVERT('test', CHAR CHARACTER SET utf8mb4);
    SELECT CAST('test' AS CHAR CHARACTER SET utf8mb4);

    However, we also went the migrations annotation route and implemented HasCharSet() and HasCollation() extension methods for EF Core 3.0+, that can be used to set corresponding annotations (currently only on a column level, but table and database levels will be added for .NET 5).

    We have planned to make the current behavior of adding the default char set and collation in our RelationalTypeMappingSource implementation obsolete and removing it for .NET 5.

    So as far as I can see, we have no reservations against closing this issue.


    If extending RelationalTypeMapping in a provider specific way is a route that needs to be taken in the future, a general approach like enabling the possibility to add annotations to it could be a viable way.
    But of course providers are already implementing their concrete RelationalTypeMapping derived types, so they could just implement some provider specific interface in accordance with their requirements.

    It might still come in handy though in the future, to give RelationalTypeMappingSource.FindMapping() (read) access through RelationalTypeMappingInfo to the annotations of the property for which the RelationalTypeMapping is currently requested.
    However, we currently don't have a concrete scenario for this anymore for Pomelo.

  14. ajcvickers commented on Mar 31, 2020

    @ajcvickers
    Contributor

    Thanks @lauxjpn. Closing for now.

  15. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions