Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Server Identity Insert #1193

Closed
NoToComments opened this issue Jun 24, 2020 · 4 comments
Closed

SQL Server Identity Insert #1193

NoToComments opened this issue Jun 24, 2020 · 4 comments

Comments

@NoToComments
Copy link

NoToComments commented Jun 24, 2020

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

@xfra35
Copy link
Collaborator

xfra35 commented Jun 24, 2020

I guess you're talking about the SQL mapper right? Can you provide a code sample?

@NoToComments
Copy link
Author

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.

@ikkez
Copy link
Collaborator

ikkez commented Jun 26, 2020

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.

@ikkez ikkez added the duplicate label Jul 7, 2020
@ikkez
Copy link
Collaborator

ikkez commented Jul 7, 2020

please reopen if problem persists.

@ikkez ikkez closed this as completed Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants