Unable to Perform one to many join
Unable to Perform one to many join

Link to test case:
Debugger code (debug.datatables.net):
->join(
Mjoin::inst('workSites')
//->name('w')
->link('a.announcementID','announcementsToWorkSites.announcementID')
->link('workSites.workSiteID','announcementsToWorkSites.workSiteID')
->fields(
Field::inst('locationName')
)
)
Error messages shown:
DataTables warning: table id=announcementsListing - Join was performed on the field 'announcementID' which was not included in the Editor field list. The join field must be included as a regular field in the Editor instance.
Description of problem:
Trying to execute a one to many join for an announcement table using data tables, but it refuses to work. Any idea why?
Answers
Well, the error message says it clearly: You need to include the field "a.announcementID" in the field list of the Editor containing the MJoin. Please use Markdown as described below to highlight your code.
Sorry about that, I excluded the full code and forgot to do the markdown
As you can see, a.announcementID is already included, which is what has me so confused as to why it 'throwing that error
My apologies for not having the clearest first initial post
Mmmm ... weird!
I have this is in my code - and it has been working for years now:
The only differences I can see is that
- I don't have my primary table aliased
- My id fields are called "id"
The first difference might cause the issue. Maybe Mjoin doesn't "like" aliased table names?!
Apart from that maybe @allan has an idea?
I'm reasonably sure it is going to be the alias that is causing the issue. If you replace
'announcements AS a'
with'announcements'
and update the variousa
references, I suspect it will work immediately.I'll take more of a look into this.
Allan
Thank you!
I'll remove the alias for my table for now then and see how it works while waiting for the results of you looking into it