doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.92k stars 2.51k forks source link

MSODBCSQL17 and SQL Server 2008 findOneBy(): Incorrect syntax near 'OFFSET' #9583

Open Adi-18 opened 2 years ago

Adi-18 commented 2 years ago

Bug Report

Q A
Version 3.2.2
Symfony 6.0.4
PHP 8.1

Summary

Application that connects to a remote SQL Server 2008 R2 with MSODBCSQL17 and SQLSRV Doctrine DBAL driver in a Docker container running PHP-FPM 8.1 and Apache.

Using Doctrine to persist entities and retrieve one more than one record works without problems, but the findOneBy() method throws 1 DBAL exception and 1 SQLSRV Exception.

Current behavior

When retrieving entities with the default findOneBy() method, Symfony throws the following: Incorrect syntax near 'OFFSET'

Also follows don't works:

        $qb = $this->createQueryBuilder('c');
        $qb
            ->where('c.operator = :loginId')
            ->setParameter('loginId', $loginId)
            ->orderBy('c.workDate','ASC')
            ->setMaxResults(1)
        ;
        return $qb->getQuery()->getSingleResult();

I need to select first row of my database. Issue [ doctrine/dbal#3159] did not help or I don't understand it.

Damien-Unsolite commented 2 years ago

Hi. Same problem for me. It seems Doctrine 3 must be used now for SQLServer "version 2012 and above" https://www.doctrine-project.org/projects/doctrine-dbal/en/3.2/reference/platforms.html Doctrine 2 can use SQLServer 2000 and above. That's very bad for me (and my project)...