Zsolt Szilagyi
Zsolt Szilagyi

Reputation: 5006

Unknown column <tablename>_id on Shopware 6 translations

After creating a Shopware6 Entity with translations, exactly following the official tutorial, I get an Unknown column "<tablename>_id" error; the tablename seems to be interpreted as part of the column name.

Upvotes: 1

Views: 405

Answers (1)

Zsolt Szilagyi
Zsolt Szilagyi

Reputation: 5006

There is a requirement on the naming scheme of mapped fields in the *_translation tables: they HAVE to follow <tablename>_id. That is, the tablename IS part of the fieldname.

In the tutorial that's not obvious, since they speak of bundle_id, where "bundle" is not the name of the entity but the table name. Most likely you vendor-prefixed and modulename-prefixed your table.

Example:

Your Entity: ACME\CoolModule\Core\Content\FoobarDefinition

Entity Table:
acme_coolmodule_foobar

Translation-table HAS to be exactly:
          CREATE TABLE IF NOT EXISTS `acme_coolmodule_foobar_translation` (            
          `acme_coolmodule_foobar_id` BINARY(16) NOT NULL,
          `language_id` BINARY(16) NOT NULL, ...

The difficulty is that Shopware doesn't SWAG-Prefix their own tutorial-modules, so you can't see the difference.

Upvotes: 3

Related Questions