SQL Server Identity Insert
NoToComments opened this issue · comments
Hello I cant get fatfree working with sqlserver.
On Inserts it sends 0 as id to sqlserver. Instead of leaving the column out of the insert statement.
CREATE TABLE [dbo].[example](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [varchar](50) NOT NULL
) ON [PRIMARY]
GO
Current behavior
INSERT INTO [dbo].[example]
(id,[name])
VALUES
(0,'test')
Wished behavior
INSERT INTO [dbo].[example]
([name])
VALUES
(<name, varchar(50),>)
Looks like #1192
I guess you're talking about the SQL mapper right? Can you provide a code sample?
Yeah its about the mapper.
Something like that?
$database = new \DB\SQL(
'sqlsrv:server=localhost,1433;database=testDB',
'sa',
'P@ssw0rd'
);
$example=new \DB\SQL\Mapper($database,'example');
$example->name="SpaceOps";
$example->save();
Error code
PDOStatement: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Cannot insert the value NULL into column 'id', table 'shortyTest.dbo.project'; column does not allow nulls. INSERT fails.
Can you please check latest commit f3-factory/fatfree-core@95d5f68 at master branch. I've just tested it with SQL Server 2017 myself now and it all works fine here.
please reopen if problem persists.