Skip to content

Commit f0dfd2e

Browse files
committed
Add support for DATEADD, DATEDIFF, and related functions; normalize parameters in function calls
1 parent 999ab54 commit f0dfd2e

15 files changed

Lines changed: 120 additions & 1 deletion

SqlScriptDom/Parser/TSql/CodeGenerationSupporter.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,20 @@ internal static class CodeGenerationSupporter
293293
internal const string DataRetention = "DATA_RETENTION";
294294
internal const string DataSource = "DATA_SOURCE";
295295
internal const string Date = "DATE";
296+
internal const string DateAdd = "DATEADD";
297+
internal const string DateBucket = "DATE_BUCKET";
296298
internal const string DateCorrelationOptimization = "DATE_CORRELATION_OPTIMIZATION";
299+
internal const string DateDiff = "DATEDIFF";
300+
internal const string DateDiffBig = "DATEDIFF_BIG";
297301
internal const string DateFirst = "DATEFIRST";
298302
internal const string DateFormat = "DATEFORMAT";
299303
internal const string DateFormat2 = "DATE_FORMAT";
304+
internal const string DateName = "DATENAME";
305+
internal const string DatePart = "DATEPART";
300306
internal const string DateTime = "DATETIME";
301307
internal const string DateTime2 = "DATETIME2";
302308
internal const string DateTimeOffset = "DATETIMEOFFSET";
309+
internal const string DateTrunc = "DATETRUNC";
303310
internal const string Deterministic = "DETERMINISTIC";
304311
internal const string DboOnly = "DBO_ONLY";
305312
internal const string DbChaining = "DB_CHAINING";

SqlScriptDom/Parser/TSql/TSql100.g

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20874,6 +20874,9 @@ regularBuiltInFunctionCall [FunctionCall vParent]
2087420874
:
2087520875
(
2087620876
expressionList[vParent, vParent.Parameters]
20877+
{
20878+
NormalizeDatePartFunctionFirstParameter(vParent);
20879+
}
2087720880
|
2087820881
vColumn=starColumnReferenceExpression
2087920882
{

SqlScriptDom/Parser/TSql/TSql110.g

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23849,6 +23849,9 @@ regularBuiltInFunctionCall [FunctionCall vParent]
2384923849
:
2385023850
(
2385123851
expressionList[vParent, vParent.Parameters]
23852+
{
23853+
NormalizeDatePartFunctionFirstParameter(vParent);
23854+
}
2385223855
|
2385323856
vColumn=starColumnReferenceExpression
2385423857
{

SqlScriptDom/Parser/TSql/TSql120.g

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24598,6 +24598,9 @@ regularBuiltInFunctionCall [FunctionCall vParent]
2459824598
:
2459924599
(
2460024600
expressionList[vParent, vParent.Parameters]
24601+
{
24602+
NormalizeDatePartFunctionFirstParameter(vParent);
24603+
}
2460124604
|
2460224605
vColumn=starColumnReferenceExpression
2460324606
{

SqlScriptDom/Parser/TSql/TSql130.g

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29420,6 +29420,9 @@ regularBuiltInFunctionCall [FunctionCall vParent]
2942029420
:
2942129421
(
2942229422
expressionList[vParent, vParent.Parameters]
29423+
{
29424+
NormalizeDatePartFunctionFirstParameter(vParent);
29425+
}
2942329426
|
2942429427
vColumn=starColumnReferenceExpression
2942529428
{

SqlScriptDom/Parser/TSql/TSql140.g

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30237,6 +30237,9 @@ regularBuiltInFunctionCall [FunctionCall vParent]
3023730237
:
3023830238
(
3023930239
expressionList[vParent, vParent.Parameters]
30240+
{
30241+
NormalizeDatePartFunctionFirstParameter(vParent);
30242+
}
3024030243
|
3024130244
vColumn=starColumnReferenceExpression
3024230245
{

SqlScriptDom/Parser/TSql/TSql150.g

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31390,6 +31390,9 @@ regularBuiltInFunctionCall [FunctionCall vParent]
3139031390
:
3139131391
(
3139231392
expressionList[vParent, vParent.Parameters]
31393+
{
31394+
NormalizeDatePartFunctionFirstParameter(vParent);
31395+
}
3139331396
|
3139431397
vColumn=starColumnReferenceExpression
3139531398
{

SqlScriptDom/Parser/TSql/TSql160.g

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32215,6 +32215,9 @@ regularBuiltInFunctionCall [FunctionCall vParent]
3221532215
:
3221632216
(
3221732217
expressionList[vParent, vParent.Parameters]
32218+
{
32219+
NormalizeDatePartFunctionFirstParameter(vParent);
32220+
}
3221832221
|
3221932222
vColumn=starColumnReferenceExpression
3222032223
{

SqlScriptDom/Parser/TSql/TSql170.g

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33343,6 +33343,9 @@ regularBuiltInFunctionCall [FunctionCall vParent]
3334333343
:
3334433344
(
3334533345
expressionList[vParent, vParent.Parameters]
33346+
{
33347+
NormalizeDatePartFunctionFirstParameter(vParent);
33348+
}
3334633349
|
3334733350
vColumn=starColumnReferenceExpression
3334833351
{

SqlScriptDom/Parser/TSql/TSql180.g

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33343,6 +33343,9 @@ regularBuiltInFunctionCall [FunctionCall vParent]
3334333343
:
3334433344
(
3334533345
expressionList[vParent, vParent.Parameters]
33346+
{
33347+
NormalizeDatePartFunctionFirstParameter(vParent);
33348+
}
3334633349
|
3334733350
vColumn=starColumnReferenceExpression
3334833351
{

0 commit comments

Comments
 (0)