File tree Expand file tree Collapse file tree
tests/system/Database/Builder Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,4 +49,34 @@ public function testAliasSupportsStringOfNames()
4949 }
5050
5151 //--------------------------------------------------------------------
52+
53+ /**
54+ * @see https://github.com/codeigniter4/CodeIgniter4/issues/1599
55+ */
56+ public function testAliasLeftJoinWithShortTableName ()
57+ {
58+ $ this ->setPrivateProperty ($ this ->db , 'DBPrefix ' , 'db_ ' );
59+ $ builder = $ this ->db ->table ('jobs ' );
60+
61+ $ builder ->join ('users as u ' , 'u.id = jobs.id ' , 'left ' );
62+
63+ $ expectedSQL = 'SELECT * FROM "db_jobs" LEFT JOIN "db_users" as "u" ON "u"."id" = "db_jobs"."id" ' ;
64+
65+ $ this ->assertEquals ($ expectedSQL , str_replace ("\n" , ' ' , $ builder ->getCompiledSelect ()));
66+ }
67+
68+ /**
69+ * @see https://github.com/codeigniter4/CodeIgniter4/issues/1599
70+ */
71+ public function testAliasLeftJoinWithLongTableName ()
72+ {
73+ $ this ->setPrivateProperty ($ this ->db , 'DBPrefix ' , 'db_ ' );
74+ $ builder = $ this ->db ->table ('jobs ' );
75+
76+ $ builder ->join ('users as u ' , 'users.id = jobs.id ' , 'left ' );
77+
78+ $ expectedSQL = 'SELECT * FROM "db_jobs" LEFT JOIN "db_users" as "u" ON "db_users"."id" = "db_jobs"."id" ' ;
79+
80+ $ this ->assertEquals ($ expectedSQL , str_replace ("\n" , ' ' , $ builder ->getCompiledSelect ()));
81+ }
5282}
You can’t perform that action at this time.
0 commit comments