Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vinstah opened this issue Nov 14, 2019 · 6 comments
Closed

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

vinstah opened this issue Nov 14, 2019 · 6 comments

Comments

@vinstah
Copy link

vinstah commented Nov 14, 2019

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

@emteknetnz
Copy link
Member

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

@emteknetnz
Copy link
Member

Note quite sure why this closed

@emteknetnz emteknetnz reopened this Jun 1, 2022
@vinstah
Copy link
Author

vinstah commented Jun 1, 2022

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
Copy link
Member

wilr commented Jun 1, 2022

@emteknetnz Closed because its fixed in my commit

@wilr wilr closed this as completed Jun 1, 2022
@emteknetnz
Copy link
Member

This PR hasn't been merged yet

@emteknetnz emteknetnz reopened this Jun 2, 2022
@emteknetnz
Copy link
Member

Linked PR has been merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants