Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
f16d4ce
Add support of DateOnly/TimeOnly types
SergeiPavlov Jun 6, 2022
76124aa
Merge branch 'master' into upstream/dateonly
SergeiPavlov Jul 12, 2022
d7eb8ad
Some refactoring
SergeiPavlov Jul 20, 2022
cf29f28
Update Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v09/ServerInf…
SergeiPavlov Jul 20, 2022
c9e0948
Code style
SergeiPavlov Jul 20, 2022
97a2dd3
use is null
SergeiPavlov Jul 20, 2022
2e4e002
node.Arguments
SergeiPavlov Jul 20, 2022
4b8160b
Update Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v10/ServerInf…
SergeiPavlov Jul 20, 2022
2a2f92e
Merge branch 'master' into upstream/dateonly
SergeiPavlov Jul 22, 2022
068620e
Merge branch 'master' into upstream/dateonly
SergeiPavlov Nov 28, 2022
bd8f3f4
Merge pull request #251 from servicetitan/upstream/dateonly
alex-kulakov Nov 30, 2022
413bab2
Move TimeOnly and DateOnly compilers to separate files
alex-kulakov Nov 30, 2022
7d41b49
Replace DO_DATEONLY with NET6_0_OR_GREATER
alex-kulakov Nov 30, 2022
58e2a7b
No env var DO_DATEONLY support
alex-kulakov Nov 30, 2022
4a29d38
Add implicit conversion of DateOnly/TimeOnly to SqlExpression
alex-kulakov Dec 1, 2022
f379ba7
SqlDml level changes
alex-kulakov Dec 1, 2022
f6c8b2c
Add Sql-level tests for DateOnly and TimeOnly
alex-kulakov Dec 1, 2022
26bf4ae
SqlType: Fix compilation error for NET5
alex-kulakov Dec 15, 2022
78cfbfb
Define DataTypeInfo for DateOnly/TimeOnlySupport for various providers
alex-kulakov Jan 16, 2023
46cdb51
Add base test class for tests of schema extraction
alex-kulakov Jan 16, 2023
579d70b
Replace old MSSQLExtractor-based test with one class based on Extract…
alex-kulakov Jan 16, 2023
ba11277
Firebird: Fixed FK actions extraction
alex-kulakov Jan 16, 2023
736ba39
ExtractorTest for Firebird
alex-kulakov Jan 16, 2023
46295a4
MSSQLExtractorTest: Use line by line script
alex-kulakov Jan 16, 2023
b641322
ExtractorTest for MySQL
alex-kulakov Jan 17, 2023
dda5a0e
ExtractorTest for Sqlite
alex-kulakov Jan 18, 2023
20e8641
PgSql: extrator tests
alex-kulakov Jan 20, 2023
e88dec1
Oracle: Extractor test
alex-kulakov Jan 21, 2023
6ae309b
Fix typo in class name
alex-kulakov Jan 21, 2023
5d1f69b
PgSql: Full-text Index extraction text
alex-kulakov Jan 21, 2023
b72f821
MySQL extraction imrovements
alex-kulakov Jan 21, 2023
7507117
Oracle schema extraction imrpovements
alex-kulakov Jan 21, 2023
17d02f8
Sqlite : add time and date as data types
alex-kulakov Jan 21, 2023
03e5c63
Sqlite schema extractor improvements
alex-kulakov Jan 21, 2023
051336f
Fixed wrong name of type members' compiler
alex-kulakov Jan 23, 2023
ada49d5
Raw tests for DateOnly/TimeOnly fields/values within Linq
alex-kulakov Jan 23, 2023
b7d49e3
Register DateOnly/Time only member compilers
alex-kulakov Jan 24, 2023
832e8a0
Add DateOnly/TimeOnly as supported types for Min/Max ops
alex-kulakov Jan 24, 2023
d5241aa
TimeOnlyCompilers updated
alex-kulakov Jan 24, 2023
7ee3521
DateOnlyCompilers updated
alex-kulakov Jan 24, 2023
f513f5d
DateTime/DateOnly/TimeOnly ctor usage within LINQ tests
alex-kulakov Jan 27, 2023
86b26be
TimeOnly ctors compilers list updated
alex-kulakov Jan 27, 2023
e26210e
SqlDml: Add DateConstruct/TimeConstruct methods
alex-kulakov Jan 27, 2023
7e52c92
SqlServer: add support for DateConstruct/TimeConstruct
alex-kulakov Jan 27, 2023
6e304c3
Firebird: DateConstruct/TimeConstruct support
alex-kulakov Jan 27, 2023
647daed
MySQL: Add DateConstruct/TimeConstruct functions support
alex-kulakov Jan 28, 2023
3e825c1
Oracle: Add DateConstruct/TimeConstruct functions support
alex-kulakov Jan 29, 2023
a2bbcbc
PgSQL: Add support for DateConstruct/TimeConstruct functions
alex-kulakov Jan 29, 2023
197ce00
Sqlite: Support for DateConstruct/TimeConstruct
alex-kulakov Jan 30, 2023
47eab77
SqlExtract changes
alex-kulakov Feb 2, 2023
005e62d
TimeOnly and DateOnly compilers use their own SqlDml.Extract()
alex-kulakov Feb 2, 2023
9d866ce
Support for DateOnly/TimeOnly parts extraction
alex-kulakov Feb 2, 2023
435abfb
Reminder of certain particularity of using SqlFunctionType
alex-kulakov Feb 2, 2023
ec00730
Several tests fixed, one kept ignored just in case
alex-kulakov Feb 2, 2023
2af4f96
Compilers use dedicated SqlDml methods for Date and Time
alex-kulakov Feb 8, 2023
2d80867
Date/Time operations support
alex-kulakov Feb 14, 2023
3deb380
DateOnly/TimeOnly-related tests for Linq improved
alex-kulakov Feb 14, 2023
abca168
Mysql: Fix time extraction
alex-kulakov Feb 20, 2023
efe5a44
Make server side timezone available for tests
alex-kulakov Feb 20, 2023
2ff5b47
Test for data conversion on Schema upgrade
alex-kulakov Feb 20, 2023
edfa2e0
ExpressionProcessor: additional cast to date/time in case of SQLite
alex-kulakov Feb 20, 2023
8d7b8c1
TimeOny/DateOnly parameters formatting for human readable string
alex-kulakov Feb 20, 2023
047a76b
Functions to convert betwee Date/Time/DateTime/DateTimeOffset
alex-kulakov Feb 20, 2023
753d18a
SqlActionTranslator uses new data conversion functions
alex-kulakov Feb 20, 2023
519a8c1
Conversions of date/time/datetime/datetimeoffset values
alex-kulakov Feb 22, 2023
a4b31f3
Fix DateTypeCollection.Add
alex-kulakov Feb 22, 2023
c296cca
Removed unused code
alex-kulakov Feb 22, 2023
ffd0e0d
Ignore Sqlite in certain tests
alex-kulakov Feb 25, 2023
5387951
Sqlite: time resolution increased
alex-kulakov Feb 25, 2023
f76b4c7
Remove TimeOnly/DateOnly reading from test
alex-kulakov Feb 25, 2023
6a6ff05
Upgrade to SqlClient 5.1.0 with DateOnly/TimeOnly support
SergeiPavlov Feb 27, 2023
15e1d94
TestHelper: DateTime precision workarouds for Oracle/Mysql
alex-kulakov Feb 27, 2023
2a3f91d
Update StorageProviderVersion with new items
alex-kulakov Feb 27, 2023
312f8d0
Test for DateTime and TimeOnly values with microseconds
alex-kulakov Feb 27, 2023
376d78a
Tests for default values and type compatibility
alex-kulakov Feb 27, 2023
fd88cce
Field default values of DateOnly/TimeOnly support
alex-kulakov Feb 27, 2023
9f8453e
Oracle: Fix wrong interval usage
alex-kulakov Feb 27, 2023
059d798
Increased precision of time for Firebird and Oracle
alex-kulakov Feb 27, 2023
c1c1d14
Mysql: Fix wrong type of value range for DateOnly
alex-kulakov Feb 27, 2023
fa3651a
Mysql: Change time parameters usage in queries
alex-kulakov Feb 28, 2023
faf05fa
Fixed some sql tests for PostgreSQL
alex-kulakov Feb 28, 2023
11857bb
PgSQL: Make_timestamp with integer hour and minute
alex-kulakov Mar 1, 2023
578b3fa
DateTime/TimeOnly values adjusting for test purposes changed
alex-kulakov Mar 1, 2023
c70c497
Some tricky operations with datetime fractions changed
alex-kulakov Mar 2, 2023
ef53315
Remove DO_DATEONLY mark
alex-kulakov Mar 3, 2023
fe72637
TimeOnlyCompilers: No compiler for TimeOnly.Ticks
alex-kulakov Mar 6, 2023
192b829
Merge branch 'master' into master-date-and-time-support
alex-kulakov Mar 6, 2023
272c622
Merge branch 'master-date-and-time-support' into upstream/UpgradeSqlC…
SergeiPavlov Mar 7, 2023
921490a
Override Bind/Read in SqlServer's TypeMapper only
SergeiPavlov Mar 7, 2023
0c90eed
Fix formatting
SergeiPavlov Mar 7, 2023
0732719
Improve changlog
alex-kulakov Mar 7, 2023
1a0b7f2
Merge pull request #304 from servicetitan/upstream/UpgradeSqlClient
alex-kulakov Mar 7, 2023
e19c329
Put Read methods to correct place within class
alex-kulakov Mar 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog/7.1.0-RC-dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[main] Add support for new .NET 6 DateOnly and TimeOnly types
[main] Updated BitFaster.Caching package reference to v2.0.0
[sqlserver] Updated Microsoft.Data.SqlClient package reference to v5.0.0
2 changes: 1 addition & 1 deletion Extensions/TestCommon/TestCommon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
<None Include="Readme.txt" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Orm\Xtensive.Orm\Xtensive.Orm.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Orm\Xtensive.Orm\Xtensive.Orm.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Xtensive.Orm.Web/Xtensive.Orm.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
Expand Down
4 changes: 4 additions & 0 deletions Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ internal static class Constants

// cannot use "FFF" cause it may lead to empty string for fractions part.
public const string DateTimeFormatString = @"''\'yyyy\.MM\.dd HH\:mm\:ss\.fff\'''";
#if NET6_0_OR_GREATER
public const string DateFormatString = @"''\'yyyy\.MM\.dd\'''";
public const string TimeFormatString = @"''\'HH\:mm\:ss\.ffff\'''";
#endif
}
}
143 changes: 130 additions & 13 deletions Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v2_5/Compiler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2011-2022 Xtensive LLC.
// Copyright (C) 2011-2023 Xtensive LLC.
// This code is distributed under MIT license terms.
// See the License.txt file in the project root for more information.
// Created by: Csaba Beer
Expand Down Expand Up @@ -101,6 +101,31 @@ public override void Visit(SqlExtract node)
Visit(CastToLong(node.Operand));
return;
}
#if NET6_0_OR_GREATER
if (((node.IsDatePart && node.DatePart == SqlDatePart.DayOfYear)
|| (node.IsDateTimePart && node.DateTimePart == SqlDateTimePart.DayOfYear))) {
if (!case_SqlDateTimePart_DayOfYear) {
case_SqlDateTimePart_DayOfYear = true;
Visit(SqlDml.Add(node, SqlDml.Literal(1)));
case_SqlDateTimePart_DayOfYear = false;
}
else {
base.Visit(node);
}
return;
}
else if (node.IsSecondExtraction) {
if (!case_SqlDateTimePart_Second) {
case_SqlDateTimePart_Second = true;
Visit(SqlDml.Truncate(node));
case_SqlDateTimePart_Second = false;
}
else {
base.Visit(node);
}
return;
}
#else
switch (node.DateTimePart) {
case SqlDateTimePart.DayOfYear:
if (!case_SqlDateTimePart_DayOfYear) {
Expand All @@ -123,6 +148,8 @@ public override void Visit(SqlExtract node)
}
return;
}
#endif

base.Visit(node);
}

Expand All @@ -149,6 +176,14 @@ public override void Visit(SqlBinary node)
case SqlNodeType.DateTimeMinusDateTime:
DateTimeSubtractDateTime(node.Left, node.Right).AcceptVisitor(this);
return;
#if NET6_0_OR_GREATER
case SqlNodeType.TimePlusInterval:
TimeAddInterval(node.Left, node.Right).AcceptVisitor(this);
return;
case SqlNodeType.TimeMinusTime:
TimeSubtractTime(node.Left, node.Right).AcceptVisitor(this);
return;
#endif
case SqlNodeType.Modulo:
Visit(SqlDml.FunctionCall(translator.TranslateToString(SqlNodeType.Modulo), node.Left, node.Right));
return;
Expand All @@ -170,34 +205,84 @@ public override void Visit(SqlBinary node)
/// <inheritdoc/>
public override void Visit(SqlFunctionCall node)
{
var arguments = node.Arguments;

switch (node.FunctionType) {
case SqlFunctionType.Concat:
Visit(SqlDml.Concat(node.Arguments.ToArray(node.Arguments.Count)));
Visit(SqlDml.Concat(arguments.ToArray(node.Arguments.Count)));
return;
case SqlFunctionType.DateTimeTruncate:
Visit(SqlDml.Cast(node.Arguments[0], new SqlValueType("Date")));
Visit(SqlDml.Cast(arguments[0], new SqlValueType("Date")));
return;
case SqlFunctionType.IntervalToMilliseconds:
Visit(CastToLong(node.Arguments[0]) / NanosecondsPerMillisecond);
Visit(CastToLong(arguments[0]) / NanosecondsPerMillisecond);
return;
case SqlFunctionType.IntervalConstruct:
case SqlFunctionType.IntervalToNanoseconds:
Visit(CastToLong(node.Arguments[0]));
Visit(CastToLong(arguments[0]));
return;
case SqlFunctionType.DateTimeAddMonths:
Visit(DateAddMonth(node.Arguments[0], node.Arguments[1]));
Visit(DateAddMonth(arguments[0], arguments[1]));
return;
case SqlFunctionType.DateTimeAddYears:
Visit(DateAddYear(node.Arguments[0], node.Arguments[1]));
Visit(DateAddYear(arguments[0], arguments[1]));
return;
case SqlFunctionType.DateTimeConstruct:
Visit(DateAddDay(DateAddMonth(DateAddYear(SqlDml.Cast(SqlDml.Literal(new DateTime(2001, 1, 1)), SqlType.DateTime),
node.Arguments[0] - 2001),
node.Arguments[1] - 1),
node.Arguments[2] - 1));
arguments[0] - 2001),
arguments[1] - 1),
arguments[2] - 1));
return;
#if NET6_0_OR_GREATER
case SqlFunctionType.DateAddYears:
Visit(DateAddYear(arguments[0], arguments[1]));
return;
case SqlFunctionType.DateAddMonths:
Visit(DateAddMonth(arguments[0], arguments[1]));
return;
case SqlFunctionType.DateAddDays:
Visit(DateAddDay(arguments[0], arguments[1]));
return;
case SqlFunctionType.DateConstruct:
Visit(DateAddDay(DateAddMonth(DateAddYear(SqlDml.Cast(SqlDml.Literal(new DateOnly(2001, 1, 1)), SqlType.Date),
arguments[0] - 2001),
arguments[1] - 1),
arguments[2] - 1));
return;
case SqlFunctionType.TimeAddHours:
Visit(DateAddHour(node.Arguments[0], node.Arguments[1]));
return;
case SqlFunctionType.TimeAddMinutes:
Visit(DateAddMinute(node.Arguments[0], node.Arguments[1]));
return;
case SqlFunctionType.TimeConstruct:
Visit(DateAddMillisecond(DateAddSecond(DateAddMinute(DateAddHour(SqlDml.Cast(SqlDml.Literal(new TimeOnly(0, 0, 0)), SqlType.Time),
arguments[0]),
arguments[1]),
arguments[2]),
arguments[3]));
return;
case SqlFunctionType.DateToString:
Visit(DateToString(arguments[0]));
return;
case SqlFunctionType.TimeToString:
Visit(TimeToString(arguments[0]));
return;
case SqlFunctionType.DateToDateTime:
DateToDateTime(arguments[0]).AcceptVisitor(this);
return;
case SqlFunctionType.DateTimeToDate:
DateTimeToDate(arguments[0]).AcceptVisitor(this);
return;
case SqlFunctionType.DateTimeToTime:
DateTimeToTime(arguments[0]).AcceptVisitor(this);
return;
case SqlFunctionType.TimeToDateTime:
TimeToDateTime(arguments[0]).AcceptVisitor(this);
return;
#endif
case SqlFunctionType.DateTimeToStringIso:
Visit(DateTimeToStringIso(node.Arguments[0]));
Visit(DateTimeToStringIso(arguments[0]));
return;
}

Expand All @@ -223,6 +308,15 @@ protected static SqlExpression DateTimeSubtractDateTime(SqlExpression date1, Sql
(CastToLong(DateDiffMillisecond(DateAddDay(date2, DateDiffDay(date2, date1)), date1)) *
NanosecondsPerMillisecond);
}
#if NET6_0_OR_GREATER

protected static SqlExpression TimeSubtractTime(SqlExpression time1, SqlExpression time2)
{
return SqlDml.Modulo(
NanosecondsPerDay + CastToLong(DateDiffMillisecond(time2, time1)) * NanosecondsPerMillisecond,
NanosecondsPerDay);
}
#endif

protected static SqlExpression DateTimeAddInterval(SqlExpression date, SqlExpression interval)
{
Expand All @@ -231,6 +325,9 @@ protected static SqlExpression DateTimeAddInterval(SqlExpression date, SqlExpres
(interval / NanosecondsPerMillisecond) % (MillisecondsPerDay));
}

protected static SqlExpression TimeAddInterval(SqlExpression time, SqlExpression interval) =>
DateAddMillisecond(time, (interval / NanosecondsPerMillisecond) % (MillisecondsPerDay));

protected static SqlCast CastToLong(SqlExpression arg) => SqlDml.Cast(arg, SqlType.Int64);

protected static SqlUserFunctionCall DateDiffDay(SqlExpression date1, SqlExpression date2) =>
Expand Down Expand Up @@ -271,6 +368,26 @@ protected static SqlUserFunctionCall BitXor(SqlExpression left, SqlExpression ri

protected static SqlUserFunctionCall BitNot(SqlExpression operand) =>
SqlDml.FunctionCall("BIN_NOT", operand);
#if NET6_0_OR_GREATER

protected static SqlExpression TimeToDateTime(SqlExpression time) =>
SqlDml.Cast(time, SqlType.DateTime);

protected static SqlExpression DateTimeToTime(SqlExpression dateTime) =>
SqlDml.Cast(dateTime, SqlType.Time);

protected static SqlExpression DateToDateTime(SqlExpression date) =>
SqlDml.Cast(date, SqlType.DateTime);

protected static SqlExpression DateTimeToDate(SqlExpression dateTime) =>
SqlDml.Cast(dateTime, SqlType.Date);

protected static SqlFunctionCall DateToString(SqlExpression date) =>
SqlDml.Substring(date, 0, 10);

protected static SqlConcat TimeToString(SqlExpression time) =>
SqlDml.Concat(SqlDml.Substring(time, 0, 12), SqlDml.Literal("0000"));
#endif

protected static SqlConcat DateTimeToStringIso(SqlExpression dateTime)
{
Expand All @@ -279,8 +396,8 @@ protected static SqlConcat DateTimeToStringIso(SqlExpression dateTime)

return SqlDml.Concat(date, SqlDml.Literal("T"), time);
}
#endregion

#endregion

protected internal Compiler(SqlDriver driver)
: base(driver)
Expand Down
36 changes: 18 additions & 18 deletions Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v2_5/Extractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ private static void ReadForeignKeyColumnData(DbDataReader reader, ref ForeignKey
state.ReferencingTable = state.ReferencingSchema.Tables[reader.GetString(1).Trim()];
state.ForeignKey = state.ReferencingTable.CreateForeignKey(reader.GetString(2).Trim());
ReadConstraintProperties(state.ForeignKey, reader, 3, 4);
ReadCascadeAction(state.ForeignKey, reader, 5);
ReadCascadeAction(state.ForeignKey, reader, 5, 12);
state.ReferencedTable = state.ReferencedSchema.Tables[reader.GetString(9).Trim()];
state.ForeignKey.ReferencedTable = state.ReferencedTable;
}
Expand Down Expand Up @@ -618,25 +618,25 @@ private static void ReadConstraintProperties(Constraint constraint,
constraint.IsInitiallyDeferred = ReadStringOrNull(row, isInitiallyDeferredIndex) == "YES";
}

private static void ReadCascadeAction(ForeignKey foreignKey, IDataRecord row, int deleteRuleIndex)
private static void ReadCascadeAction(ForeignKey foreignKey, IDataRecord row, int deleteRuleIndex, int updateRuleIndex)
{
var deleteRule = ReadStringOrNull(row, deleteRuleIndex);
switch (deleteRule) {
case "CASCADE":
foreignKey.OnDelete = ReferentialAction.Cascade;
return;
case "SET NULL":
foreignKey.OnDelete = ReferentialAction.SetNull;
return;
case "NO ACTION":
foreignKey.OnDelete = ReferentialAction.NoAction;
return;
case "RESTRICT": // behaves like NO ACTION
foreignKey.OnDelete = ReferentialAction.NoAction;
return;
case "SET DEFAULT":
foreignKey.OnDelete = ReferentialAction.SetDefault;
return;
foreignKey.OnDelete = GetRefAction(deleteRule);

var updateRule = ReadStringOrNull(row, updateRuleIndex);
foreignKey.OnUpdate = GetRefAction(updateRule);


static ReferentialAction GetRefAction(in string rawActionName)
{
return rawActionName switch {
"CASCADE" => ReferentialAction.Cascade,
"SET NULL" => ReferentialAction.SetNull,
"NO ACTION" => ReferentialAction.NoAction,
"RESTRICT" => ReferentialAction.NoAction,
"SET DEFAULT" => ReferentialAction.SetDefault,
_ => throw new ArgumentOutOfRangeException()
};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ public override DataTypeCollection GetDataTypesInfo()

dtc.DateTime = DataTypeInfo.Range(SqlType.DateTime, commonFeatures,
ValueRange.DateTime, "timestamp");
#if NET6_0_OR_GREATER

dtc.DateOnly = DataTypeInfo.Range(SqlType.Date, commonFeatures, ValueRange.DateOnly, "date");
dtc.TimeOnly = DataTypeInfo.Range(SqlType.Time, commonFeatures, ValueRange.TimeOnly, "time");
#endif

dtc.Char = DataTypeInfo.Stream(SqlType.Char, commonFeatures, MaxCharLength, "char");
dtc.VarChar = DataTypeInfo.Stream(SqlType.VarChar, commonFeatures, MaxCharLength, "varchar");
Expand Down
Loading