Repository navigation
Description
Background information
IMPORTANT: If you choose to ignore this issue report template, your issue will be closed as we cannot help without the requested information.
Please make sure you tick (add an x between the square brackets with no spaces) the following check boxes:
- Reporting an issue of an unmodified OSPOS installation
- Checked open and closed issues and no similar issue was already reported (please make sure you searched!)
- Read README, WHATS_NEW, INSTALL.md and UPGRADE
- Read the FAQ for any known install and/or upgrade gotchas (in specific PHP extensions installed)
- Read the wiki
- Executed any database upgrade scripts if an upgrade pre 3.0.0 (e.g. database/2.4_to_3.0.sql)
- Aware the installation code is in bintray (see README), and GitHub master is for developers only and therefore not complete nor stable
Installation information
- OSPOS version is: 3.3.2
- OSPOS git commit hash is: 78c8c2
- PHP version is: 7.4.13
- MySQL or MariaDB version is: 8.0.22
- OS and version is: FreeBSD 11.3
- WebServer is: Apache 2.4
- Selected language is: English
- (If applicable) Docker installation:
- (If applicable) Installation package for the LAMP/LEMP stack is:
Issue / Bug / Question / New Feature
Currently the default characterset for tables in OSPOS is utf8. My database, at least, sets the collation to utf8_general_ci. The ci indicates that the table is case insensitive. The problem that this creates is that if you have a DROPDOWN type attribute that you want to correct the capitalization on, you cannot do this through OSPOS if there are items that have this incorrect value. This is because if you delete the value in the DROPDOWN attribute, the attribute_value does not get deleted because other items depend on the attribute value. Then when you go back and re-add the value, the database says "yep, we have that one already, here is the attribute_id for it" when in fact, it has the incorrect capitalization, but doesn't pay attention to it because the collation is setup as case insensitive.
I cannot tell if the OSPOS install procedure it setting the collation or the database defaults are setting that because I don't see it explicitly in the tables.sql file (I do see the character set). That said, I think we need a design discussion of the pros/cons of recommending a cs collation. I've already pointed out the side effect of the utf8_general_ci (and other _ci) encodings. But we would need to consider whether searches of attributes are broken by someone expecting a case insensitive search, but getting case sensitive results ("hello world!" likely wouldn't return results containing "Hello world!" without code changes). We would also need to resolve performance implications of a larger encoding (4 bytes vs 3). I don't think all tables would need to have a CS encoding. probably just the attribute_values.attribute_value column, but possibly a few others in a few other tables.
@opensourcepos/org Thoughts
Activity
objecttothis commentedon Jan 14, 2021
Here is an article discussing the different collations, encodings, etc: https://jibai31.wordpress.com/2017/05/04/how-to-choose-your-mysql-encoding-and-collation/
Update: I do see that in the 3.1.1 migration we are setting all the tables as utf8_general_ci. So the question now becomes, do we need to set some columns on some tables to case senstitive. It seems that utf8_bin is the most likely candidate, though there are others in the utf8mb4 collations.
jekkos commentedon Jan 21, 2021
I think that we probably want to have ci_collation for most of the queries. If you search a table then most of the time you don't care whether it's uppercase or not.
I think there is also the option to set case sensitivity when running a query so we could consider to use just that if we want to match in a case sensitive way?
objecttothis commentedon Jan 22, 2021
@jekkos for searches, I completely agree. Searches isn't where this bug happens, though. This bug occurs any time you have an attribute_value connected by more than one attribute_link row. For example, let's say you have a dropdown with one of the values being "mISSPELLED vALUE" because your employee didn't see they had the capslock on. Before correcting the issue, several items have been assigned that dropdown.
In this case, if you attempt to correct the issue, you will never be able to from within OSPOS. When you delete the dropdown entry and re-create it as "Misspelled Value" after clicking submit, you will then be able to click edit and see that it is still "mISSPELLED vALUE". This is because the collation on the attribute_values.attribute_value column is case insensitive.
The only way I can forsee resolving this bug without changing the collation on that column is to search for all attribute_links that use that attribute_value, delete them and then recreate them... that adds a lot of overhead, because you would need to call that functionality every time you edited an attribute (not just dropdowns). That's well and good for one-off attribute changes, but what about when you are doing a CSV import with a 1000 rows?
objecttothis commentedon Feb 25, 2026
This is resolved by #4384 and did not require collation changes in the database.