Skip to content

Remove SqlServer TypeMapping for CLR type char #8656

@lajones

Description

@lajones

An EntityType with property char is not supported by the SQL Server provider. However SqlServerTypeMapper does have a mapping in _clrTypeMappings for char (mapping it to a SQL Server int column).

The reason for this is to support generation of single character literals in the Query Pipeline e.g. as arguments to functions, or LIKE can take an ESCAPE argument which is a single character - see this test. Query checks that it can interpret each argument (in this case a single character) - if it fails to find a type mapping for that type then it assumes it cannot generate literals for that type.

We should remove the entry in _clrTypeMappings for SqlServerTypeMapper for char so that we will generate the correct error if someone tries to create a property of that type. But we need to provide an alternate means to translate the literal above. We discussed:

  1. Just changing how we deal with LIKE to enforce that the ESCAPE argument is a string, or
  2. Changing the way Query treats arguments in general to specifically allow it to try a string TypeMapping if a char one does not exist.
  3. Updating the TypeMapper to allow a set of types which it can interpret for generation of literals even if it does not allow that type as a property type.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions