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

Cannot fetch translations when table names include spaces. #764

Open
GuySartorelli opened this issue Apr 25, 2022 · 1 comment
Open

Cannot fetch translations when table names include spaces. #764

GuySartorelli opened this issue Apr 25, 2022 · 1 comment

Comments

@GuySartorelli
Copy link
Contributor

Originally opened as silverstripe/silverstripe-framework#10259 by @marimchen

Can you please add some kind of warning message or an red error-message in dev/build for classes which have a blank at the beginning of their name e.g " MyTable" or "My Table". It's hard to see in the database itself and it causes real bad behaviour for popular modules like silverstripe-fluent from tractorcow.

Thank you very much, kind regards

Per discussion in the original issue, spaces in table names are valid in SQL and so should be allowed by the fluent module (as opposed to presenting an error or warning as suggested above).

This is now being raised here because as per @marimchen:

It was overlooked because everything worked as it should, except of fluent, which couldn't handle fetching the translations correct because of that.

It sounds like table names just aren't being quoted correctly somewhere - hopefully @marimchen can provide more specifics about exactly how this was found and how the problem presented.

@GuySartorelli GuySartorelli changed the title Cannot fetch translations when tables include spaces. Cannot fetch translations when table names include spaces. Apr 25, 2022
@tractorcow
Copy link
Collaborator

tractorcow commented Apr 25, 2022

you could probably look at some of the preg_match in code and change the \w to include spaces.

e.g.

// FluentExtension.php
if (preg_match('/"(?<table>[\w\\\\]+)"\."(?<field>\w+)"/i', $sql, $matches)) {

Do you want to submit a patch for your case and test with your db with spaces?

Make sure not to try matching fields with spaces; I don't know if silverstripe supports columns with whitespace in them.

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

2 participants