@@ -15,6 +15,7 @@ public partial class Compiler
1515 protected virtual string ColumnAsKeyword { get ; set ; } = "AS " ;
1616 protected virtual string TableAsKeyword { get ; set ; } = "AS " ;
1717 protected virtual string LastId { get ; set ; } = "" ;
18+ protected virtual string EscapeCharacter { get ; set ; } = "\\ " ;
1819
1920 protected Compiler ( )
2021 {
@@ -446,7 +447,7 @@ protected virtual string CompileColumns(SqlResult ctx)
446447 sql = "DISTINCT " + sql ;
447448 }
448449
449- return "SELECT " + aggregate . Type . ToUpper ( ) + "(" + sql + $ ") { ColumnAsKeyword } " + WrapValue ( aggregate . Type ) ;
450+ return "SELECT " + aggregate . Type . ToUpperInvariant ( ) + "(" + sql + $ ") { ColumnAsKeyword } " + WrapValue ( aggregate . Type ) ;
450451 }
451452
452453 return "SELECT 1" ;
@@ -482,7 +483,7 @@ public virtual string CompileUnion(SqlResult ctx)
482483 {
483484 if ( clause is Combine combineClause )
484485 {
485- var combineOperator = combineClause . Operation . ToUpper ( ) + " " + ( combineClause . All ? "ALL " : "" ) ;
486+ var combineOperator = combineClause . Operation . ToUpperInvariant ( ) + " " + ( combineClause . All ? "ALL " : "" ) ;
486487
487488 var subCtx = CompileSelectQuery ( combineClause . Query ) ;
488489
@@ -809,12 +810,11 @@ public virtual string WrapIdentifiers(string input)
809810 return input
810811
811812 // deprecated
812- . Replace ( "{" , this . OpeningIdentifier )
813- . Replace ( "}" , this . ClosingIdentifier )
813+ . ReplaceIdentifierUnlessEscaped ( this . EscapeCharacter , "{" , this . OpeningIdentifier )
814+ . ReplaceIdentifierUnlessEscaped ( this . EscapeCharacter , "}" , this . ClosingIdentifier )
814815
815- . Replace ( "[" , this . OpeningIdentifier )
816- . Replace ( "]" , this . ClosingIdentifier ) ;
816+ . ReplaceIdentifierUnlessEscaped ( this . EscapeCharacter , "[" , this . OpeningIdentifier )
817+ . ReplaceIdentifierUnlessEscaped ( this . EscapeCharacter , "]" , this . ClosingIdentifier ) ;
817818 }
818-
819819 }
820820}
0 commit comments