[MySQL] Inspection hint: column aliases required for...
I've started getting an inspection hint along the lines of:
column aliases required for 'a(addressid:number, number:number, postcode:number, firstline:number, firstline:string)'
This is apearing at, in this case the table alias for `address` in the update statement below.
UPDATE
`address` a
SET
a.firstline =
(SELECT sf_extractHouseIdent(
GROUP_CONCAT(
l.text
ORDER BY l.addressline SEPARATOR ' '
),
'',
'',
''
) AS firstline
FROM
addresslines l
WHERE a.addressid = l.addressid
GROUP BY l.addressid
ORDER BY l.addressline);
I'm getting similar warnings on tables within select statements when there are multiple `joins`.
Can anyone suggest what the warning actually means?
Please sign in to leave a comment.
Hello.
Could you show your table definitions? I've tried your sample with arbitrary tables and got no warning.
Regards,
Alexander.
Sure thing, no crown jewels in these tables. :)
The stored function does some crunching and gives a hash for each address - the field is called {{firstline}} for historial reasons.
I have discovered some extra information, however, which might need a bit more digging on my part to figure out how to recreate it concidely.
When I copied the statement to a console the warning disappears; so I created a completely fresh sql file and found that on its own the error is not displayed. I surmise that the problem must be due to something else within the sql file - this is over 700 lines long and performing a whole host of updates to a system ranging from adding tables, views and stored programs to rearranging data and eliminating some unused 'temporary' tables.
Okay, after further digging, it is being caused by a previous line.
Allow me to describe the position for this particular table - the {{firstline}} field gets dropped and then recreated before being filled with the calculated hash code... there is quite a lot goes on between those two actions, but the final two actions are sufficient to demonstrate the problem.
With the table definitions commented out, the error is displayed; with the table definitions uncommented, the error goes away.
I was thinking that this was a problem that was being picked up in my code, but maybe I should be logging it in YouTrack as a bug?
Thank you for detailed description. I have reproduced it in a bit different case: when same-named column appears in the table definition _and_ alter statement. Like this:
(Drop column statement is not essential to reproduce, it is added just for "realism", to make the whole script valid.) If the column is mentioned only in the table definition, or only in an alter statement (like in your latter sample), then there is no warning for me. This case really looks like some IDE defect, since the warning is inadequate with suggested conditions.
Do you actually have some similar operations with columns in your script? Some removal or maybe rename?
Thank you,
Alexander.
Hi Alexander,
Yes, all similar warnings are occuring at places where there are fieldnames referenced that also appear in either drop or alter statements further up the file. I have traced each one now and for this to be the case.
I've found something similar with using temporary tables in a stored program too, where the table name appears to get sort of forgotten --- I'm trying to pin down the exact circumstances before I upload it, but that is almost certainly something to go on YouTrack.
I'm sorry for being slow to respond - I'm trying to complete an Open University assignment at the moment and cannot spend as much time on 0xDBE as I'd like to.
Kind regards,
Geoff
Thanks a lot, I think the case is clear enough. Created: https://youtrack.jetbrains.com/issue/DBE-1195
Regards,
Alexander.
Thanks Alexander.