Skip to content

implements search on null/notnull metadata - #41459

Merged
ArtificialOwl merged 5 commits into
masterfrom
enh/noid/search-metadata-null
Nov 23, 2023
Merged

implements search on null/notnull metadata#41459
ArtificialOwl merged 5 commits into
masterfrom
enh/noid/search-metadata-null

Conversation

@ArtificialOwl

@ArtificialOwlArtificialOwl commented Nov 14, 2023

Copy link
Copy Markdown
Member

Add the possiblity to search on null/not null value on metadata.
This is a test-feature for the Photos App.

This PR requires to add this line

 '{DAV:}is-defined' => Operator::class,

in https://github.com/nextcloud/3rdparty/blob/master/icewind/searchdav/src/DAV/QueryParser.php#L78

[...]
<d:where>
<d:and>
<d:not>
<d:is-defined>
<d:prop><nc:metadata-test/></d:prop>
</d:is-defined>
</d:not>
</d:and>
[...]

Need:

Comment threadapps/dav/lib/Files/FileSearchBackend.php Fixed
Comment threadapps/dav/lib/Files/FileSearchBackend.php Fixed

@artongeartonge left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Comment threadlib/private/Files/Cache/SearchBuilder.php Outdated
Comment threadapps/dav/lib/Files/FileSearchBackend.php Outdated
Comment threadapps/dav/lib/Files/FileSearchBackend.php Fixed
Comment threadapps/dav/lib/Files/FileSearchBackend.php Fixed
@ArtificialOwl
ArtificialOwlforce-pushed the enh/noid/search-metadata-null branch from b77e16c to 5229965CompareNovember 14, 2023 22:14
@ArtificialOwlArtificialOwl added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Nov 14, 2023
@icewind1991

Copy link
Copy Markdown
Member

might be cleaner to just transform the dav operator to field == null!(field == null) instead of adding a new search operator

@ArtificialOwl
ArtificialOwlforce-pushed the enh/noid/search-metadata-null branch from 5229965 to a091bf0CompareNovember 14, 2023 22:43
Comment threadapps/dav/lib/Files/FileSearchBackend.php Fixed
Comment threadapps/dav/lib/Files/FileSearchBackend.php Fixed
Comment threadapps/dav/lib/Files/FileSearchBackend.php Fixed
Comment threadapps/dav/lib/Files/FileSearchBackend.php Fixed
@artonge

Copy link
Copy Markdown
Collaborator

might be cleaner to just transform the dav operator to field == null!(field == null) instead of adding a new search operator

Do you mean in the DAV request ? The issue is that we are casting the type of the property here:

privatefunctioncastValue(SearchPropertyDefinition$property, $value) {
switch ($property->dataType) {
case SearchPropertyDefinition::DATATYPE_BOOLEAN:
return$value === 'yes';
case SearchPropertyDefinition::DATATYPE_DECIMAL:
case SearchPropertyDefinition::DATATYPE_INTEGER:
case SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER:
return0 + $value;
case SearchPropertyDefinition::DATATYPE_DATETIME:
if (is_numeric($value)) {
returnmax(0, 0 + $value);
}
$date = \DateTime::createFromFormat(\DateTimeInterface::ATOM, (string)$value);
return ($dateinstanceof \DateTime && $date->getTimestamp() !== false) ? $date->getTimestamp() : 0;
default:
return$value;
}
}

And as the property is used in another comparison in the request, it is assumed to be an integer. So using the appropriate operator would be cleaner I think.

@ArtificialOwl
ArtificialOwlforce-pushed the enh/noid/search-metadata-null branch from a091bf0 to ab03a38CompareNovember 15, 2023 21:03
@artonge

Copy link
Copy Markdown
Collaborator

Pushed 3rdparty changes

@ArtificialOwl
ArtificialOwlforce-pushed the enh/noid/search-metadata-null branch from cf5b620 to 1386738CompareNovember 21, 2023 15:18
@solracsfsolracsf added this to the Nextcloud 28 milestone Nov 21, 2023
@blizzzblizzz mentioned this pull request Nov 22, 2023
5 tasks
ArtificialOwland others added 4 commits November 22, 2023 12:43
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Signed-off-by: Louis Chemineau <louis@chmn.me>
Signed-off-by: Louis Chemineau <louis@chmn.me>
Signed-off-by: Louis Chemineau <louis@chmn.me>
@ArtificialOwl
ArtificialOwlforce-pushed the enh/noid/search-metadata-null branch from 1386738 to a93af13CompareNovember 22, 2023 13:43

@ChristophWurstChristophWurst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for the caldav changes

@ArtificialOwl

Copy link
Copy Markdown
MemberAuthor

Working on fixing test.
Since commit ..., the array returned in the response is reordered:

  • "name": "{DAV:}href",
  • "name": "{DAV:}propstat",
  • "name": "{DAV:}status",

(status was before propstat before)

@ArtificialOwl
ArtificialOwlforce-pushed the enh/noid/search-metadata-null branch 3 times, most recently from 8d06f48 to a1d2ac5CompareNovember 23, 2023 01:23
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
@ArtificialOwl
ArtificialOwlforce-pushed the enh/noid/search-metadata-null branch from a1d2ac5 to fbe92d4CompareNovember 23, 2023 01:43
@ArtificialOwl
ArtificialOwl merged commit ee787cd into masterNov 23, 2023
@ArtificialOwl
ArtificialOwl deleted the enh/noid/search-metadata-null branch November 23, 2023 08:52
@ChristophWurstChristophWurst added the pending documentation This pull request needs an associated documentation update label Nov 23, 2023
@ChristophWurst

Copy link
Copy Markdown
Member

adds new public API -> needs docs

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviewspending documentationThis pull request needs an associated documentation update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@ArtificialOwl@icewind1991@artonge@ChristophWurst@AndyScherzinger@github-advanced-security@solracsf