silverstripe/silverstripe-tagfield

issue when using Taxonomies, need a error suggestion/ add to docs

Closed this issue · 6 comments

When using a simple $many_many to TaxonomyTerm I get the error

[Emergency] Uncaught SilverStripe\ORM\Connect\DatabaseException: Couldn't run query: SELECT AS "Title", "TaxonomyTerm"."Sort" AS "_SortColumn0" FROM "TaxonomyTerm" INNER JOIN "ProductPage_Tags" ON "ProductPage_Tags"."TaxonomyTermID" = "TaxonomyTerm"."ID" WHERE ("ProductPage_Tags"."ProductPageID" = ?) ORDER BY "_SortColumn0" ASC


private static $many_many =  [
     'Tags'    => TaxonomyTerm::class,
];

TagField::create(
  'Tags',
  'Tags',
  TaxonomyTerm::get(),
  $this->Tags()
)

The problem isn't immediately obvious as the TagField is looking for TaxonomyTerm.Title which doesn't exist, I had to hunt through the code to find the constructor had an extra param for title field

public function __construct($name, $title = '', $source = [], $value = null, $titleField = 'Title')

PRs

Hi, thanks for submitting this

Could you please clarify the error you're getting. It seems as though the SQL you've supplied above is missing the error that MySQL is throwing e.g. "Missing column xyz"

Also, if you had any ideas around a proposed solution, that would also be helpful

Note quite sure why this closed

I only got notified today about this missed the comment for 3 years,

looks like @wilr closed this since they updated the docs which would prevent the error by using ->setTitleField('Name');

wilr commented

@emteknetnz Closed because its fixed in my commit

This PR hasn't been merged yet

Linked PR has been merged