From d738dd7decb19d46404d258b55851264e10fab37 Mon Sep 17 00:00:00 2001 From: Matthias Keck Date: Wed, 10 Apr 2024 08:47:33 +0200 Subject: [PATCH 1/2] Lowercases query term for lowercased SQLDirectory field - uppercase will never return a result here Fixes: SIRI-951 --- .../sirius/biz/storage/layer2/jdbc/SQLBlobStorageSpace.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/sirius/biz/storage/layer2/jdbc/SQLBlobStorageSpace.java b/src/main/java/sirius/biz/storage/layer2/jdbc/SQLBlobStorageSpace.java index 1429583b6..746507c8e 100644 --- a/src/main/java/sirius/biz/storage/layer2/jdbc/SQLBlobStorageSpace.java +++ b/src/main/java/sirius/biz/storage/layer2/jdbc/SQLBlobStorageSpace.java @@ -31,6 +31,7 @@ import sirius.kernel.commons.Files; import sirius.kernel.commons.Strings; import sirius.kernel.commons.Tuple; +import sirius.kernel.commons.Value; import sirius.kernel.di.std.Part; import sirius.kernel.health.Exceptions; import sirius.kernel.nls.NLS; @@ -661,7 +662,7 @@ protected void listChildDirectories(SQLDirectory parent, .eq(SQLDirectory.COMMITTED, true) .eq(SQLDirectory.DELETED, false) .where(OMA.FILTERS.like(SQLDirectory.NORMALIZED_DIRECTORY_NAME) - .startsWith(prefixFilter) + .startsWith(Value.of(prefixFilter).toLowerCase()) .ignoreEmpty() .build()) .limit(maxResults) From 4e72174ede66bda0ba1e31b555ed62390fbdf7e9 Mon Sep 17 00:00:00 2001 From: Matthias Keck Date: Wed, 10 Apr 2024 08:50:12 +0200 Subject: [PATCH 2/2] Use lowercase annotation at layer2 directories - stay consistent with the blob implementations - maybe future usages will also profit from optimized queries Fixes: SIRI-951 --- .../java/sirius/biz/storage/layer2/jdbc/SQLDirectory.java | 4 +++- .../java/sirius/biz/storage/layer2/mongo/MongoDirectory.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/sirius/biz/storage/layer2/jdbc/SQLDirectory.java b/src/main/java/sirius/biz/storage/layer2/jdbc/SQLDirectory.java index dcd4b712f..fd82f00ce 100644 --- a/src/main/java/sirius/biz/storage/layer2/jdbc/SQLDirectory.java +++ b/src/main/java/sirius/biz/storage/layer2/jdbc/SQLDirectory.java @@ -20,6 +20,7 @@ import sirius.db.mixing.annotations.BeforeSave; import sirius.db.mixing.annotations.Index; import sirius.db.mixing.annotations.Length; +import sirius.db.mixing.annotations.LowerCase; import sirius.db.mixing.annotations.NullAllowed; import sirius.db.mixing.annotations.Transient; import sirius.db.mixing.types.BaseEntityRef; @@ -76,6 +77,7 @@ public class SQLDirectory extends SQLEntity implements Directory, OptimisticCrea */ public static final Mapping NORMALIZED_DIRECTORY_NAME = Mapping.named("normalizedDirectoryName"); @Length(255) + @LowerCase @NullAllowed private String normalizedDirectoryName; @@ -131,7 +133,7 @@ protected void beforeSave() { if (Strings.isFilled(directoryName)) { this.directoryName = storageUtils.sanitizePath(directoryName); if (Strings.isFilled(directoryName)) { - this.normalizedDirectoryName = directoryName.toLowerCase(); + this.normalizedDirectoryName = directoryName; } else { this.directoryName = null; this.normalizedDirectoryName = null; diff --git a/src/main/java/sirius/biz/storage/layer2/mongo/MongoDirectory.java b/src/main/java/sirius/biz/storage/layer2/mongo/MongoDirectory.java index e3067816a..af2d7568f 100644 --- a/src/main/java/sirius/biz/storage/layer2/mongo/MongoDirectory.java +++ b/src/main/java/sirius/biz/storage/layer2/mongo/MongoDirectory.java @@ -17,6 +17,7 @@ import sirius.db.mixing.Mapping; import sirius.db.mixing.annotations.BeforeSave; import sirius.db.mixing.annotations.Index; +import sirius.db.mixing.annotations.LowerCase; import sirius.db.mixing.annotations.NullAllowed; import sirius.db.mixing.annotations.Transient; import sirius.db.mixing.types.BaseEntityRef; @@ -78,6 +79,7 @@ public class MongoDirectory extends MongoEntity implements Directory, Optimistic */ public static final Mapping NORMALIZED_DIRECTORY_NAME = Mapping.named("normalizedDirectoryName"); @NullAllowed + @LowerCase private String normalizedDirectoryName; /** @@ -131,7 +133,7 @@ protected void beforeSave() { if (Strings.isFilled(directoryName)) { this.directoryName = storageUtils.sanitizePath(directoryName); if (Strings.isFilled(directoryName)) { - this.normalizedDirectoryName = directoryName.toLowerCase(); + this.normalizedDirectoryName = directoryName; } else { this.directoryName = null; this.normalizedDirectoryName = null;