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

fixes #4127 #6693 #12536

Closed
wants to merge 4 commits into from
Closed

fixes #4127 #6693 #12536

wants to merge 4 commits into from

Conversation

eshiol
Copy link
Contributor

@eshiol eshiol commented Oct 24, 2016

fixes JDatabaseQuery __toString
UNION ALL
UNION + ORDER BY

fixes UNION ALL
fixed UNION + ORDER BY
@eshiol
Copy link
Contributor Author

eshiol commented Oct 24, 2016

If you use union and order, you will always get the error:

"Incorrect usage of UNION and ORDER BY"
$query1 = JFactory::getDbo()->getQuery(true);
$query1->select(array('id', 'title'))->from('#__content')->where('title LIKE ' . $query1->q($query1->e('A', true) . '%', false));
$query2 = JFactory::getDbo()->getQuery(true);
$query2->select(array('id', 'title'))->from('#__content')->where('title LIKE ' . $query1->q($query1->e('B', true) . '%', false));
$query1->union($query2)->order('id DESC');
JFactory::getDbo()->setQuery($query1)->execute();

unionAll doesn't work properly. The string you entered into the unionAll method was never appended to the SQL query

$query1 = JFactory::getDbo()->getQuery(true);
$query1->select(array('id', 'title'))->from('#__content')->where('title LIKE ' . $query1->q($query1->e('A', true) . '%', false));
$query2 = JFactory::getDbo()->getQuery(true);
$query2->select(array('id', 'title'))->from('#__content')->where('title LIKE ' . $query1->q($query1->e('B', true) . '%', false));
echo $query1->unionAll($query2);

Expected result

The code above should output "SELECT id, title FROM #__content WHERE title LIKE 'A%' UNION ALL (SELECT id, title FROM #__content WHERE title LIKE 'B%')".

Actual result

At the moment the output is "SELECT id, title FROM #__content WHERE title LIKE 'A%'".

@infograf768
Copy link
Member

looks lik this pr is messed up.

@alikon
Copy link
Contributor

alikon commented Oct 26, 2016

yes files changed have nothing in common with the pr description

@eshiol
Copy link
Contributor Author

eshiol commented Oct 26, 2016

I've merged two pull requests, but I don't know why. The file to pull is the first one with the id: 22a262d
Do you think I have to close this pull request and open a new one?

@alikon
Copy link
Contributor

alikon commented Oct 26, 2016

yes should be the better move

@eshiol
Copy link
Contributor Author

eshiol commented Oct 26, 2016

the bug is solved #10817

@eshiol eshiol closed this Oct 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants