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

Kohana DB builder, MariaDB and PHP7 #11

Closed
k03n00b opened this issue Dec 22, 2016 · 1 comment
Closed

Kohana DB builder, MariaDB and PHP7 #11

k03n00b opened this issue Dec 22, 2016 · 1 comment

Comments

@k03n00b
Copy link

k03n00b commented Dec 22, 2016

UNION is behaving differently with newer MariaDB and PHP7.

Kohana's DB builder is using brackets
(SELECT ...) UNION ALL (SELECT ...) ORDER BY id DESC
With brackets result won't be ordered / sorted correctly. Brackets will break ORDER BY.

Here's fix:
SELECT ... UNION ALL SELECT ... ORDER BY id DESC

/modules/database/classes/Kohana/Database/Query/Builder/Select.php

	if ( ! empty($this->_union))
	{
		$query = ''.$query.'';
		foreach ($this->_union as $u) {
			$query .= ' UNION ';
			if ($u['all'] === TRUE)
			{
				$query .= 'ALL ';
			}
			$query .= ''.$u['select']->compile($db).'';
		}
	}
@svenbw
Copy link
Collaborator

svenbw commented Jan 10, 2017

Looks like a bug in MariaDB and should be fixed in MariaDB version 10.2.1
(see MDEV-10037 UNION with LIMIT ROWS EXAMINED does not require parentheses)

@neo22s neo22s closed this as completed Jan 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants