diff --git a/.github/workflows/mac_unit_test_ci.yml b/.github/workflows/mac_unit_test_ci.yml index a915d0d2be5..1feef9d1464 100644 --- a/.github/workflows/mac_unit_test_ci.yml +++ b/.github/workflows/mac_unit_test_ci.yml @@ -11,7 +11,9 @@ jobs: name: Unit Tests steps: - uses: actions/checkout@v4 - - name: Build and test - run: | - dotnet build -c Release -warnaserror /p:TreatWarningsAsErrors=true /p:RunAnalyzers=true - dotnet test -c Release --no-restore --no-build ./test/OrchardCore.Tests/OrchardCore.Tests.csproj + - name: Build + run: dotnet build -c Release -warnaserror /p:TreatWarningsAsErrors=true /p:RunAnalyzers=true + - name: Run Test + run: dotnet test -c Release --no-restore --no-build ./test/OrchardCore.Tests/OrchardCore.Tests.csproj + env: + OrchardCore__OrchardCore_YesSql: true diff --git a/.github/workflows/main_ci.yml b/.github/workflows/main_ci.yml index bee2eb249f5..8dee93da203 100644 --- a/.github/workflows/main_ci.yml +++ b/.github/workflows/main_ci.yml @@ -36,6 +36,8 @@ jobs: - name: Unit Tests run: | dotnet test -c Release --no-build ./test/OrchardCore.Tests/OrchardCore.Tests.csproj + env: + OrchardCore__OrchardCore_YesSql: true - name: Functional Tests if: matrix.os == 'ubuntu-latest' run: | diff --git a/.github/workflows/pr_ci.yml b/.github/workflows/pr_ci.yml index 4e645136ff5..8738212757e 100644 --- a/.github/workflows/pr_ci.yml +++ b/.github/workflows/pr_ci.yml @@ -30,6 +30,8 @@ jobs: - name: Unit Tests run: | dotnet test -c Release --no-build ./test/OrchardCore.Tests/OrchardCore.Tests.csproj + env: + OrchardCore__OrchardCore_YesSql: true - name: Functional Tests if: matrix.os == 'ubuntu-latest' run: | diff --git a/.github/workflows/preview_ci.yml b/.github/workflows/preview_ci.yml index cc7910525ef..0b38de9d7bf 100644 --- a/.github/workflows/preview_ci.yml +++ b/.github/workflows/preview_ci.yml @@ -40,6 +40,8 @@ jobs: if: steps.check-publish.outputs.should-publish == 'true' run: | dotnet test -c Release --no-build ./test/OrchardCore.Tests/OrchardCore.Tests.csproj + env: + OrchardCore__OrchardCore_YesSql: true - name: Functional Tests if: steps.check-publish.outputs.should-publish == 'true' run: | diff --git a/.github/workflows/release_ci.yml b/.github/workflows/release_ci.yml index 6b9b440c45f..5e31b4c5796 100644 --- a/.github/workflows/release_ci.yml +++ b/.github/workflows/release_ci.yml @@ -45,6 +45,8 @@ jobs: - name: Unit Tests run: | dotnet test -c Release --no-build ./test/OrchardCore.Tests/OrchardCore.Tests.csproj + env: + OrchardCore__OrchardCore_YesSql: true - name: Functional Tests if: matrix.os == 'ubuntu-latest' run: | diff --git a/src/OrchardCore.Cms.Web/appsettings.json b/src/OrchardCore.Cms.Web/appsettings.json index 07383b1c9cd..8eab980d4b0 100644 --- a/src/OrchardCore.Cms.Web/appsettings.json +++ b/src/OrchardCore.Cms.Web/appsettings.json @@ -25,6 +25,12 @@ // "DefaultTableNameSeparator": "_", // Table name separator, one or multiple '_', "NULL" means no separator, defaults to '_'. // "DefaultIdentityColumnSize": "Int64" // Identity column size, 'Int32' or 'Int64', defaults to 'Int64'. //}, + // See https://docs.orchardcore.net/en/latest/reference/core/Data/#database-table to configure database table presets used before a given tenant is setup. + //"OrchardCore_YesSql": { + // "CommandsPageSize": 500, + // "QueryGatingEnabled": true, + // "EnableThreadSafetyChecks": false + //}, // See https://docs.orchardcore.net/en/latest/reference/modules/DataProtection.Azure/#configuration to configure data protection key storage in Azure Blob Storage. //"OrchardCore_DataProtection_Azure": { // "ConnectionString": "", // Set to your Azure Storage account connection string. diff --git a/src/OrchardCore/OrchardCore.Data.YesSql/OrchardCoreBuilderExtensions.cs b/src/OrchardCore/OrchardCore.Data.YesSql/OrchardCoreBuilderExtensions.cs index 22b6668eb17..64ed6f979b8 100644 --- a/src/OrchardCore/OrchardCore.Data.YesSql/OrchardCoreBuilderExtensions.cs +++ b/src/OrchardCore/OrchardCore.Data.YesSql/OrchardCoreBuilderExtensions.cs @@ -10,6 +10,7 @@ using OrchardCore.Data.Migration; using OrchardCore.Data.YesSql; using OrchardCore.Environment.Shell; +using OrchardCore.Environment.Shell.Configuration; using OrchardCore.Environment.Shell.Removing; using OrchardCore.Environment.Shell.Scope; using OrchardCore.Json; @@ -37,8 +38,11 @@ public static OrchardCoreBuilder AddDataAccess(this OrchardCoreBuilder builder) { builder.ApplicationServices.AddSingleton(); - builder.ConfigureServices(services => + builder.ConfigureServices((services, serviceProvider) => { + var configuration = serviceProvider.GetService(); + + services.Configure(configuration.GetSection("OrchardCore_YesSql")); services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/src/docs/reference/core/Data/README.md b/src/docs/reference/core/Data/README.md index c57f6ab46df..b5ec5d868b8 100644 --- a/src/docs/reference/core/Data/README.md +++ b/src/docs/reference/core/Data/README.md @@ -36,6 +36,7 @@ OrchardCore uses the `YesSql` library to interact with the configured database p | `IdentifierAccessorFactory` | You can provide your own value accessor factory. | | `VersionAccessorFactory` | You can provide your own version accessor factory. | | `ContentSerializer` | You can provide your own content serializer. | +| `EnableThreadSafetyChecks` | Gets or sets the `EnableThreadSafetyChecks` option in YesSql, which aids in diagnosing concurrency or race condition issues. | For example, you can change the default command-page-size from `500` to `1000` by adding the following code to your startup code. @@ -46,6 +47,15 @@ services.Configure(options => }); ``` +You may configure `CommandsPageSize`, `QueryGatingEnabled`, and `EnableThreadSafetyChecks` options using a configuration provider like `appsettings.json` using the following + +```json +"OrchardCore_YesSql": { + "CommandsPageSize": 500, + "QueryGatingEnabled": true, + "EnableThreadSafetyChecks": false +}, + ## Database table The following database table settings, only used as presets before a given tenant is setup, can be provided from any configuration source. @@ -56,10 +66,10 @@ The following database table settings, only used as presets before a given tenan | `DefaultTableNameSeparator` | Table name separator, one or multiple '_', "NULL" means no separator, defaults to '_'. | | `DefaultIdentityColumnSize` | Identity column size, 'Int32' or 'Int64', defaults to 'Int64'. | -##### `appsettings.json` +#### Configuration Source (ex., `appsettings.json`) ```json - "OrchardCore_Data_TableOptions": { +"OrchardCore_Data_TableOptions": { "DefaultDocumentTable": "Document", "DefaultTableNameSeparator": "_", "DefaultIdentityColumnSize": "Int64"