Fix case sensitivity on package name lookup (#5524)
* 90% working test
* wip
* Modify test, changelog, add implementation
* Revert "90% working test"
This reverts commit 64a8f1d806
.
* fix typo
* spotless
This commit is contained in:
parent
4070b40fb1
commit
293cd3ef3c
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 5523
|
||||
jira: SMILE-7729
|
||||
title: "Previously, it was possible to store NPM Packages where the package name's case did not match the package ID's case, e.g. `my-package` was different than `MY-PACKAGE`. Names are now normalized to lower case before queries occur."
|
|
@ -28,6 +28,6 @@ import java.util.Optional;
|
|||
|
||||
public interface INpmPackageDao extends JpaRepository<NpmPackageEntity, Long>, IHapiFhirJpaRepository {
|
||||
|
||||
@Query("SELECT p FROM NpmPackageEntity p WHERE p.myPackageId = :id")
|
||||
@Query("SELECT p FROM NpmPackageEntity p WHERE lower(p.myPackageId) = lower(:id)")
|
||||
Optional<NpmPackageEntity> findByPackageId(@Param("id") String thePackageId);
|
||||
}
|
||||
|
|
|
@ -30,10 +30,11 @@ import java.util.Optional;
|
|||
|
||||
public interface INpmPackageVersionDao extends JpaRepository<NpmPackageVersionEntity, Long>, IHapiFhirJpaRepository {
|
||||
|
||||
@Query("SELECT p FROM NpmPackageVersionEntity p WHERE p.myPackageId = :id")
|
||||
@Query("SELECT p FROM NpmPackageVersionEntity p WHERE lower(p.myPackageId) = lower(:id)")
|
||||
Collection<NpmPackageVersionEntity> findByPackageId(@Param("id") String thePackageId);
|
||||
|
||||
@Query("SELECT p FROM NpmPackageVersionEntity p WHERE p.myPackageId = :id AND p.myVersionId = :version")
|
||||
@Query(
|
||||
"SELECT p FROM NpmPackageVersionEntity p WHERE lower(p.myPackageId) = lower(:id) AND p.myVersionId = :version")
|
||||
Optional<NpmPackageVersionEntity> findByPackageIdAndVersion(
|
||||
@Param("id") String thePackageId, @Param("version") String thePackageVersion);
|
||||
|
||||
|
@ -41,7 +42,7 @@ public interface INpmPackageVersionDao extends JpaRepository<NpmPackageVersionEn
|
|||
* Uses a "like" expression on the version ID
|
||||
*/
|
||||
@Query(
|
||||
"SELECT p.myVersionId FROM NpmPackageVersionEntity p WHERE p.myPackageId = :id AND p.myVersionId like :version")
|
||||
"SELECT p.myVersionId FROM NpmPackageVersionEntity p WHERE lower(p.myPackageId) = lower(:id) AND p.myVersionId like :version")
|
||||
List<String> findVersionIdsByPackageIdAndLikeVersion(
|
||||
@Param("id") String theId, @Param("version") String thePartialVersionString);
|
||||
}
|
||||
|
|
|
@ -177,6 +177,9 @@ public class JpaPackageCacheTest extends BaseJpaR4Test {
|
|||
|
||||
// The package has the ID in lower-case, so for the test we input the first parameter in upper-case & check that no error is thrown
|
||||
assertDoesNotThrow(() -> myPackageCacheManager.addPackageToCache(packageNameUppercase, "0.2.0", stream, "hl7.fhir.us.davinci-cdex"));
|
||||
|
||||
// Ensure uninstalling it also works!
|
||||
assertDoesNotThrow(() -> myPackageCacheManager.uninstallPackage(packageNameUppercase, "0.2.0"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue