Skip to content
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
3 changes: 2 additions & 1 deletion ChangeLog/7.2.2-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
[main] QueryEndpoint.SingleAsync()/SingleOrDefaultAsync() get overloads that can recieve one key value as parameter without need to create array explicitly
[main] PrefetchQuery<T> implements IAsyncEnumerable<T>, extra call for .AsAsyncEmumerable() is not needed for async enumeration
[main] PrefetchQuery<T>.AsAsyncEmumerable() is marked as Obsolete
[main] Support for C#14+ optimization that applies ReadOnlySpan<T>.Contains() extension instead of IEnumerable<T>.Contains() one to arrays
[main] Support for C#14+ optimization that applies ReadOnlySpan<T>.Contains() extension instead of IEnumerable<T>.Contains() one to arrays
[main] Compatibility with VB and FSharp improved
12 changes: 6 additions & 6 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@
<TargetFrameworks Condition="'$(TargetFrameworks)'==''">net8.0;net7.0;net6.0</TargetFrameworks> <!-- fallback to default -->
</PropertyGroup>

<PropertyGroup Condition = "$(Configuration.Contains('Debug')) == 'true'">
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<PropertyGroup Condition = "$(Configuration.Contains('Debug')) == 'true' AND $(MSBuildProjectName.Contains('Tests.VB')) == 'false'">
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
</PropertyGroup>

<PropertyGroup Condition = "$(Configuration.Contains('Release')) == 'true'">
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
<PropertyGroup Condition = "$(Configuration.Contains('Release')) == 'true' AND $(MSBuildProjectName.Contains('Tests.VB')) == 'false'">
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
</PropertyGroup>

<PropertyGroup>
Expand Down
21 changes: 20 additions & 1 deletion Orm.sln
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NuGetPublish", "Publish\NuG
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Xtensive.Orm.Tests.FSharp", "Orm\Xtensive.Orm.Tests.FSharp\Xtensive.Orm.Tests.FSharp.fsproj", "{A68C90C1-AD82-40FD-A18D-F04923514743}"
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Xtensive.Orm.Tests.VB", "Orm\Xtensive.Orm.Tests.VB\Xtensive.Orm.Tests.VB.vbproj", "{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Debug-NET6|Any CPU = Debug-NET6|Any CPU
Debug-NET7|Any CPU = Debug-NET7|Any CPU
Debug-NET8|Any CPU = Debug-NET8|Any CPU
Release|Any CPU = Release|Any CPU
Release-NET6|Any CPU = Release-NET6|Any CPU
Release-NET7|Any CPU = Release-NET7|Any CPU
Release-NET8|Any CPU = Release-NET8|Any CPU
Expand Down Expand Up @@ -602,6 +604,22 @@ Global
{A68C90C1-AD82-40FD-A18D-F04923514743}.Release-NET7|Any CPU.Build.0 = Release-NET7|Any CPU
{A68C90C1-AD82-40FD-A18D-F04923514743}.Release-NET8|Any CPU.ActiveCfg = Release-NET8|Any CPU
{A68C90C1-AD82-40FD-A18D-F04923514743}.Release-NET8|Any CPU.Build.0 = Release-NET8|Any CPU
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}.Debug-NET6|Any CPU.ActiveCfg = Debug-NET6|Any CPU
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}.Debug-NET6|Any CPU.Build.0 = Debug-NET6|Any CPU
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}.Debug-NET7|Any CPU.ActiveCfg = Debug-NET7|Any CPU
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}.Debug-NET7|Any CPU.Build.0 = Debug-NET7|Any CPU
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}.Debug-NET8|Any CPU.ActiveCfg = Debug-NET8|Any CPU
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}.Debug-NET8|Any CPU.Build.0 = Debug-NET8|Any CPU
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}.Release|Any CPU.Build.0 = Release|Any CPU
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}.Release-NET6|Any CPU.ActiveCfg = Release-NET6|Any CPU
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}.Release-NET6|Any CPU.Build.0 = Release-NET6|Any CPU
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}.Release-NET7|Any CPU.ActiveCfg = Release-NET7|Any CPU
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}.Release-NET7|Any CPU.Build.0 = Release-NET7|Any CPU
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}.Release-NET8|Any CPU.ActiveCfg = Release-NET8|Any CPU
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225}.Release-NET8|Any CPU.Build.0 = Release-NET8|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -638,6 +656,7 @@ Global
{45000ADE-F647-4171-A91A-428CDF682603} = {2302847B-292A-4650-A852-BDED40E1BB1C}
{2CC55F3E-8EA5-4305-8716-D5B944120F82} = {5726BBD8-14F9-4909-B765-3E7709223B61}
{A68C90C1-AD82-40FD-A18D-F04923514743} = {8AAB1719-253A-47D2-970F-1911CFEE84B7}
{C78BE7F5-2B6F-D34B-A2D9-EFA97EEF9225} = {8AAB1719-253A-47D2-970F-1911CFEE84B7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F995719A-8D35-49A3-B271-42898A587F57}
Expand Down
190 changes: 190 additions & 0 deletions Orm/Xtensive.Orm.Tests.FSharp/ArithmeticOperationsCompilersTest.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
module ArithmeticOperationsCompilersTest

open FsUnit
open NUnit.Framework
open Xtensive.Orm
open Xtensive.Orm.Tests
open Model
open Microsoft.FSharp.Linq

[<TestFixture>]
type Fixture() =
inherit AutoBuildTest()

override this.BuildConfiguration() =
let config = base.BuildConfiguration ()
config.Types.Register typeof<X>
config

[<Test>]
member this.AdditionStringTest() =
use session = base.Domain.OpenSession ()
use ts = session.OpenTransaction ()
X (StringField = "John") |> ignore
let alll = session.Query.All<X> ()
let query =
query {
for x in alll do
if (x.StringField + x.StringField) = "JohnJohn" then
yield x
}
let list = query |> Seq.toArray
Assert.That(list.Length, Is.EqualTo(1))
let fetched = list.[0]
Assert.That(fetched.StringField, Is.EqualTo("John"))

[<Test>]
member this.AdditionDateTimeTest() =
use session = base.Domain.OpenSession ()
use ts = session.OpenTransaction ()
X (DateTimeField = new System.DateTime(System.DateTime.Now.Year, 2, 15)) |> ignore
let alll = session.Query.All<X> ()
let query =
query {
for x in alll do
if (x.DateTimeField + System.TimeSpan.FromDays(2)) > new System.DateTime(System.DateTime.Now.Year, 2, 15) then
yield x
}
let list = query |> Seq.toArray
Assert.That(list.Length, Is.EqualTo(1))
let fetched = list.[0]
Assert.That(fetched.DateTimeField, Is.EqualTo(new System.DateTime(System.DateTime.Now.Year, 2, 15)))

[<Test>]
member this.AdditionTimeSpanTest() =
Require.ProviderIsNot (StorageProvider.PostgreSql)
use session = base.Domain.OpenSession ()
use ts = session.OpenTransaction ()
X (TimeSpanField = System.TimeSpan.FromTicks(111222333)) |> ignore
let alll = session.Query.All<X> ()
let query =
query {
for x in alll do
if (x.TimeSpanField + System.TimeSpan.FromDays(2)) > System.TimeSpan.FromTicks(111222333) + System.TimeSpan.FromDays(1) then
yield x
}
let list = query |> Seq.toArray
Assert.That(list.Length, Is.EqualTo(1))
let fetched = list.[0]
Assert.That(fetched.TimeSpanField, Is.EqualTo(System.TimeSpan.FromTicks(111222333)))

[<Test>]
member this.AdditionDecimalTest() =
use session = base.Domain.OpenSession ()
use ts = session.OpenTransaction ()
X (DecimalField = decimal 16.0) |> ignore
let alll = session.Query.All<X> ()
let query =
query {
for x in alll do
if x.DecimalField + x.DecimalField <= decimal 35 then
yield x
}
let list = query |> Seq.toArray
Assert.That(list.Length, Is.EqualTo(1))
let fetched = list.[0]
Assert.That(fetched.DecimalField, Is.EqualTo(decimal 16))

[<Test>]
member this.SubtractionDateTimeTest1() =
use session = base.Domain.OpenSession ()
use ts = session.OpenTransaction ()
X (DateTimeField = new System.DateTime(System.DateTime.Now.Year, 2, 15)) |> ignore
let alll = session.Query.All<X> ()
let query =
query {
for x in alll do
if (x.DateTimeField - System.TimeSpan.FromDays(2)) > new System.DateTime(System.DateTime.Now.Year, 2, 10) then
yield x
}
let list = query |> Seq.toArray
Assert.That(list.Length, Is.EqualTo(1))
let fetched = list.[0]
Assert.That(fetched.DateTimeField, Is.EqualTo(new System.DateTime(System.DateTime.Now.Year, 2, 15)))

[<Test>]
member this.SubtractionDateTimeTest2() =
use session = base.Domain.OpenSession ()
use ts = session.OpenTransaction ()
X (DateTimeField = new System.DateTime(System.DateTime.Now.Year, 2, 15)) |> ignore
let alll = session.Query.All<X> ()
let query =
query {
for x in alll do
if (x.DateTimeField - new System.DateTime(System.DateTime.Now.Year, 2, 10)) > System.TimeSpan.FromDays(2) then
yield x
}
let list = query |> Seq.toArray
Assert.That(list.Length, Is.EqualTo(1))
let fetched = list.[0]
Assert.That(fetched.DateTimeField, Is.EqualTo(new System.DateTime(System.DateTime.Now.Year, 2, 15)))

[<Test>]
member this.SubtractionTimeSpanTest() =
Require.ProviderIsNot (StorageProvider.PostgreSql)
use session = base.Domain.OpenSession ()
use ts = session.OpenTransaction ()
X (TimeSpanField = System.TimeSpan.FromTicks(111222333)) |> ignore
let alll = session.Query.All<X> ()
let query =
query {
for x in alll do
if (x.TimeSpanField - System.TimeSpan.FromTicks(111222)) > System.TimeSpan.FromTicks(111222) then
yield x
}
let list = query |> Seq.toArray
Assert.That(list.Length, Is.EqualTo(1))
let fetched = list.[0]
Assert.That(fetched.TimeSpanField, Is.EqualTo(System.TimeSpan.FromTicks(111222333)))

[<Test>]
member this.SubtractionDecimalTest() =
use session = base.Domain.OpenSession ()
use ts = session.OpenTransaction ()
X (DecimalField = decimal 16.0) |> ignore
let alll = session.Query.All<X> ()
let query =
query {
for x in alll do
if x.DecimalField - x.DecimalField + decimal 3 <= decimal 5 then
yield x
}
let list = query |> Seq.toArray
Assert.That(list.Length, Is.EqualTo(1))
let fetched = list.[0]
Assert.That(fetched.DecimalField, Is.EqualTo(decimal 16))

[<Test>]
member this.MultiplyDecimalTest() =
Require.ProviderIsNot StorageProvider.Firebird
use session = base.Domain.OpenSession ()
use ts = session.OpenTransaction ()
X (DecimalField = decimal 16.0) |> ignore
let alll = session.Query.All<X> ()
let query =
query {
for x in alll do
if x.DecimalField * x.DecimalField <= decimal 350 then
yield x
}
let list = query |> Seq.toArray
Assert.That(list.Length, Is.EqualTo(1))
let fetched = list.[0]
Assert.That(fetched.DecimalField, Is.EqualTo(decimal 16))

[<Test>]
member this.DivideDecimalTest() =
use session = base.Domain.OpenSession ()
use ts = session.OpenTransaction ()
X (DecimalField = decimal 16.0) |> ignore
let alll = session.Query.All<X> ()
let query =
query {
for x in alll do
if x.DecimalField / decimal 2 <= decimal 16 then
yield x
}
let list = query |> Seq.toArray
Assert.That(list.Length, Is.EqualTo(1))
let fetched = list.[0]
Assert.That(fetched.DecimalField, Is.EqualTo(decimal 16))
Loading
Loading