Skip to content

Commit

Permalink
implements search on null/notnull metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Nov 14, 2023
1 parent a2770e0 commit 8eba418
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/dav/lib/Files/FileSearchBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ private function transformSearchOperation(Operator $operator) {
return new SearchComparison($trimmedType, $this->mapPropertyNameToColumn($property), $value);
}

// no break
case Operator::OPERATION_IS_DEFINED:
$property = $operator->arguments[0];
return new SearchComparison('null', substr($property->name, strlen(FilesPlugin::FILE_METADATA_PREFIX)), '', IMetadataQuery::EXTRA);
case Operator::OPERATION_IS_COLLECTION:
return new SearchComparison('eq', 'mimetype', ICacheEntry::DIRECTORY_MIMETYPE);
default:
Expand Down
2 changes: 2 additions & 0 deletions lib/private/Files/Cache/SearchBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class SearchBuilder {
ISearchComparison::COMPARE_GREATER_THAN_EQUAL => 'gte',
ISearchComparison::COMPARE_LESS_THAN => 'lt',
ISearchComparison::COMPARE_LESS_THAN_EQUAL => 'lte',
ISearchComparison::COMPARE_NULL => 'isNull',
];

protected static $searchOperatorNegativeMap = [
Expand All @@ -57,6 +58,7 @@ class SearchBuilder {
ISearchComparison::COMPARE_GREATER_THAN_EQUAL => 'lt',
ISearchComparison::COMPARE_LESS_THAN => 'gte',
ISearchComparison::COMPARE_LESS_THAN_EQUAL => 'gt',
ISearchComparison::COMPARE_NULL => 'isNotNull',
];

public const TAG_FAVORITE = '_$!<Favorite>!$_';
Expand Down
1 change: 1 addition & 0 deletions lib/public/Files/Search/ISearchComparison.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ interface ISearchComparison extends ISearchOperator {
public const COMPARE_LESS_THAN_EQUAL = 'lte';
public const COMPARE_LIKE = 'like';
public const COMPARE_LIKE_CASE_SENSITIVE = 'clike';
public const COMPARE_NULL = 'null';

public const HINT_PATH_EQ_HASH = 'path_eq_hash'; // transform `path = "$path"` into `path_hash = md5("$path")`, on by default

Expand Down

0 comments on commit 8eba418

Please sign in to comment.