-
Notifications
You must be signed in to change notification settings - Fork 824
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
RFC: Explicitly specify what characters are/aren't allowed in DataObject db field names #10605
Comments
I like this, though I'm concerned about scenarios where developers cannot change existing column names such as If we do this, then I'd much prefer a list of allowable characters as this method is far stricter, presumably it would be something like |
I think allowing utf8 characters is a must, especially for developers in places where English isn't the primary language, which may want to use characters from their language's script for the column names - though I'm interested to hear if anyone disagrees with that. I'd suspect hyphens and underscores would be allowed, along with alphanumerical characters including utf8 "word" characters. So The upgrade path concern is valid though. I'm not sure how to reconcile that - or how much of an impact this change would have (if any impact at all). |
What are we doing for table names? Could/should that be somehow reflected here as well? |
Would we provide a migration script for data that suddenly live in a column with an unsupported name and a new column with a supported name is created during dev/build? Or use a fallback trying to access the column without the sanitisation applied? |
Other than passing it through
I think that's a good idea, if this RFC is approved. It won't help anyway with the situation that Steve described (i.e. they can't change the name without affecting other systems), but I suspect that is a very edge case scenario.
I'd like to avoid this, as it means we then have to support these "invalid" column names with all our functionality, which is what I'm trying to get away from with this RFC. |
We've come across situations a few times where we want to verify if column names are "valid" (#10600 is the most recent) - and have tried to do so using regex. Unfortunately there's currently no validation inside Silverstripe code itself to determine what characters are or aren't valid for database columns.
We already use code like
explode()
etc in places, which make assumptions about what characters aren't valid in db field names - but the only validation for this is in the database itself. This can potentially lead to scenarios where a db column is technically valid and gets created in the database with no errors or warnings, but then our code makes incorrect assumptions and causes errors later down the line - after data has already been created.I propose we set either a whitelist of allowed characters, or a blacklist of disallowed characters, and validate DB column names. Invalid column names would result in errors at least during dev/build, so that developers are never in a scenario where they have otherwise column names that are unusable with some functionality, and so that we can more confidently validate column name validity anywhere in the code without ambiguity.
@silverstripe/core-team thoughts?
The text was updated successfully, but these errors were encountered: