数据库:参数化的日期字符串比较时也转换格式
- 教材项目 8 用参数传 "2024/1/23 23:59:59"(日期和时间之间两个空格)做 BETWEEN, 比较时用 tsql_cmp 把形如日期的字符串转成标准格式;日期和时间之间允许多个空格 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
19d6872d80
commit
13c3e4c3ec
3 files changed
+14
-2
No files matched your search
@@ -911,6 +911,14 @@ internal sealed class Translator
|
||||
_sql.Append(Values.Quote(Values.NormalizeDateLiteral(s.Value)));
|
||||
return;
|
||||
}
|
||||
// 参数的值执行时才知道:是日期样子的字符串时同样转成标准格式(教材 BETWEEN @time_start AND @time_end 传的是字符串)
|
||||
if (expression is VariableReference)
|
||||
{
|
||||
_sql.Append("tsql_cmp(");
|
||||
Expression(expression);
|
||||
_sql.Append(')');
|
||||
return;
|
||||
}
|
||||
Expression(expression);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user