Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

PostgreSQL driver for Joomla! platform [clean version _ v2]. #961

Closed
wants to merge 31 commits into from

4 participants

@gpongelli

This driver implements inherited function from JDatabaseDriver class and add some other useful function to be able to use Joomla! on PostgreSQL database.
There is also a class that inherits from JDatabaseQuery to be able to create query object using PostgreSQL dialect.
These two classes are tested by other two classes under "test" folder.

PostgreSQL's added functions:

  • getAlterDbCharacterSet, set database encoding
  • getCreateDbQuery, returns a query string to create a database using $option array members
  • getRandom, get a random number
  • getStringPositionSQL, returns string's position inside another string
  • getTableSequences, returns an array of table's sequences information
  • releaseTransactionSavepoint, release given savepoint during transaction
  • showTables, lists all table in database
  • transactionSavepoint, creates transaction savepoint

Overridden functions:

  • connected
  • dropTable
  • escape
  • execute
  • fetchArray
  • fetchAssoc
  • fetchObject
  • freeResult
  • getAffectedRows
  • getCollation
  • getNumRows
  • getQuery
  • getTableColumns
  • getTableCreate
  • getTableKeys
  • getTableList
  • getVersion
  • insertid
  • insertObject
  • lockTable
  • renameTable
  • replacePrefix
  • select
  • setUTF
  • transactionCommit
  • transactionRollback
  • transactionStart
  • unlockTables
  • updateObject

PostgreSQL database query added functions:

  • limit, a possible replace for limit in setQuery
  • offset, a possible replace for limit in setQuery
  • forShare, lock table/row during SELECT
  • forUpdate, lock table/row during SELECT
  • getInsertTable, used in "indertid()" to retrieve last INSERT INTO's table name
  • noWait, no wait a locked table
  • returning, an INSERT INTO optional clause to returns last insert id

Added also Postgresql's exporter and importer classes and their test classes.

gpongelli added some commits
@gpongelli gpongelli Added JDatabaseDriverPostgresql class. d3e77c1
@gpongelli gpongelli Added JDatabaseExporterPostgresql class. d7af380
@gpongelli gpongelli Added JDatabaseImporterPostgresql class. 55b07b5
@gpongelli gpongelli Added JDatabaseQueryPostgresql class. 3d3d554
@gpongelli gpongelli Added a check of static $cursor in loadNexObject and loadNextRow.
Without this check the row or object returned is always the first of
result set.
0017aea
@gpongelli gpongelli Added test classes for Postgresql's exporter. b9613bf
@gpongelli gpongelli Added test classes for Postgresql's importer. 82d96ea
@gpongelli gpongelli Added Postgresql database mock class. b5361db
@gpongelli gpongelli Added JDatabasePostgresqlQueryDummy class. f7868ef
@gpongelli gpongelli Added test class for Postgresql driver. fa43112
@gpongelli gpongelli Added test class for Postgresql's query. 97ee3d2
@gpongelli gpongelli Added Postgresql's query inspector class. 4cfb8f5
@gpongelli gpongelli Added JoomlaDatabasePostgresqlTestCase class. 23b9b2e
@gpongelli gpongelli Added JoomlaPostgresqlTestCase class. b4b9686
@gpongelli gpongelli Added DDL for Postgresql database. 4740484
@gpongelli gpongelli Changes on test setUp and setupBeforeClass members. ae82c21
@gpongelli gpongelli Correct JDatabaseExporterPostgreSQLInspector name in
JDatabaseExporterPostgresqlInspector .
7069113
@gpongelli gpongelli Changed JDatabasePostgreSQLMock to JDatabasePostgresqlMock. bda1667
@gpongelli gpongelli Fixed classes name. 172b7d9
@gpongelli gpongelli Removed JoomlaDatabasePostgresqlTestCase class. 3f03a59
@gpongelli gpongelli Changed superclass' file name according to last commit. f16ec16
@gpongelli gpongelli Changed setUpBeforeClass, getConnection and getMockDatabase to be
database independent.
794fb52
@gpongelli gpongelli Changed getMockDatabase to be database independent. f1e01c5
@gpongelli gpongelli Removed JoomlaPostgresqlTestCase.php file according to last two commi…
…ts about superclass' database-independent mock loading.
bb93743
@gpongelli gpongelli Changed superclass from JoomlaDatabasePostgresqlTestCase to
JoomlaDatabaseTestCase .
Changed setUp to load config.php file and search JTestConfig instead of
loading config_postgresql.php file and search JPostgresqlTestConfig.
Using JDatabaseDriver::getInstance instead of JDatabase's one.
83babc5
@gpongelli gpongelli Changed superclass from JoomlaPostgresqlTestCase to JoomlaTestCase.
Changed getMockDatabase call to load PostgreSQL Mock class and not
global one.
5d4daf4
@gpongelli gpongelli Added capability to use this driver with older Postgresql database (8.3,
8.4 and 9.0 versions).
Updated tests, actually it's possible to test older database version for
exporter and importer class changing return value of 'getVersion'
inside setup() call.
To test older database for driver class, just install it.
156972b
@gpongelli gpongelli Backward compatibility of getQuery, now returns query as
JDatabaseQueryPostgresql only if requested by second argument.
Use of getQuery() returning JDatabaseQueryPostgresql object is needed by
insertid() call to properly work.
6cf87c1
@gpongelli gpongelli Renamed JDatabaseMock.php to JDatabaseGlobalMock.php to be easily called
by JoomlaTestCase::getMockDatabase() in multidb environment without
creating each JoomlaTestCase's extended classes for each database.
8cd04d7
@gpongelli gpongelli Added isSupported() function and its test. 0cb9b56
@gpongelli

This branch should be easily merged inside master, instead of #917 (and it's parent #532) that could be closed without merging.

@joomla-jenkins
Collaborator

Unit testing complete. There were 25 failures and 16 errors from 2351 tests and 12252 assertions.
Checkstyle analysis reported 164 warnings and 0 errors.

@gpongelli

any log ?

@LunaSela

Probably caused by still using mysql for the postgresql tests because config.php still has mysql as database driver selected.

Before changing test config to postgresql driver, I got exactly the same error / failure counts.

It would probably correct and consistent to use a separate config file like config_postgresql.php for postgresql tests and skip these tests when it is not present - like it is done for the other DBMS.

If you still need logs, feel free to request them.

@gpongelli

you're right, but as you can see from this commit of previous pull 917 I've removed configuration file because someone told me inside mailing list to do this.

Which are your test result after changing configuration to postgresql driver ?
Which other database driver skip tests if it's not present its configuration file ?

Thank you,
Eng. Gabriele Pongelli.

@LunaSela

Ok as I see now, that recently changed. On Thursday that was the case for mysql drivers. Now the testing architecture radically changed and you will probably have to adapt to the current head. Now, the DBMS specific config files seem to be gone. - at least I cannot find them at the moment.

Running the junit tests on the checkout of Thursday, most errors are invalid date errors. Probably by not using "null date" but a hardcoded 0000-00-00 00:00:00. I might have a more detailed look at this when I have more spare time

@gpongelli

That hardcoded date were put inside joomla-platform/tests/suite/joomla/access/stubs/S01.xml .

Thank you,
Eng. Gabriele Pongelli.

@LouisLandry

Hi Gabriele,

I spent some time last night and rebased your branch over master, along with squashing all of your commits into one. In doing this I also moved things around quite a bit to line up with the current test scaffolding. We still have work to do generally on making the joomla testing tree more robust and such, but that is a much larger task.

You can see my work here: https://github.com/LouisLandry/joomla-platform/compare/merging

The one thing I didn't do was really test the PostgreSQL driver itself. I didn't have a postgres instance setup and didn't wanna go through that last night. Every other test case class passes completely though, and it is all lined up with how things are in the test tree now. You've done a masterful job with the postgresql support... well done. If you are OK with what I've done here, you could pull it down, make sure the driver tests are working (You'll need to uncomment the postgresql DSN string in phpunit.xml in the repository root), and submit it as a pull request. If you want to simply use it as a reference to get everything lined up yourself that's fine as well. I just know that you've been working on this a long time and trying to get it done against an ever moving target. I know that can be frustrating, so I wanted to put in some effort to help you out.

We are very close.

@gpongelli

Hi Louis,
it's not really easy start a pull request and, after some time, re-do all again because base structure was changed meanwhile (I did this three times, each time for a different change), and yes, it's frustrating.
This is not a criticism directed to a person, the problem maybe could be the procedure of doing this kind of job and it's management (merging this driver before moving each driver files and now their testing files would have avoided me to send two extra pull request), but I don't have the skill to discuss about management of project like this.
Sorry for this "extra" and off topic part.

Thank you for this job, I'll pull it and I'll do again tests, maybe I'll add importer and exporter test files for older database version (sublassing actual class and change mock's "getVersion" inside setUp). Query class doesn't change between versions and driver class can be tested on older version only running it.
I'll do this next days.

Have you solved problem with joomla-platform/tests/suite/joomla/access/stubs/S01.xml file and hardcoded null value ?

Eng. Gabriele Pongelli.

@LouisLandry

Yes, I know it's frustrating. You had the unfortunate situation of coming in with this at a time when the database package was being re-thought/re-built and also the unit tests being reworked. Interestingly, the entire year before that part of the codebase was very stable and would have been easier to do probably. I don't know. Ultimately it is what it is, and hopefully we are in a better place moving forward.

I'm not aware of a problem with the access package stub off the top of my head, but all the tests are running and passing for me now.

@gpongelli

I'm working on a branch coming from yours, test on Postgresql driver returns me OK .
I've found only driver test class while I've created library's classes and test classes for database query, for importer and exporter classes too, where are they ?

Eng. Gabriele Pongelli .

@LouisLandry

Everything except the driver tests themselves (which actually connect to pgsql/mysql/etc) are in the main test suite: tests/suites/unit/joomla/database/database/.

The driver test itself is at: tests/suites/database/driver/postgresql/JDatabasePostgresqlTest.php.

@LouisLandry

OK, merged the other one. Thanks a ton.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 4, 2012
  1. @gpongelli
  2. @gpongelli
  3. @gpongelli
  4. @gpongelli
  5. @gpongelli

    Added a check of static $cursor in loadNexObject and loadNextRow.

    gpongelli authored
    Without this check the row or object returned is always the first of
    result set.
  6. @gpongelli
  7. @gpongelli
  8. @gpongelli
  9. @gpongelli
  10. @gpongelli
  11. @gpongelli
  12. @gpongelli
  13. @gpongelli
  14. @gpongelli
  15. @gpongelli
  16. @gpongelli
  17. @gpongelli

    Correct JDatabaseExporterPostgreSQLInspector name in

    gpongelli authored
    JDatabaseExporterPostgresqlInspector .
  18. @gpongelli
  19. @gpongelli

    Fixed classes name.

    gpongelli authored
  20. @gpongelli
  21. @gpongelli
  22. @gpongelli
  23. @gpongelli
  24. @gpongelli

    Removed JoomlaPostgresqlTestCase.php file according to last two commi…

    gpongelli authored
    …ts about superclass' database-independent mock loading.
  25. @gpongelli

    Changed superclass from JoomlaDatabasePostgresqlTestCase to

    gpongelli authored
    JoomlaDatabaseTestCase .
    Changed setUp to load config.php file and search JTestConfig instead of
    loading config_postgresql.php file and search JPostgresqlTestConfig.
    Using JDatabaseDriver::getInstance instead of JDatabase's one.
  26. @gpongelli

    Changed superclass from JoomlaPostgresqlTestCase to JoomlaTestCase.

    gpongelli authored
    Changed getMockDatabase call to load PostgreSQL Mock class and not
    global one.
  27. @gpongelli

    Added capability to use this driver with older Postgresql database (8.3,

    gpongelli authored
    8.4 and 9.0 versions).
    Updated tests, actually it's possible to test older database version for
    exporter and importer class changing return value of 'getVersion'
    inside setup() call.
    To test older database for driver class, just install it.
  28. @gpongelli

    Backward compatibility of getQuery, now returns query as

    gpongelli authored
    JDatabaseQueryPostgresql only if requested by second argument.
    Use of getQuery() returning JDatabaseQueryPostgresql object is needed by
    insertid() call to properly work.
  29. @gpongelli

    Renamed JDatabaseMock.php to JDatabaseGlobalMock.php to be easily called

    gpongelli authored
    by JoomlaTestCase::getMockDatabase() in multidb environment without
    creating each JoomlaTestCase's extended classes for each database.
  30. @gpongelli
  31. @gpongelli
Something went wrong with that request. Please try again.