Implement string.Trim with parameters on SQL Server
We currently translate string.Trim only when no characters are specified (whitespace only), and implement it with LTRIM/RTRIM.
SQL Server 2017 introduced a more fully-featured TRIM function which can accept characters to trim. To maintain compatibility with older versions we can still use this only when non-whitespace characters are specified. Unfortunately no similar overloads exist for LTRIM/RTRIM (#22924).
Note that TRIM has a funky syntax (TRIM ( [ characters FROM ] string )), instead of just commas.
mysql has to deal with this syntax in some places, we could introduce a similar solution:
https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/blob/master/src/EFCore.MySql/Query/Expressions/Internal/MySqlComplexFunctionArgumentExpression.cs
Yeah, I have one too :rofl: Finally SQL Server will join the exclusive clique....
I would like to know how you expect the new TRIM function with parameters to work. Could it be easily translated to something like LTRIM(RTRIM('MyString', 'CharsToTrim'), 'CharsToTrim'), or are you expecting to use the new TRIM ( [ characters FROM ] string ) syntax?
We should definitely translate to the new SQL Server 2022 function, but the quirky syntax makes this a more difficult task. That goes beyond a beginner-level issue for sure.