fuel / core

Fuel PHP Framework - The core of the Fuel v1 framework
http://fuelphp.com
813 stars 345 forks source link

Fields accept NULL by default #248

Closed ghost closed 13 years ago

ghost commented 13 years ago

According to the docs, specifically at: http://fuelphp.com/docs/classes/database/dbutil.html#method_create_table

When specifying whether a field can be null, it states "boolean, true if nullable, defaults to false". This however is not the case. Unless you specify it not to allow null, the fields will allow it.

The fix: $sql .= array_key_exists('NULL', $attr) ? (($attr['NULL'] === true) ? ' NULL' : ' NOT NULL') : ''; becomes: $sql .= array_key_exists('NULL', $attr) ? (($attr['NULL'] === true) ? ' NULL' : ' NOT NULL') : ' NOT NULL';

Line 176 of /fuel/core/classes/dbutil.php from the latest RC.

Perhaps I just misunderstood what the docs said, but it seems like that should be the functionality.

Additionally, when utilizing the ORM and having NOT NULL available, it seems that I get a "Column cannot be null" error when using empty values, as the ORM seems to attempt to set it as NULL when really I just meant blank.

Hopefully we can all figure something out ;)

WanWizard commented 13 years ago

This line is different from the one in the develop branch, so I have to assume it's has already been fixed.

ghost commented 13 years ago

Do you know of anything addressing the issue with the ORM and null values?

WanWizard commented 13 years ago

There is no issue in the fuel/orm issue list regarding null values. If there is, please create an issue there.