Attribut named "default" #6984

Closed
opened 2026-01-22 15:42:38 +01:00 by admin · 4 comments
Owner

Originally created by @Jcs1994 on GitHub (May 23, 2022).

Bug Report

Q A
BC Break no
Version 2.11.2

Summary

Doctrine doesn't handle an attribut named default, it crashes when inserting in database

Error in bootstrap script: Doctrine\DBAL\Exception\SyntaxErrorException:
An exception occurred while executing 'INSERT INTO X.myTable(enabled, default, deleted_at, created_at, updated_at, business_unit_id, ebics_connection_provider_id) VALUES (?, ?, ?, ?, ?, ?, ?)' with params [1, 0, null, "2022-05-23 13:07:48", "2022-05-23 13:07:48", "3", "5"]:

SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "default"
LINE 1: ...myTable (enabled, default, d..

Current behavior

An attribut named default make doctrine crash on INSERT

How to reproduce

Add an attribut to an entity named default

    /**
     * @ORM\Column(name="default", type="boolean", options={"default"=false})
     */
    private bool $default;

Generate migration (it's working)
$this->addSql('ALTER TABLE X.myTable ADD "default" BOOLEAN DEFAULT \'false\' NOT NULL');
Execute migration
Persist and flush the entity

You will get SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "default"
LINE 1: ...myTable (enabled, default, d..

Expected behavior

Doctrine should generate SQL with double quotes on default word

'INSERT INTO X.myTable(enabled, "default", deleted_at, created_at, updated_at, business_unit_id, ebics_connection_provider_id) VALUES (?, ?, ?, ?, ?, ?, ?)' with params [1, 0, null, "2022-05-23 13:07:48", "2022-05-23 13:07:48", "3", "5"]

Originally created by @Jcs1994 on GitHub (May 23, 2022). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | no | Version | 2.11.2 #### Summary Doctrine doesn't handle an attribut named `default`, it crashes when inserting in database ``` Error in bootstrap script: Doctrine\DBAL\Exception\SyntaxErrorException: An exception occurred while executing 'INSERT INTO X.myTable(enabled, default, deleted_at, created_at, updated_at, business_unit_id, ebics_connection_provider_id) VALUES (?, ?, ?, ?, ?, ?, ?)' with params [1, 0, null, "2022-05-23 13:07:48", "2022-05-23 13:07:48", "3", "5"]: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "default" LINE 1: ...myTable (enabled, default, d.. ``` #### Current behavior An attribut named `default` make doctrine crash on INSERT #### How to reproduce Add an attribut to an entity named `default` ``` /** * @ORM\Column(name="default", type="boolean", options={"default"=false}) */ private bool $default; ``` Generate migration (it's working) `$this->addSql('ALTER TABLE X.myTable ADD "default" BOOLEAN DEFAULT \'false\' NOT NULL');` Execute migration Persist and flush the entity ``` You will get SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "default" LINE 1: ...myTable (enabled, default, d.. ``` #### Expected behavior Doctrine should generate SQL with double quotes on `default` word 'INSERT INTO X.myTable(enabled, **"**default**"**, deleted_at, created_at, updated_at, business_unit_id, ebics_connection_provider_id) VALUES (?, ?, ?, ?, ?, ?, ?)' with params [1, 0, null, "2022-05-23 13:07:48", "2022-05-23 13:07:48", "3", "5"]
admin closed this issue 2026-01-22 15:42:39 +01:00
Author
Owner

@derrabus commented on GitHub (May 23, 2022):

What database engine and version is this?

@derrabus commented on GitHub (May 23, 2022): What database engine and version is this?
Author
Owner

@Jcs1994 commented on GitHub (May 23, 2022):

What database engine and version is this?

Postgres 12.9

@Jcs1994 commented on GitHub (May 23, 2022): > What database engine and version is this? Postgres 12.9
Author
Owner

@greg0ire commented on GitHub (May 23, 2022):

Aren't you supposed to quote that keyword? https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#quoting-reserved-words

@greg0ire commented on GitHub (May 23, 2022): Aren't you supposed to quote that keyword? https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#quoting-reserved-words
Author
Owner

@Jcs1994 commented on GitHub (May 23, 2022):

oh yes my bad

Aren't you supposed to quote that keyword? https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#quoting-reserved-words

@Jcs1994 commented on GitHub (May 23, 2022): oh yes my bad > Aren't you supposed to quote that keyword? https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#quoting-reserved-words
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6984