Skip to content

Commit

Permalink
Merge pull request #1970 from scireum/mke/SIRI-951_sqldirectory_query
Browse files Browse the repository at this point in the history
SQLdirectory query lowercasing
  • Loading branch information
mkeckmkeck authored Apr 10, 2024
2 parents 7388840 + 4e72174 commit 18036c1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 18036c1

Please sign in to comment.