Page MenuHomePhabricator

cargo query error with list storage type and table aliases
Closed, ResolvedPublic

Description

If you have a table with a list storage type List of (,) Wikitext String let's say, and you alias the table, the auto-inserted ORDER BY will not use the table alias and will fail.

{{#cargo_query:
tables=Contacts=c
|fields=_pageName,Role
|where=c.`Username` = 'Ofbeaton'
|format=table
}}

this fails with a Unknown column 'cargo__Contacts.Role__full' in 'order clause' error.

If you remove the table alias, it works.

This is on MySQL 5.7

Event Timeline

Ofbeaton created this task.Feb 18 2019, 7:58 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 18 2019, 7:58 PM
Ofbeaton updated the task description. (Show Details)Feb 18 2019, 8:00 PM

This error doesn't seem consistent, some of my queries with the list work, but the above one does not.

here's the full SQL generated by the above query:

SELECT `_pagename` AS `_pageName`,`Role__full` AS `Role`
FROM `cargo__Contacts` `c`
WHERE c.`Username` = 'Ofbeaton' ORDER BY `_pageName`,`cargo__Contacts`.`Role__full` LIMIT 100

If you change `Cargo__Contacts` with c then it works.

Thank you! Looking at the code there, I'm glad I wasn't going crazy and this was a legit bug.

@Nikhil-nk - thanks for this fix!

Zoranzoki21 closed this task as Resolved.Feb 20 2019, 12:51 AM
Zoranzoki21 assigned this task to Nikhil-nk.