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

Handle special chars #11

Open
robsontenorio opened this issue Oct 25, 2019 · 10 comments
Open

Handle special chars #11

robsontenorio opened this issue Oct 25, 2019 · 10 comments

Comments

@robsontenorio
Copy link
Collaborator

Is there any alternative through configuration to ignore special chars like:

á -> a
õ -> o
ç -> c
...

By default Caché does not ignore when making a simple "where" with sql. Otherwise i must implement a translator helper at app level.

@jeandormehl
Copy link
Owner

Will have a look into this.

@robsontenorio
Copy link
Collaborator Author

Current workaround:

$name = Str::ascii($name);
 
where('name', $name);

Just wondering if there is a default config for this issue.

@jeandormehl
Copy link
Owner

I will add a configuration option for this and sanitize parameters passed before the queries run.

Will let you know when I get some time to actually do it.

@robsontenorio
Copy link
Collaborator Author

robsontenorio commented Nov 10, 2019

Please, dont. It is just workaround, i don't know if there is a best "native way" through drivers/PDO/ODBC config to do it.

@jeandormehl
Copy link
Owner

Hi, thanks for the pull requests.

I'm swamped at work but I will get to this probably this weekend.

@jeandormehl
Copy link
Owner

Hi Robson

Completely forgot about this, will revisit as soon as I'm back home later next week.

@robsontenorio
Copy link
Collaborator Author

The main problem here is at database level (Caché DB).

How do you currently manage a "like"? Considering the target fields has special chars/accents.

@jeandormehl
Copy link
Owner

jeandormehl commented Oct 19, 2020

I am extending from use Illuminate\Database\Query\Grammars\SqlServerGrammar;

I do not actually test the "like" part of queries and dont modify the values in this regard.

My best guess is that we would need to override a function, either where the variables are added to the sql or where the like statement is created.

I will investigate.

There could also possibly be an ODBC or PDO ATTR setting that could handle this for us. Will check Cache and PHP sites.

@robsontenorio
Copy link
Collaborator Author

robsontenorio commented Oct 24, 2020

On Caché legacy DB my company has created an internal custom function "removeAccents()"

So.. if name is joão i do place joao on like statement, and removeAccents() will turn it on joao. So it will work as expected.

where removeAccents(name) like "%joao%" `  

But I am really looking for a more native solution. No lucky.

@jeandormehl
Copy link
Owner

Hi

Yes, this can be easily fixed in one of the grammars.
I have a massive deadline for the 24th but this should be very simple to implement.

I will have a look as soon as I can.

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