Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Columns in create table default to nullable #33

@japettyjohn

Description

@japettyjohn

Column definitions should be non-nullable for native non pointer types.

When creating new tables the columns for non-pointer types are nullable in the database (at least for MariaDB). In the case that inserts/updates only goes through the API this is can be negated in terms a data integrity issue - but this cannot be guaranteed and it will certainly cause problems with the API to assign nulls to non-nilable fields.

From the performance end it may be implementation specific but mysql is faster with non-nullable columns (http://stackoverflow.com/questions/471367/when-to-use-null-in-mysql-tables).

This is addressed in the createTable of https://github.com/jmoiron/modl/blob/master/dbmap.go#L180 and is dependant on the ColumnMap here https://github.com/jmoiron/modl/blob/master/tablemap.go#L295 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions