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

Bug in Query builder Join #2099

Open
qhung opened this issue Jul 9, 2018 · 4 comments
Open

Bug in Query builder Join #2099

qhung opened this issue Jul 9, 2018 · 4 comments

Comments

@qhung
Copy link

qhung commented Jul 9, 2018

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!

@WanWizard
Copy link
Member

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.

@qhung
Copy link
Author

qhung commented Jul 17, 2018

Dear WanWizard,
Thanks for your answer!

But, i can use it in fuel 1.7.
How can I write it in 1.8 version?

@WanWizard
Copy link
Member

I can't recall anything significant changed between 1.7 and 1.8, that needs to be checked.

@qhung
Copy link
Author

qhung commented Jul 25, 2018

Please tell me when you understand. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants