Bug in Query builder Join
qhung opened this issue · 4 comments
Hello,
Currently, I am tired with JOIN and DB :: expr()
Is the code below a bug?
if ($this->_table instanceof \Database_Query_Builder_Select)
{
// Compile the subquery and add it
$sql .= ' ('.$this->_table->compile().')';
}
elseif ($this->_table instanceof \Database_Expression)
{
// Compile the expression and add its value
$sql .= ' ('.trim($this->_table->value(), ' ()').')'; <== bug
}
Why trim() with ' ()' is used?
Example, i am using in my code:
$qr->join(DB::expr(" table
FORCE INDEX(PRIMARY) "), 'INNER');
Its make after of ')' is lost.
table
FORCE INDEX ( PRIMARY
Thanks!
Not really a bug, the first parameter of join() is the name of the table to join, not some arbitrary piece of SQL.
And the functionality was probably not included because its syntax is DB specific, so you can't make a generic compiler. The posibility to have per-driver compilers was only introduced recently.
Dear WanWizard,
Thanks for your answer!
But, i can use it in fuel 1.7.
How can I write it in 1.8 version?
I can't recall anything significant changed between 1.7 and 1.8, that needs to be checked.
Please tell me when you understand. Thank you!