Skip to content

Commit 5d369af

Browse files
Merge pull request #467 from gbrunton/master
Fixes empty identifier issue
2 parents 50382fa + 238463f commit 5d369af

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

QueryBuilder.Tests/GeneralTests.cs

+10
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

+7
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,11 @@ 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
}
58+

QueryBuilder/Compilers/Compiler.cs

+2
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,8 @@ public virtual string WrapValue(string value)
886886
var opening = this.OpeningIdentifier;
887887
var closing = this.ClosingIdentifier;
888888

889+
if (string.IsNullOrWhiteSpace(opening) && string.IsNullOrWhiteSpace(closing)) return value;
890+
889891
return opening + value.Replace(closing, closing + closing) + closing;
890892
}
891893

0 commit comments

Comments
 (0)