Skip to content

Commit 5271463

Browse files
author
GaryBrunton
committed
Fixes this issue:
https://stackoverflow.com/a/66070044/384853 Now you can have empty opening and closing identifiers.
1 parent 97e2acb commit 5271463

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

QueryBuilder.Tests/GeneralTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ public void Return_Different_MethodInfo_WhenSame_Method_With_Different_GenericTy
8989
Assert.NotSame(call1, call2);
9090
}
9191

92+
[Fact]
93+
public void Custom_compiler_with_empty_identifier_overrides_should_remove_identifiers()
94+
{
95+
var compiler = new TestEmptyIdentifiersCompiler();
96+
97+
var wrappedValue = compiler.WrapValue("Table");
98+
99+
Assert.Equal("Table", wrappedValue);
100+
}
101+
92102
[Fact]
93103
public void Should_Equal_AfterMultipleCompile()
94104
{

QueryBuilder.Tests/Infrastructure/TestCompiler.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,10 @@ public virtual MethodInfo Call_FindCompilerMethodInfo(Type clauseType, string me
4848
return FindCompilerMethodInfo(clauseType, methodName);
4949
}
5050
}
51+
52+
class TestEmptyIdentifiersCompiler : TestCompiler
53+
{
54+
protected override string OpeningIdentifier { get; set; } = "";
55+
protected override string ClosingIdentifier { get; set; } = "";
56+
}
5157
}

QueryBuilder/Compilers/Compiler.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,8 @@ public virtual string WrapValue(string value)
834834
var opening = this.OpeningIdentifier;
835835
var closing = this.ClosingIdentifier;
836836

837+
if (string.IsNullOrWhiteSpace(opening) && string.IsNullOrWhiteSpace(closing)) return value;
838+
837839
return opening + value.Replace(closing, closing + closing) + closing;
838840
}
839841

0 commit comments

Comments
 (0)