DDC-215: not null is not working using YAML #268

Closed
opened 2026-01-22 12:32:56 +01:00 by admin · 1 comment
Owner

Originally created by @doctrinebot on GitHub (Dec 16, 2009).

Jira issue originally created by user hgirardi:

I've created this:

Test:
type: entity
table: test
fields:
id:
type: integer
id: true
generator:
strategy: auto
sequenceGenerator:
sequenceName: test_id_seq
allocationSize: 1
initialValue: 1
nome:
type: string
length: 300
sigla:
type: string
length: 5
notnull: false

result:
CREATE TABLE test (id INT NOT NULL, nome TEXT NOT NULL, sigla VARCHAR(5) DEFAULT NOT NULL, PRIMARY KEY(id))
CREATE SEQUENCE test_id_seq INCREMENT BY 1 START 1

I debuged doctrine's code and saw in the
lib/Doctrine/ORM/Tools/SchemaTool.php on _gatherColumn method
that is tested
$column['notnull'] = isset($mapping['nullable']) ? ! $mapping['nullable'] : true;
on line 266

but in lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php there's not any check for 'nullable', just 'notnull'...
on line 193 there's this validation:
if (isset($fieldMapping['notnull'])) {;
$mapping['notnull'] = $fieldMapping['notnull'];
}

if I insert this validation:
if (isset($fieldMapping['nullable'])) {;
$mapping['nullable'] = $fieldMapping['nullable'];
}

it's gonna work just fine...

Originally created by @doctrinebot on GitHub (Dec 16, 2009). Jira issue originally created by user hgirardi: I've created this: Test: type: entity table: test fields: id: type: integer id: true generator: strategy: auto sequenceGenerator: sequenceName: test_id_seq allocationSize: 1 initialValue: 1 nome: type: string length: 300 sigla: type: string length: 5 notnull: false result: CREATE TABLE test (id INT NOT NULL, nome TEXT NOT NULL, sigla VARCHAR(5) DEFAULT NOT NULL, PRIMARY KEY(id)) CREATE SEQUENCE test_id_seq INCREMENT BY 1 START 1 I debuged doctrine's code and saw in the lib/Doctrine/ORM/Tools/SchemaTool.php on _gatherColumn method that is tested $column['notnull'] = isset($mapping['nullable']) ? ! $mapping['nullable'] : true; on line 266 but in lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php there's not any check for 'nullable', just 'notnull'... on line 193 there's this validation: if (isset($fieldMapping['notnull'])) {; $mapping['notnull'] = $fieldMapping['notnull']; } if I insert this validation: if (isset($fieldMapping['nullable'])) {; $mapping['nullable'] = $fieldMapping['nullable']; } it's gonna work just fine...
admin added the Bug label 2026-01-22 12:32:56 +01:00
admin closed this issue 2026-01-22 12:32:56 +01:00
Author
Owner

@doctrinebot commented on GitHub (Dec 19, 2009):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Dec 19, 2009): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#268