Skip to content
Snippets Groups Projects

Fixed null default value (closes #9)

Merged Daniel Kurowski requested to merge 9-fix-default-value-null into master

Closes #9 (closed)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Daniel Kurowski added 4 commits

    added 4 commits

    Compare with previous version

  • lgtm :thumbsup:

    For the record, there's an edge case:

    CREATE DOMAIN whatever AS TEXT DEFAULT 'definitely not null';
    CREATE TABLE tbl (
        id int,
        col whatever NOT NULL
    );
    
    INSERT INTO tbl (id) VALUES (1) RETURNING *;

    gives you

    id | col
    ---|--------------------
    1  | definitely not null

    If a column doesn't specify its default value, the database falls back to the default value of the column's type. Incidentally, that is null for all postgres's base types (with some negligible internal exceptions) but, as demonstrated, it doesn't have to be null for user-defined types.

    If we wanted to be rigorous about this, we'd also have to cross-check pg_type.typdefault of the column's type. But I don't think we need to go into such depths atm. I'll create a follow-up.

  • Jiří Pudil approved this merge request

    approved this merge request

  • merged

  • Jiří Pudil mentioned in commit d5d30557

    mentioned in commit d5d30557

  • Jiří Pudil mentioned in issue #11

    mentioned in issue #11

Please register or sign in to reply
Loading