Modify

Opened 4 months ago

Closed 4 months ago

Last modified 4 months ago

#1108 closed defect (fixed)

pdosqlexec doesn't throw exception for the non-first SQL instruction

Reported by: alex@… Owned by: mrook
Priority: tbd Milestone: 2.8.0
Component: phing-tasks-ext Version: 2.7.0
Keywords: pdosqlexec, DummyPDOQuerySplitter Cc:

Description

When pdosqlexec task process a dbdeploy file and we have a wrong SQL instruction but not the first instruction, PDO doesn't throw exception as explained in this bug https://bugs.php.net/bug.php?id=61613

To skip this bug, we can split the SQL file for a instruction for each delimiter.

Adding this control in DummyPDOQuerySplitter it works like a charm, the MySQL errors are showed.

Attachments (1)

DummyPDOQuerySplitter.php (2.3 KB) - added by alex@… 4 months ago.
/usr/local/Cellar/php55/5.5.11/lib/php/phing/tasks/ext/pdo/DummyPDOQuerySplitter.php

Download all attachments as: .zip

Change History (6)

Changed 4 months ago by alex@…

/usr/local/Cellar/php55/5.5.11/lib/php/phing/tasks/ext/pdo/DummyPDOQuerySplitter.php

comment:1 Changed 4 months ago by alex@…

I have a lot of issues uploading the modifications, the content of the DummyPDOQuerySplitter::nextQuery() is

 public function nextQuery()
    {
        $sql      = null;

        $delimiter = $this->parent->getDelimiter();
        $project   = $this->parent->getOwningTarget()->getProject();

        while (($line = $this->sqlReader->readLine()) !== null) {
            $line      = ProjectConfigurator::replaceProperties(
                             $project, trim($line), $project->getProperties()
                         );

            if (($line != $delimiter) && (
                StringHelper::startsWith("//", $line) ||
                StringHelper::startsWith("--", $line) ||
                StringHelper::startsWith("#", $line))) {
                continue;
            }

            $sql .= " " . $line . "\n";

            /**
             * fix issue with PDO and wrong formated multistatements
             * @issue 1108
             */
            if (StringHelper::endsWith($delimiter, $line))
            {
                break;
            }

        }

        return $sql;
    }

comment:2 Changed 4 months ago by alex@…

Generated a pull request on github

https://github.com/phingofficial/phing/pull/290

comment:3 Changed 4 months ago by Michiel Rook

  • Resolution set to fixed
  • Status changed from new to closed

Merge pull request #290 from corretge/patch-1

Fixes #1108 - fix for pdosqlexec doesn't throw exception

Changeset: 01b3f5081acb9d71c85aec05db2d6cb64de4aa53

comment:4 Changed 4 months ago by Michiel Rook

Merge pull request #290 from corretge/patch-1

Fixes #1108 - fix for pdosqlexec doesn't throw exception

Changeset: 01b3f5081acb9d71c85aec05db2d6cb64de4aa53

comment:5 Changed 4 months ago by mrook

  • Milestone changed from Backlog to 2.8.0

Add Comment

Modify Ticket

Action
as closed The owner will remain mrook.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.