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

Automatically increase an attribute's database field length #2308

Open
wants to merge 1 commit into
base: 2.8
Choose a base branch
from

Conversation

fritzmg
Copy link
Contributor

@fritzmg fritzmg commented Jun 15, 2022

Currently if you have a select/radio attribute where the options are defined in the attribute itself, the database field that is created for tl_iso_product will have a hard coded length of 64. However, this means that if you define an option with a value larger than 64 characters, it will lead to an exception in the back end when trying to save the product with that option, as it won't fit into the database field.

This PR solves that by increasing the length of the database field (by multiples of 64) dynamically, according to the option's value lengths. For this to apply you will need to update the database yourself though after you have entered all the possible options for your attribute (via the Install Tool or contao:migrate).

@aschempp
Copy link
Member

aschempp commented Jun 16, 2022

why not use the actual length? Maybe we need to include the length of existing database values as well? Also, doesn't it update the database automatically if you change an attribute configuration?

@fritzmg
Copy link
Contributor Author

fritzmg commented Jun 16, 2022

why not use the actual length?

There is no actual length as the back end input field has no maximum length. Or do you mean the actual length of the string instead of multiple values of 64?

Maybe we need to include the length of existing database values as well?

Probably, yes. But it's at least an improvement to before.

Also, doesn't it update the database automatically if you change an attribute configuration?

Yes, as I pointed out this would require you to update the database after you have changed the values.

@aschempp
Copy link
Member

Or do you mean the actual length of the string instead of multiple values of 64?

yes

Also, doesn't it update the database automatically if you change an attribute configuration?

Yes, as I pointed out this would require you to update the database after you have changed the values.

uhm, why, if we update automatically?

@fritzmg
Copy link
Contributor Author

fritzmg commented Jun 16, 2022

Does it already do that when you edit the options of an existing radio/select attribute? I didn't actually check 🙈

@aschempp
Copy link
Member

As far as I know it does, otherwise change if attribute types would not update the column.

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

Successfully merging this pull request may close these issues.

2 participants