Problem/Motivation
If you create any kind of workflow, attach it to a node type and then go to the node add page you trigger the following PDO exception:
PDOException: (SELECT t.tid, t.target_sid as state_id, s.state AS state_name, s.weight AS state_weight FROM {workflow_transitions} t INNER JOIN {workflow_states} s ON s.sid = t.target_sid WHERE t.sid = :sid AND s.status = 1 ORDER BY state_weight) UNION (SELECT s.sid as tid, s.sid as state_id, s.state as state_name, s.weight as state_weight FROM {workflow_states} s WHERE s.sid = :sid AND s.status = 1) ORDER BY state_weight, state_id (prepared: (SELECT t.tid, t.target_sid as state_id, s.state AS state_name, s.weight AS state_weight FROM "WORKFLOW_TRANSITIONS" t INNER JOIN "WORKFLOW_STATES" s ON s.sid = t.target_sid WHERE t.sid = :sid AND s.status = 1 ORDER BY state_weight) UNION (SELECT s.sid as tid, s.sid as state_id, s.state as state_name, s.weight as state_weight FROM "WORKFLOW_STATES" s WHERE s.sid = :sid AND s.status = 1) ORDER BY state_weight, state_id ) e: SQLSTATE[HY000]: General error: 907 OCIStmtExecute: ORA-00907: missing right parenthesis (ext\pdo_oci\oci_statement.c:148) args: Array ( [:sid] => 1 ) in workflow_allowable_transitions() (line 1336 of D:\wwwroot\mytc\sites\all\modules\contrib\workflow\workflow.module).
I'm not sure exactly if this is a bug with Workflow or with the Oracle driver. I'm cross posting the issue between the two projects.
Thanks,
Comments
Comment #1
minoroffense commentedIssue on the Oracle project
#1443170: PDO Exception when adding a workflow to a node using the Workflow module
Comment #2
minoroffense commentedThe offending code is the following:
What if we converted this to use db_select? Let Drupal generate the SQL code as required instead of using db_query directly?
Comment #3
minoroffense commentedFor example
By using "addField" you can build in the conditions for the direction of the query without any inline string stuff as the original has.
Not tested at all, but short of any typos it should work.
EDIT: Tested and it works with MySQL. The location of the orderBy methods is important (seem to only be available on the second query)
Comment #4
minoroffense commentedAlright, so that fixed the syntax error, but now I get another issue
Here's the generated SQL
Can anyone see something wrong with the generated UNION query?
Comment #5
minoroffense commentedI've tested the above rewrite of the query in comment #3 and it seems to work in both Oracle and MySQL.
Do you require a patch file or is this code block acceptable?
Comment #6
Bastlynn commentedA patch file would be most useful once the issue with the union is cleared up. I'll take a closer look at the union once I've had my coffee and taken out some of the other patch requests in the queue.
Comment #7
David_Rothstein commentedA likely cause for the UNION issue is this core bug: #1145076: UNION queries don't support ORDER BY clauses
Comment #8
bircherThank you for addressing this issue.
I have the same problem with SQLite.
I think it would not be a bad idea to split the query up, so I would also welcome a patch file for the fork of minorOffense.
The patch works for me and my happy SQLight, and I would happily rtbc the patch so it can be applied.
Comment #9
nancydruSee also #1421518: PDOException: SQLSTATE[23000]: Duplicate entry in {node_access} table: when assigning a workflow to the node
Comment #10
nancydruThe inner join depends on the $dir param. It's not taken into account in #3.
Comment #11
nancydruHere's what I have:
This seems to function as the old code did, at least in MySql.
Comment #12
nancydruAdding release blocker
Comment #13
nancydruMy change has been committed