? Success

User tests: Successful: Unsuccessful:

avatar chrisdavenport
chrisdavenport
28 Dec 2013

Also minor corrections and improvements to docblocks for union methods.

Union method currently just doesn't work at all. This fixes it. See tracker #32995 and PR #1629. If accepted this fix also needs to go into Joomla 2.5 and Framework 1.x.

avatar chrisdavenport chrisdavenport - open - 28 Dec 2013
avatar piotr-cz
piotr-cz - comment - 2 Jan 2014

Travis build failed because of test

1) JDatabaseQueryTest::testUnionClear
Tests that ORDER BY is cleared with union.
JDatabaseQueryElement Object (...) does not match expected type "NULL".
/home/travis/build/joomla/joomla-cms/tests/unit/suites/libraries/joomla/database/JDatabaseQueryTest.php:1566
avatar chrisdavenport
chrisdavenport - comment - 2 Jan 2014

The test is not required. The ORDER BY clause is actually permitted in a MySQL UNION, although it is ignored if a LIMIT clause is not also present (which is not possible with the current implementation). I'll have a go at improving the tests. I'll have to rely on Travis because I can't get phpUnit to work at the moment (dependency hell).

avatar piotr-cz
piotr-cz - comment - 2 Jan 2014

Did you try to install PHPUnit using composer?
composer global require 'phpunit/phpunit=3.8.*', see Installation chapter.

avatar chrisdavenport
chrisdavenport - comment - 2 Jan 2014

It was installed using PEAR, but it was a while ago now. I just tried removing it and re-installing with Composer but I got this error: "Your requirements could not be resolved to an installable set of packages." I'm pretty sure the problem is that phpUnit requires PHP 5.4.x and I need to have 5.3.x running. I tried downgrading to phpUnit 3.7 (using Composer) and that now installs okay. Any idea how I actually (attempt to) run the tests now? The instructions here: http://docs.joomla.org/Running_Automated_Tests_for_the_Joomla_CMS don't seem to work with the Composer installed version.

avatar piotr-cz
piotr-cz - comment - 2 Jan 2014

Usually I go to the root folder and run selected unit tests, just like in docs:

phpunit tests/unit/suites/libraries/joomla/database/JDatabaseQueryTest.php

Outputs this:

Configuration read from D:\localhost\GIT\joomla\joomla-cms\phpunit.xml.dist

............II.........................................F......... 65 / 80 ( 81%)

(There's currently some problem in JDatabaseQueryTest::testSet).

If this doesn't work at all, there might indeed be some problem with your installation.

If are using WAMP server, you may install few PHP versions at once.
I run the CLI on PHP 5.4 and develop on 5.3

avatar chrisdavenport chrisdavenport - change - 2 Jan 2014
Labels Added: ? ?
avatar chrisdavenport
chrisdavenport - comment - 2 Jan 2014

I don't know how to run it from Composer. Entering commands "phpunit" or "php phpunit" or "php composer.phar phpunit" come up with nothing. I'm running Ubuntu 12.04 and I can't afford to break anything on it as I use it for work. I'll probably set up a new server just for testing (with PHP 5.4 on it).

Anyway, I've removed the redundant test and added what I think might work for a new test. Will see what Travis says. Working blind, but if it works, I can add some more tests.

avatar piotr-cz
piotr-cz - comment - 2 Jan 2014

Composer installs the global requires into own directory, so you may have to add it's path to environment somehow to use it anywhere.
Check this SO answer and docs.

On windows I have a batch file that sets up the CLI with:

rem // Add Composer Global path (COMPOSER_HOME)
set PATH=%PATH%;%APPDATA%\Composer\vendor\bin
avatar chrisdavenport
chrisdavenport - comment - 4 Jan 2014

I figured out how to run the tests now. Thanks Piotr.

All tests should pass now.

avatar mbabker
mbabker - comment - 31 Jan 2014

Commented at #2986 (comment) about my test. It looks like this is the right patch for this issue.

avatar okonomiyaki3000
okonomiyaki3000 - comment - 31 Jan 2014

You should deprecate unionDistinct() and just call union() instead. Unions are distinct by default so UNION DISTINCT makes no sense.

avatar chrisdavenport
chrisdavenport - comment - 31 Jan 2014

Is that true across all supported databases?

avatar mbabker
mbabker - comment - 31 Jan 2014
avatar chrisdavenport
chrisdavenport - comment - 31 Jan 2014

"UNION Specifies that multiple result sets are to be combined and returned as a single result set.
ALL Incorporates all rows into the results. This includes duplicates. If not specified, duplicate rows are removed."

Sounds to me like it's true for SQL Server too then.

I'm neutral on this point. We could deprecate, but since unionDistinct() is just a proxy to union() anyway it doesn't seem to me to be worth the effort.

avatar mbabker mbabker - change - 11 Mar 2014
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-03-11 22:51:53
avatar mbabker mbabker - close - 11 Mar 2014
avatar mbabker mbabker - reference | - 11 Mar 14
avatar mbabker mbabker - merge - 11 Mar 2014
avatar mbabker mbabker - close - 11 Mar 2014
avatar infograf768
infograf768 - comment - 13 Mar 2014

We have Jenkins issues with code blocks in query.php. Could someone look at that?

avatar chrisdavenport
chrisdavenport - comment - 13 Mar 2014

What issues? Which code blocks?

avatar Bakual
Bakual - comment - 13 Mar 2014

JM solved it already. It passes now.

avatar chrisdavenport chrisdavenport - head_ref_deleted - 13 Mar 2014
avatar chrisdavenport chrisdavenport - reference | - 21 Mar 14
avatar Bakual Bakual - reference | - 12 May 14
avatar joboca
joboca - comment - 13 Oct 2014

It is possible to join 2 databases at the same time in a single query?
For example: I want to see how many users I have on my server and how many users I have on an external server, all in a single SQL query.

I've been testing the use of union and JDatabase:
http://docs.joomla.org/Using_the_union_methods_in_database_queries
http://docs.joomla.org/How_to_connect_to_an_external_database

Add a Comment

Login with GitHub to post a comment