Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column 'fileid' in where clause is ambiguous #18313

Closed
tobiasKaminsky opened this issue Dec 10, 2019 · 3 comments · Fixed by #18314
Closed

Column 'fileid' in where clause is ambiguous #18313

tobiasKaminsky opened this issue Dec 10, 2019 · 3 comments · Fixed by #18314

Comments

@tobiasKaminsky
Copy link
Member

This is my webdav search:

<?xml version="1.0" encoding="UTF-8"?>
<d:searchrequest xmlns:d="DAV:" xmlns:oc="http://nextcloud.com/ns">
    <d:basicsearch>
        <d:select>
            <d:prop>
                <d:displayname />
                <d:getcontenttype />
                <d:resourcetype />
                <d:getcontentlength />
                <d:getlastmodified />
                <d:creationdate />
                <d:getetag />
                <d:quota-used-bytes />
                <d:quota-available-bytes />
                <oc:permissions xmlns:oc="http://owncloud.org/ns" />
                <oc:id xmlns:oc="http://owncloud.org/ns" />
                <oc:size xmlns:oc="http://owncloud.org/ns" />
                <oc:favorite xmlns:oc="http://owncloud.org/ns" />
            </d:prop>
        </d:select>
        <d:from>
            <d:scope>
                <d:href>/files/test</d:href>
                <d:depth>infinity</d:depth>
            </d:scope>
        </d:from>
        <d:where>
            <d:eq>
                <d:prop>
                    <oc:fileid xmlns:oc="http://owncloud.org/ns" />
                </d:prop>
                <d:literal>123123</d:literal>
            </d:eq>
        </d:where>
        <d:orderby />
    </d:basicsearch>
</d:searchrequest>

This is the response:

<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
    <s:exception>Doctrine\DBAL\Exception\NonUniqueFieldNameException</s:exception>
    <s:message>An exception occurred while executing 'SELECT `file`.`fileid`, `storage`, `path`, `path_hash`,
        `file`.`parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, `encrypted`, `etag`,
        `permissions`, `checksum`, `metadata_etag`, `creation_time`, `upload_time` FROM `oc_filecache` `file` LEFT JOIN
        `oc_filecache_extended` `fe` ON `file`.`fileid` = `fe`.`fileid` WHERE (`storage` = ?) AND (`fileid` = ?)' with
        params [9, 123123]:

        SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'fileid' in where clause is ambiguous
    </s:message>
</d:error>

This is afaik a regression, as it worked until ~1-2 weeks ago.

@rullzer @icewind1991

@tobiasKaminsky tobiasKaminsky added bug 0. Needs triage Pending check for reproducibility or if it fits our roadmap feature: search and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Dec 10, 2019
@kesselb
Copy link
Contributor

kesselb commented Dec 10, 2019

Index: lib/private/Files/Cache/QuerySearchHelper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- lib/private/Files/Cache/QuerySearchHelper.php	(revision bb8ac6ca34aa84a9c43fb841a863438b025120a1)
+++ lib/private/Files/Cache/QuerySearchHelper.php	(date 1575966999689)
@@ -161,6 +161,8 @@
 			$value = self::TAG_FAVORITE;
 		} else if ($field === 'tagname') {
 			$field = 'tag.category';
+		} else if ($field === 'fileid') {
+			$field = 'file.fileid';
 		}
 		return [$field, $value, $type];
 	}

Should fix it. It's related to the new filecache_extended table.

@tobiasKaminsky
Copy link
Member Author

Indeed, this fixes it 🎉
Will you create a PR, or shall I do it?

@kesselb
Copy link
Contributor

kesselb commented Dec 10, 2019

Would you mind to do it? :)

tobiasKaminsky added a commit that referenced this issue Dec 10, 2019
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants