Skip to content

Fixes TimeSpan.Ticks extraction problem #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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.0.3_dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[sqlserver] Fixed TimeSpan.Ticks extraction problem
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override void Visit(SqlFunctionCall node)
// we have to use time consuming algorithm here because
// DATEDIFF_BIG can throw arithmetic overflow on nanoseconds
// so we should handle it by this big formula
Visit(CastToLong(DateTimeSubtractDateTimeExpensive(binary.Right, binary.Left)));
Visit(CastToLong(DateTimeSubtractDateTimeExpensive(binary.Left, binary.Right)));
}
else {
base.Visit(node);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2016-2021 Xtensive LLC.
// Copyright (C) 2016-2022 Xtensive LLC.
// This code is distributed under MIT license terms.
// See the License.txt file in the project root for more information.
// Created by: Alex Groznov
Expand Down Expand Up @@ -188,5 +188,14 @@ public void ExtractDayOfWeekTest()
RunWrongTest<SingleDateTimeEntity>(c => c.NullableDateTime.Value.DayOfWeek == WrongDateTime.DayOfWeek);
});
}

[Test]
public void ExtractTimeOfDayTicksTest()
{
ExecuteInsideSession(() => {
RunTest<SingleDateTimeEntity>(c => c.DateTime.TimeOfDay.Ticks == FirstDateTime.TimeOfDay.Ticks);
RunWrongTest<SingleDateTimeEntity>(c => c.DateTime.TimeOfDay.Ticks < FirstDateTime.TimeOfDay.Ticks);
});
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2016-2021 Xtensive LLC.
// Copyright (C) 2016-2022 Xtensive LLC.
// This code is distributed under MIT license terms.
// See the License.txt file in the project root for more information.
// Created by: Alex Groznov
Expand Down Expand Up @@ -189,6 +189,18 @@ public void ExtractTimeOfDayWithMillisecondsTest()
});
}

[Test]
public void ExtractTimeOfDayTicksTest()
{
ExecuteInsideSession(() => {
var firstDateTimeOffset = TryMoveToLocalTimeZone(FirstDateTimeOffset);
RunTest<SingleDateTimeOffsetEntity>(c => c.DateTimeOffset.TimeOfDay.Ticks == firstDateTimeOffset.TimeOfDay.Ticks);

var wrongDateTimeOffset = TryMoveToLocalTimeZone(WrongDateTimeOffset);
RunWrongTest<SingleDateTimeOffsetEntity>(c => c.DateTimeOffset.TimeOfDay.Ticks == wrongDateTimeOffset.TimeOfDay.Ticks);
});
}

[Test]
public void ExtractTimeOfDayOfNullableValueTest()
{
Expand Down