From 2b0aef361c4eae4e659f9d5706a47cb492e463d2 Mon Sep 17 00:00:00 2001 From: JohnMcPMS Date: Fri, 11 Oct 2024 10:07:00 -0700 Subject: [PATCH] Make dependency lookup case insensitive (#4866) Fixes #3679 ## Change Makes the dependency lookup case insensitive. ## Validation Adds a new test that exercises adding a package with a dependency that does not match the case of the original package identifier. --- src/AppInstallerCLITests/SQLiteIndex.cpp | 21 +++++++++++++++++++ .../Schema/1_4/DependenciesTable.cpp | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/AppInstallerCLITests/SQLiteIndex.cpp b/src/AppInstallerCLITests/SQLiteIndex.cpp index 12af2a5c9c..97589be506 100644 --- a/src/AppInstallerCLITests/SQLiteIndex.cpp +++ b/src/AppInstallerCLITests/SQLiteIndex.cpp @@ -3835,3 +3835,24 @@ TEST_CASE("SQLiteIndex_V2_0_UsageFlow_ComplexMigration", "[sqliteindex][V2_0]") MigratePrepareAndCheckIntermediates(baseFile, preparedFile, { { manifest2 }, { manifest1, manifest3, manifest4 } }); } + +TEST_CASE("SQLiteIndex_DependencyWithCaseMismatch", "[sqliteindex][V1_4]") +{ + TempFile tempFile{ "repolibtest_tempdb"s, ".db"s }; + INFO("Using temporary file named: " << tempFile.GetPath()); + + Manifest dependencyManifest1, dependencyManifest2, manifest; + SQLiteIndex index = SimpleTestSetup(tempFile, dependencyManifest1, SQLiteVersion::Latest()); + + // Must contain some upper case + auto& publisher2 = "Test2"; + CreateFakeManifest(dependencyManifest2, publisher2); + index.AddManifest(dependencyManifest2, GetPathFromManifest(dependencyManifest2)); + + auto& publisher3 = "Test3"; + CreateFakeManifest(manifest, publisher3); + manifest.Installers[0].Dependencies.Add(Dependency(DependencyType::Package, dependencyManifest1.Id, "1.0.0")); + manifest.Installers[0].Dependencies.Add(Dependency(DependencyType::Package, ToLower(dependencyManifest2.Id), "1.0.0")); + + index.AddManifest(manifest, GetPathFromManifest(manifest)); +} diff --git a/src/AppInstallerRepositoryCore/Microsoft/Schema/1_4/DependenciesTable.cpp b/src/AppInstallerRepositoryCore/Microsoft/Schema/1_4/DependenciesTable.cpp index f421e0b1c3..1741cfae0b 100644 --- a/src/AppInstallerRepositoryCore/Microsoft/Schema/1_4/DependenciesTable.cpp +++ b/src/AppInstallerRepositoryCore/Microsoft/Schema/1_4/DependenciesTable.cpp @@ -70,7 +70,7 @@ namespace AppInstaller::Repository::Microsoft::Schema::V1_4 { installer.Dependencies.ApplyToType(dependencyType, [&](Manifest::Dependency dependency) { - auto packageRowId = IdTable::SelectIdByValue(connection, dependency.Id()); + auto packageRowId = IdTable::SelectIdByValue(connection, dependency.Id(), true); std::optional version; if (!packageRowId.has_value())