Skip to content

Commit 843ddb9

Browse files
committed
test: add test for table alias and table prefix
1 parent 03f5195 commit 843ddb9

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

tests/system/Database/Builder/AliasTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,20 @@ public function testAliasLeftJoinWithLongTableName()
8484

8585
$this->assertSame($expectedSQL, str_replace("\n", ' ', $builder->getCompiledSelect()));
8686
}
87+
88+
/**
89+
* @see https://github.com/codeigniter4/CodeIgniter4/issues/5360
90+
*/
91+
public function testAliasSimpleLikeWithDBPrefix()
92+
{
93+
$this->setPrivateProperty($this->db, 'DBPrefix', 'db_');
94+
$builder = $this->db->table('jobs j');
95+
96+
$builder->like('j.name', 'veloper');
97+
98+
$expectedSQL = <<<'SQL'
99+
SELECT * FROM "db_jobs" "j" WHERE "j"."name" LIKE '%veloper%' ESCAPE '!'
100+
SQL;
101+
$this->assertSame($expectedSQL, str_replace("\n", ' ', $builder->getCompiledSelect()));
102+
}
87103
}

0 commit comments

Comments
 (0)