catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.83k stars 1.15k forks source link

Medoo tableQuote behave differently based on system #1063

Closed SilverBull closed 1 year ago

SilverBull commented 1 year ago

Information

Describe the Problem Trying to select records from a table that starts with an underscore generate different behaviors on Mysql and Mssql. On mssql the query runs just fine, on mysql on other hand medoo trows a InvalidArgumentException, digging in the code looks like it fails the pregmatch `'/^(?![\d])[\p{N}\p{L}-_]+$/u'` but shouldn't fails on mssql too?

Obviously the raw query runs just fine with $datas = $database->query("SELECT id FROM _test")->fetchAll();

Detail Code The detail code you are using causes the problem.

$datas = $database->select("_test","id");

Expected output Either pass on both versions or fails on both versions

SilverBull commented 1 year ago

I update the problem, apparently it's not related to database, I tried to replicate the same mssql database and Medoo throw the same error. So it's maybe some php config or don't know. I will edit the title to reflect this update

catfan commented 1 year ago

I didn't found the Regex /^(?![_\d])[\p{N}\p{L}\-_]+$/u you mentioned on the project. What Medoo version are you using?

SilverBull commented 1 year ago

Sorry for the delay in responding, as mentioned in the opening, I am using 2.1.7. In the meantime I created a copy of prod's MSSQL database under the same machine that hosts MySQL and found that the problem persists. So it is something else in the environment that is causing the problem.

As for the regex I apologize as it appears the result of the debugging tool I'm using. In the code I have ``` if (pregmatch('/^[\p{L}][\p{L}\p{N}@$#-_]*$/u', $table)) { return '"' . $this->prefix . $table . '"'; }


Maybe this is a clue?

![2022-11-08_13-47-26](https://user-images.githubusercontent.com/12399837/200567733-5b642f39-d4ec-4d24-82b0-24779935ee2f.png)

EDIT:
Ok I'm an idiot, on the server there was version 2.0.0, uploaded the version 2.1.7 and It's working fine. 
I apologize for the trouble