Skip to content

enqueue/dbal on MS-Sql Server #977

@NeilWhitworth

Description

@NeilWhitworth

When using the enqueue symfony bundle together with enqueue/dbal against a MS-SQL server , running the console command:-

php bin\console enqueue:consume --setup-broker -vv

fails with the error:-

[PDOException (42S22)] SQLSTATE[42S22]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Invalid column name 'false'.

I have traced this to the file vendor/enqueue/dbal/DbalConsumerHelperTrait.php, function removeExpiredMessages().

`
$delete = $this->getConnection()->createQueryBuilder()
->delete($this->getContext()->getTableName())
->andWhere('(time_to_live IS NOT NULL) AND (time_to_live < :now)')
->andWhere('delivery_id IS NULL')
->andWhere('redelivered = false')

        ->setParameter(':now', time(), Type::BIGINT)
    ;

`

Changing this query as below fixes the issue for me.

`
$delete = $this->getConnection()->createQueryBuilder()
->delete($this->getContext()->getTableName())
->andWhere('(time_to_live IS NOT NULL) AND (time_to_live < :now)')
->andWhere('delivery_id IS NULL')
->andWhere('redelivered = :redelivered')

        ->setParameter(':now', time(), Type::BIGINT)
        ->setParameter('redelivered', false, Type::BOOLEAN)
    ;

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions