Skip to content

Commit 969cd68

Browse files
committed
fix #71
1 parent 387d135 commit 969cd68

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

build/version.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<VersionMajor>4</VersionMajor>
44
<VersionMinor>0</VersionMinor>
5-
<VersionPatch>58</VersionPatch>
5+
<VersionPatch>59</VersionPatch>
66
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
77
</PropertyGroup>
88
</Project>

src/SmartSql/Configuration/Tags/Switch.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,39 @@ public class Switch : Tag
88
public override bool IsCondition(AbstractRequestContext context)
99
{
1010
EnsurePropertyValue(context);
11-
return true;
11+
var matchedTag = GetMatchedTag(context);
12+
return matchedTag != null;
1213
}
14+
1315
public override void BuildSql(AbstractRequestContext context)
16+
{
17+
var matchedTag = GetMatchedTag(context);
18+
matchedTag?.BuildSql(context);
19+
}
20+
21+
private ITag GetMatchedTag(AbstractRequestContext context)
1422
{
1523
var matchedTag = ChildTags.FirstOrDefault(tag =>
1624
{
1725
if (tag is Case caseTag)
1826
{
1927
return caseTag.IsCondition(context);
2028
}
29+
2130
return false;
2231
}) ?? ChildTags.FirstOrDefault(tag => tag is Default);
23-
24-
matchedTag?.BuildSql(context);
25-
32+
return matchedTag;
2633
}
2734

2835
public class Case : StringCompareTag
2936
{
3037
public override bool IsCondition(AbstractRequestContext context)
3138
{
3239
var reqVal = EnsurePropertyValue(context);
33-
if (reqVal == null) { return false; }
40+
if (reqVal == null)
41+
{
42+
return false;
43+
}
3444

3545
var reqValStr = reqVal is Enum ? Convert.ToInt64(reqVal).ToString() : reqVal.ToString();
3646
return reqValStr.Equals(CompareValue);
@@ -45,4 +55,4 @@ public override bool IsCondition(AbstractRequestContext context)
4555
}
4656
}
4757
}
48-
}
58+
}

0 commit comments

Comments
 (0)