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

Ambiguous clause when manually setting the parent_id on Category model #332

Open
Repox opened this issue Dec 8, 2020 · 0 comments
Open

Comments

@Repox
Copy link
Contributor

Repox commented Dec 8, 2020

Expected Behavior

When setting the Category model attribute parent_id and save the model, the attribute should be persisted.

Current Behavior

When trying set the Category model attribute parent_id and save the model, it throws an error message:

SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous (SQL: select `categories`.* from `categories` inner join `category_channel` on `categories`.`id` = `category_channel`.`category_id` and `category_channel`.`channel_id` = 1 and date(`category_channel`.`published_at`) <= 2020-12-08 inner join `category_customer_group` on `categories`.`id` = `category_customer_group`.`category_id` and `category_customer_group`.`customer_group_id` in (1) and `category_customer_group`.`visible` = 1 where `categories`.`drafted_at` is null and `id` = 4 group by `category_channel`.`category_id` limit 1)

Possible Solution

Currently, I'm utilizing the NodeTrait method setParentId() instead. The model should however be able to persist the attribute correctly, without resorting to trait methods (IMHO).

Steps to Reproduce

$category->parent_id = ($parent_id > 0) ? $parent_id : null; //current category ID is 4, parent_id is suppose to be set to 1
$category->save(); // Results in previously described error message

Context (Environment)

The issue occured during an attempt to import categories from external source (ERP) and manually setting model primary key and parent ID.

Detailed Description

Possible Implementation

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

No branches or pull requests

1 participant