@@ -579,9 +579,11 @@ public function fromSubquery(BaseBuilder $from, string $alias): self
579579 /**
580580 * Generates the JOIN portion of the query
581581 *
582+ * @param RawSql|string $cond
583+ *
582584 * @return $this
583585 */
584- public function join (string $ table , string $ cond , string $ type = '' , ?bool $ escape = null )
586+ public function join (string $ table , $ cond , string $ type = '' , ?bool $ escape = null )
585587 {
586588 if ($ type !== '' ) {
587589 $ type = strtoupper (trim ($ type ));
@@ -601,6 +603,17 @@ public function join(string $table, string $cond, string $type = '', ?bool $esca
601603 $ escape = $ this ->db ->protectIdentifiers ;
602604 }
603605
606+ // Do we want to escape the table name?
607+ if ($ escape === true ) {
608+ $ table = $ this ->db ->protectIdentifiers ($ table , true , null , false );
609+ }
610+
611+ if ($ cond instanceof RawSql) {
612+ $ this ->QBJoin [] = $ type . 'JOIN ' . $ table . ' ON ' . $ cond ;
613+
614+ return $ this ;
615+ }
616+
604617 if (! $ this ->hasOperator ($ cond )) {
605618 $ cond = ' USING ( ' . ($ escape ? $ this ->db ->escapeIdentifiers ($ cond ) : $ cond ) . ') ' ;
606619 } elseif ($ escape === false ) {
@@ -634,11 +647,6 @@ public function join(string $table, string $cond, string $type = '', ?bool $esca
634647 }
635648 }
636649
637- // Do we want to escape the table name?
638- if ($ escape === true ) {
639- $ table = $ this ->db ->protectIdentifiers ($ table , true , null , false );
640- }
641-
642650 // Assemble the JOIN statement
643651 $ this ->QBJoin [] = $ type . 'JOIN ' . $ table . $ cond ;
644652
0 commit comments