#1 2016-08-11 08:26:05

jbroussia
Member
From: France
Registered: 2011-04-09
Posts: 74

Nullable types and columns declared as NOT NULL ?

Hi,

When using non nullable types for field definitions, shouldn't the corresponding columns in the tables have the "NOT NULL" constraint by default ? Also, shouldn't the ID column always be "NOT NULL" ?

Offline

#2 2016-08-11 08:57:01

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Nullable types and columns declared as NOT NULL ?

Since there won't be any NULL value sent by the ORM, there is little interest of defining such a constraint at SQL level.
Even if NULL are stored in the DB, the ORM would convert them into default values, e.g. 0 or ''.

If you use the RDBMS directly, you may define your own constraints.
But if you rely on the ORM, you can let the ORM do its stuff.

Offline

Board footer

Powered by FluxBB