jeudi 19 mars 2015

Doctrine2, bad syntax for UNIQ Index, SQL Server 2005

I'm trying to setup Doctrine2 inside my project, it works fine, but I have a issue while generating schema with columns option: 'unique=true'


my Entity :



<?php
namespace Entities\Test;
/**
* @Entity(repositoryClass="")
* @Table(name="test")
*/
Class Test {
/**
* @Id
* @Column(type="integer",unique=true, nullable=false)
*/
private $id;

/**
* @Column(type="string", length=32, unique=true, nullable=false)
*/
private $test;
}


Then, I just unse the console command :



orm:schema-tool:update --dump-sql


It return some nice SQL :



CREATE TABLE test (id INT NOT NULL, test NVARCHAR(32) NOT NULL, PRIMARY KEY (id));
CREATE UNIQUE INDEX UNIQ_D87F7E0CBF396750 ON test (id) WHERE id IS NOT NULL;
CREATE UNIQUE INDEX UNIQ_D87F7E0CD87F7E0C ON test (test) WHERE test IS NOT NULL;


But when I execute it (--force), I get an error :



[Doctrine\DBAL\DBALException]
An exception occurred while executing 'CREATE UNIQUE INDEX UNIQ_D87F7E0CBF3
96750 ON test (id) WHERE id IS NOT NULL':

SQLSTATE [42000, 156]: [Microsoft][SQL Server Native Client 11.0][SQL Serve
r]Syntaxe incorrecte vers le mot cl▒ 'WHERE'.


It seems that this syntax is for SQLServer > 2008, but I'm working with SQLServer2005, so I added the good Platform in my options array :



$conn = array(
'driver' => 'sqlsrv',
'user' => 'gaia_dev',
'password' => 'RYUuflm3Ny',
'host' => '10.2.0.19',
'dbname' => 'Contentieux',
'platform' => new Doctrine\DBAL\Platforms\SQLServer2005Platform(),
);

$this->em = EntityManager::create($conn, $config);


But it do not change anything to the SQL code, I still have this 'incorrect syntax near WHERE'


I work with the last stable version of doctrine, downloaded with composer and I tried it in a new clean project, it still the same, I searched a lot for a similar issue, but didn't find anything, I think I missed something.


Any help would be welcome !


Thank you for reading me.


Aucun commentaire:

Enregistrer un commentaire