schmittjoh / JMSJobQueueBundle

Run and Schedule Symfony Console Commands as Background Jobs
http://jmsyst.com/bundles/JMSJobQueueBundle
334 stars 254 forks source link

jms-job-queue:clean-up sql error #219

Open noemiquezada opened 5 years ago

noemiquezada commented 5 years ago

I am running Symfony 2.8 / PHP 7.0 using SQL Server When you execute the php app/console jms-job-queue:clean-up command it generates the following exception

[Doctrine\DBAL\DBALException] An exception occurred while executing 'WITH dctrn_cte AS (SELECT TOP 1 1 FROM jms_job_dependencies WHERE dest_job_id = ?) SELECT * FROM (SELECT *, ROW_NUMBE R() OVER (ORDER BY (SELECT 0)) AS doctrine_rownum FROM dctrn_cte) AS doctrine_tbl WHERE doctrine_rownum BETWEEN 1 AND 1 ORDER BY doctrine_rownum ASC' with p arams ["3"]:

SQLSTATE[42000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]No column name was specified for column 1 of 'dctrn_cte'.

I traced through it and it seems that the first line of cleanUpExpiredJobs generates a partial query which generates the above query startingt with 'WITH dctrn_cte...'.

$incomingDepsSql = $con->getDatabasePlatform()->modifyLimitQuery("SELECT 1 FROM jms_job_dependencies WHERE dest_job_id = :id", 1);

When it tries to generate a result it generates the exception because the query is not correct. $result = $con->executeQuery($incomingDepsSql, array('id' => $job->getId()));

noemiquezada commented 5 years ago

I updated the following query on Line 85 of CleanUpCommand.php from SELECT 1 FROM to SELECT * FROM and that seemed to resolve the issue.

$incomingDepsSql = $con->getDatabasePlatform()->modifyLimitQuery("SELECT * FROM jms_job_dependencies WHERE dest_job_id = :id", 1);

The query that was generated for looked like 'WITH dctrn_cte AS (SELECT TOP 1 1 FROM jms_job_dependencies... and after the change it looked like 'WITH dctrn_cte AS (SELECT TOP 1 * FROM jms_job_dependencies...

Hopefully this will help anyone else facing the same issue.