1- // Copyright (C) 2020 Xtensive LLC.
1+ // Copyright (C) 2020-2024 Xtensive LLC.
22// This code is distributed under MIT license terms.
33// See the License.txt file in the project root for more information.
44// Created by: Alexey Kulakov
@@ -15,9 +15,12 @@ namespace Xtensive.Orm.Tests.Issues.IssueJira0786_SqlServerAggregatesProblem
1515{
1616 public abstract class AggregatesProblemTestBase : AutoBuildTest
1717 {
18- protected const decimal FloatValueAccuracy = 0.000001m ;
19- protected const decimal DoubleValueAccuracy = 0.00000000000001m ;
20- protected const decimal DecimalValueAccuracy = 0.00000000000000001m ;
18+ private bool refillDatabase = false ;
19+
20+ protected decimal FloatValueAccuracy { get ; private set ; } = 0.000001m ;
21+ protected decimal DoubleValueAccuracy { get ; private set ; } = 0.00000000000001m ;
22+ protected decimal DecimalValueAccuracy { get ; private set ; } = 0.00000000000000001m ;
23+
2124
2225 protected override Domain BuildDomain ( DomainConfiguration configuration )
2326 {
@@ -31,6 +34,7 @@ protected override Domain BuildDomain(DomainConfiguration configuration)
3134 throw ;
3235 }
3336
37+ refillDatabase = true ;
3438 var secondTryConfig = configuration . Clone ( ) ;
3539 secondTryConfig . UpgradeMode = DomainUpgradeMode . Recreate ;
3640 return base . BuildDomain ( secondTryConfig ) ;
@@ -44,13 +48,24 @@ protected override DomainConfiguration BuildConfiguration()
4448 return configuration ;
4549 }
4650
47- protected override void CheckRequirements ( )
48- {
49- Require . ProviderIs ( StorageProvider . SqlServer | StorageProvider . PostgreSql ) ;
50- }
51+ protected override void CheckRequirements ( ) => Require . ProviderIs ( StorageProvider . SqlServer | StorageProvider . PostgreSql ) ;
5152
5253 protected override void PopulateData ( )
5354 {
55+ if ( StorageProviderInfo . Instance . CheckProviderIs ( StorageProvider . PostgreSql ) ) {
56+ // We have to change some scales of result values of average in SQL
57+ // because PostgreSQL does not provide ways to read raw value and reduce it
58+ // to fit into .NET decimal value, as we reduce scale for values in MS SQL Server provider.
59+
60+ FloatValueAccuracy = 0.00001m ;
61+ DoubleValueAccuracy = 0.00001m ;
62+ DecimalValueAccuracy = 0.00001m ;
63+ }
64+
65+ if ( ! refillDatabase )
66+ return ;
67+
68+
5469 using ( var session = Domain . OpenSession ( ) )
5570 using ( var tx = session . OpenTransaction ( ) ) {
5671 _ = new TestEntity ( ) {
0 commit comments