awesomemotive / easy-digital-downloads

Sell digital downloads through WordPress
https://easydigitaldownloads.com
GNU General Public License v2.0
863 stars 474 forks source link

Use table alias/name when building date query #9700

Closed jkudish closed 10 months ago

jkudish commented 10 months ago

This PR attempts to fix the issue described in #9699

Use the received table name & table alias arguments in the get_sql function to set those as properties on the Date class. Note that get_sql already gets called with those params as per the line below. However the get_sql function oddly wasn't defining those arguments in its definition.

https://github.com/awesomemotive/easy-digital-downloads/blob/715373d18971c8b12e949bb3fd5d6c40aac6c234/includes/database/engine/class-query.php#L1363

Then, when building the SQL query, use the alias or name (only if available) to prepend to the column name in the query. This prevents ambiguity issues when performing the SQL query

This prevents and fixes the issue described in https://github.com/awesomemotive/easy-digital-downloads/issues/9699

I am open to receiving feedback on the solution proposed and working on an updated solution.

Thanks!

robincornett commented 10 months ago

Hi @jkudish, and thank you so much for looking into this and submitting a PR! I'll check it over locally, but I wanted to ask if you would be willing to also submit the issue and PR over in the BerlinDB repository? Berlin is the package/library we are using to manage our custom database tables, and based on what you're saying, it looks like this is a fix that should be applied in there.

jkudish commented 10 months ago

Apologies for the delay. I've moved this over to https://github.com/berlindb/core/pull/164 as suggested