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

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.

Kizule assigned this task to Nikhil-nk.