notNull ignored for some field types

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • a.slyzhko
    Senior Member
    • Oct 2023
    • 133

    #1

    notNull ignored for some field types

    Hi,

    I noticed that notNull: true in entityDefs works for some field types, e.g. int, but seems to be ignored for: float, date, datetime, link, linkParent

    Example:

    Code:
    "amount": {
        "type": "float",
        "required": true,
        "notNull": true
    }
    still produces a nullable DB column.

    From the ORM converter, it looks like some field-type definitions override notNull, while FOREIGN_ID attributes are explicitly forced to notNull = false.

    Is this intentional behavior? Is there a recommended way to enforce DB-level NOT NULL for these field types?

    Thanks.
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 10054

    #2
    Hi,

    Some field types override it in: metadata > fields > {type} > fieldDefs > notNull.

    I can't say what was the intention to do it, as it was added 13 years ago and not by me. We very rarely needed to use the 'notNull' parameter for ordinary field types like 'date'.

    For link fields, it's likely defined in the field or relation converter.

    Comment

    Working...