• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

HicServices / RDMP / 9345549669

03 Jun 2024 06:47AM UTC coverage: 56.558% (-0.002%) from 56.56%
9345549669

push

github

JFriel
Merge branch 'develop' of https://github.com/HicServices/RDMP into release/8.2.0

10763 of 20522 branches covered (52.45%)

Branch coverage included in aggregate %.

152 of 231 new or added lines in 53 files covered. (65.8%)

3 existing lines in 2 files now uncovered.

30662 of 52722 relevant lines covered (58.16%)

7621.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.14
/Rdmp.Core/DataLoad/Engine/Migration/QueryBuilding/MigrationQueryHelper.cs
1
// Copyright (c) The University of Dundee 2018-2019
2
// This file is part of the Research Data Management Platform (RDMP).
3
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5
// You should have received a copy of the GNU General Public License along with RDMP. If not, see <https://www.gnu.org/licenses/>.
6

7
namespace Rdmp.Core.DataLoad.Engine.Migration.QueryBuilding;
8

9
/// <summary>
10
/// Generates the MERGE and UPDATE SQL queries responsible for migrating records from STAGING to LIVE as part of a data load.
11
/// </summary>
12
public abstract class MigrationQueryHelper
13
{
14
    protected readonly MigrationColumnSet ColumnsToMigrate;
15
    protected readonly MigrationColumnSetQueryHelper McsQueryHelper;
16

17
    protected MigrationQueryHelper(MigrationColumnSet columnsToMigrate)
58✔
18
    {
19
        ColumnsToMigrate = columnsToMigrate;
58✔
20
        McsQueryHelper = new MigrationColumnSetQueryHelper(ColumnsToMigrate);
58✔
21
    }
58✔
22

23
    public virtual string CreateUpdateQuery()
24
    {
NEW
25
        return $"WITH ToUpdate AS (SELECT stag.* FROM {ColumnsToMigrate.SourceTable.GetFullyQualifiedName()} AS stag LEFT OUTER JOIN {ColumnsToMigrate.DestinationTable.GetFullyQualifiedName()} AS prod {McsQueryHelper.BuildJoinClause("stag", "prod")} WHERE {McsQueryHelper.BuildPrimaryKeyNotNullTest("stag.")} AND {McsQueryHelper.BuildPrimaryKeyNotNullTest("prod.")} AND EXISTS (SELECT {McsQueryHelper.BuildSelectListForAllColumnsExceptStandard("stag.")} EXCEPT SELECT {McsQueryHelper.BuildSelectListForAllColumnsExceptStandard("prod.")})) {CreateUpdateClause()}";
×
26
    }
27

28
    public string CreateUpdateClause()
29
    {
30
        const string joinTableName = "ToUpdate";
31

NEW
32
        return
×
NEW
33
            $"UPDATE prod SET {BuildUpdateClauseForRow(joinTableName, "prod")} FROM {ColumnsToMigrate.DestinationTable.GetFullyQualifiedName()} AS prod INNER JOIN {joinTableName} {McsQueryHelper.BuildJoinClause(joinTableName, "prod")} SELECT @@ROWCOUNT";
×
34
    }
35

36

37
    public abstract string BuildUpdateClauseForRow(string sourceAlias, string destAlias);
38
    public abstract string BuildInsertClause();
39
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc