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

Fix quoting with an underscore at the beginning #151

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Driver/Quoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function quote(string $identifier, bool $isTable = false): string
private function expression(string $identifier): string
{
return preg_replace_callback(
'/([a-z][0-9_a-z\.]*\(?)/i',
'/([_a-z][0-9_a-z\.]*\(?)/i',
function ($match) {
$identifier = $match[1];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2267,4 +2267,21 @@ public function testFragmentInWhereInClause(): void
$select
);
}

/**
* Issue https://github.com/cycle/database/issues/49
*/
public function testLeftJoinQuoting(): void
{
$select = $this->database
->select()
->from(['users'])
->leftJoin('_1SCONST _1SCONST2(NOLOCK)')
->on('SC3271.ID', '=', '_1SCONST2.OBJID');

$this->assertSameQuery(
'SELECT * FROM {users} LEFT JOIN {_1SCONST} _1SCONST2({NOLOCK}) ON {SC3271}.{ID} = {_1SCONST2}.{OBJID}',
$select
);
}
}
Loading