zendframework/zend-db

SQL Server IDENTITY support

Opened this issue · 3 comments

SqlServer\Ddl\CreatTableDecorator does not know how to process $id->setOption('IDENTITY', '1, 1'); , equivalent to AUTO_INCREMENT from MySQL or SEQUENCE from PostgreSQL

@alextech can you provide a working example? Thanks!

Sorry, abused this as personal todo list:

public function testOptions() {
        $ctd = new CreateTableDecorator();

        $ct = new CreateTable('foo');
        $ctd->setSubject($ct);

        $col = new Column('id');
        $col->setOption('IDENTITY', '1,1');
        $ct->addColumn($col);

        $this->assertEquals(
            "CREATE TABLE [foo] ( \n    [id] INTEGER NOT NULL IDENTITY(1, 1) \n)",
            $ctd->getSqlString(new SqlServer())
        );
    }

Can paste to SqlServer\Ddl\CreateTableDecoratorTest.

This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at laminas/laminas-db#83.