Skip to content

Query: Enable translations that generate different SQL depending on a value to be cached #12764

@MikeDempseyFL

Description

@MikeDempseyFL

The current implementation of the relational StringCompareTranslator only handles the String.Compare(s1, s2) method.
On our database that would be indeterminate since the database session may be set to use case specific, or not specific, comparisons.
I want to force this method to always use case specific comparisons and to also support the String.Compare(s1, s2, ignoreCase) method in our EF provider.

In order to do this it appears that I need to add our own StringCompareTranslator and also add an override for the VisitStringCompare method in our QuerySqlGenerator.

My current design does work for 3 of the 5 possible scenarios but the remaining 2 [less common] cases would require some other way to pass information from the translator to the visitor.

I am currently adding the required text decoration in the translator and using it in the visitor, but I can only decorate constant expressions and simple column references.
If one term is a more complex column reference [e.g. e.name.Substring(1,3) rather than just e.name.] and the other term is either a variable [i.e. a parameter] or another complex column reference then I can't add the required information.

Note that in order to support simple column references I essentially have to 'visit' the column reference in the translator in order to turn it into a constant expression [e.g. "e"."name" (CS)] which kind of bends the rules already.

An example of a case specific comparison between a column reference and a variable would be:
"e"."name" = ? (CS)

Can anyone suggest an alternative way to handle this without jumping through hoops to only partially support the requirement.

Further technical details

EF Core version: 2.1
Database Provider: Teradata
Operating system: Windows 10
IDE: Visual Studio 2017 15.6

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions