Closed ashleyfae closed 3 years ago
Hey @ashleyfae. Sorry you ran into this.
Speculating using my fuzzy memory of writing this code, I think it has 2 separate origins.
WP_Meta_Query::find_compatible_table_alias()
.WP_Query
over the years)If that's at all accurate, my current thoughts on them are:
parse_groupby()
is private, so the $alias
parameter could be removed to simply always include them.Related: (parse_fields()
works similarly, but it isn't ever used without aliases.
I recommend we change that false
on line 1392 to $alias
, so that parse_groupby()
matches the results of parse_fields()
when called internally. If the fields include table aliases, the groupby definitely should too.
What do you think?
I recommend we change that
false
on line 1392 to$alias
, so thatparse_groupby()
matches the results ofparse_fields()
when called internally. If the fields include table aliases, the groupby definitely should too.What do you think?
Yep that works!
If you have a
GROUPBY
clause, but you're also joining on a table that just so happens to have that same column name, you can end up with an error like this:This is because the
GROUPBY
column is added to the selected fields here, but specifically without the table alias:https://github.com/berlindb/core/blob/master/query.php#L1392
Note the second parameter for
parse_groupby()
isfalse
, which means the alias is not added as a prefix. Changing that totrue
fixed the issue for me, but I wasn't sure if there was a specific reason it wasfalse
?