Schema migration with default value of zero (0) does not set default value #2

Closed
opened 2017-01-18 04:30:16 +00:00 by jamie · 5 comments
jamie commented 2017-01-18 04:30:16 +00:00 (Migrated from git.hazaar.io)

Take the following schema migration:

{
    "up": {
        "alter": {
            "table": {
                "request_form": {
                    "add": {
                        "from_fred": {
                            "name": "from_fred",
                            "ordinal_position": 12,
                            "default": 0,
                            "not_null": false,
                            "data_type": "integer",
                            "length": null,
                            "primarykey": false
                        }
                    }
                }
            }
        }
    },
    "down": {
        "alter": {
            "table": {
                "request_form": {
                    "drop": [
                        "from_FRED"
                    ]
                }
            }
        }
    }
}

This column will not be set with a default value. I think it is because the check for the default is borking on the check due to zero resolving to false or something.

Take the following schema migration: ``` { "up": { "alter": { "table": { "request_form": { "add": { "from_fred": { "name": "from_fred", "ordinal_position": 12, "default": 0, "not_null": false, "data_type": "integer", "length": null, "primarykey": false } } } } } }, "down": { "alter": { "table": { "request_form": { "drop": [ "from_FRED" ] } } } } } ``` This column will not be set with a default value. I think it is because the check for the default is borking on the check due to zero resolving to ```false``` or something.
jamie commented 2017-01-18 04:30:58 +00:00 (Migrated from git.hazaar.io)

added ~152 label

added ~152 label
jamie commented 2017-04-01 00:07:01 +00:00 (Migrated from git.hazaar.io)

added ~160 label

added ~160 label
jamie commented 2017-06-21 23:25:23 +00:00 (Migrated from git.hazaar.io)

Tested this with a new table and the default is set correctly. Might be only on a column add.

Tested this with a new table and the default is set correctly. Might be only on a column add.
jamie commented 2017-06-21 23:27:53 +00:00 (Migrated from git.hazaar.io)

Confirmed. Creating the table as a whole, the default is set correctly. Adding a column the default is not set if it is zero.

Confirmed. Creating the table as a whole, the default is set correctly. Adding a column the default is not set if it is zero.
jamie commented 2017-06-21 23:38:35 +00:00 (Migrated from git.hazaar.io)

closed via commit bfc6c870f4

closed via commit bfc6c870f47b9f2521889ac1103191f0028a5085
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: hazaar/hazaar-dbi#2
No description provided.