In outsystem database if we create a column with is mandatory as yes but still it does not create the column as not null in underlying database. Can you please tell me reason behind it?
Hello @Arnab Karmaker
In OutSystems, when you mark a column as Mandatory in the data model, it does not necessarily translate to a NOT NULL constraint in the underlying database. This behavior is due to how OutSystems manages data consistency and application logic. OutSystems enforces the Mandatory constraint at the application layer instead of the database layer. This allows the platform to ensure data integrity while keeping the underlying database schema flexible for future changes. When you mark a column as Mandatory, OutSystems automatically validates the data before committing it to the database. If an attempt is made to leave the column empty, the platform raises a validation error at runtime, preventing invalid data from being saved. If the database schema used a NOT NULL constraint, altering it later (e.g., making the column optional) would require database migration scripts to remove the constraint. By avoiding a NOT NULL constraint, OutSystems ensures smoother schema updates without requiring low-level database changes.
OutSystems often manages default values for columns behind the scenes. E.g: a Mandatory column of type Text might be stored as an empty string ('') or a Mandatory column of type Integer might have a default value of 0.
Because of this default value assignment, a NOT NULL constraint is less relevant in practice, as the platform always ensures a value is present before committing data.
Hope this helps.
Thank you, Sana, it was helpful.
I'm glad you found the solution! Please mark it as the accepted answer so others with the same question can benefit from it. Always happy to help! 😊
Logically it should not cause any error but if the column already contains NULL values, changing it to NOT NULL will cause a constraint violation. You will need to update the existing data to ensure there are no NULL values before applying the change.