You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AI summary:
This pull request introduces support for database-level default values (db_default) for fields, which allows default values to be enforced at the schema/database level rather than just in Python. This feature is reflected in the changelog, new migration examples, and updates to model and test code to ensure correct handling and description of db_default. The changes also include improvements to migration operations and model construction utilities.
New features and schema enhancements:
Added a db_default parameter for fields, enabling database-level DEFAULT clauses that persist in schema generation and migrations. This allows defaults to be enforced for rows inserted outside the ORM. (CHANGELOG.rst, CHANGELOG.rstL13-R28)
Updated Product model in models.py to include stock_quantity with a db_default value, and new migration files demonstrate adding, changing, and dropping db_default values for fields. (models.py, [1]; migrations/0018_add_db_defaults.py, [2]; migrations/0019_change_db_default.py, [3]; migrations/0020_drop_db_default.py, [4]
Updated early initialization tests to check for the presence and correct value of db_default in field metadata. (test_early_init.py, [1][2][3][4][5][6][7][8][9]
Migration and utility enhancements:
Added migration operations for setting, changing, and removing db_default values, ensuring schema changes are correctly handled and tested. (migrations/0018_add_db_defaults.py, [1]; migrations/0019_change_db_default.py, [2]; migrations/0020_drop_db_default.py, [3]
Changelog and documentation updates:
Updated CHANGELOG.rst to document the new db_default feature, model construction improvements, and several bug fixes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added explicit param for propagating value as default in database
Resolved #2091
AI summary:
This pull request introduces support for database-level default values (
db_default) for fields, which allows default values to be enforced at the schema/database level rather than just in Python. This feature is reflected in the changelog, new migration examples, and updates to model and test code to ensure correct handling and description ofdb_default. The changes also include improvements to migration operations and model construction utilities.New features and schema enhancements:
db_defaultparameter for fields, enabling database-levelDEFAULTclauses that persist in schema generation and migrations. This allows defaults to be enforced for rows inserted outside the ORM. (CHANGELOG.rst, CHANGELOG.rstL13-R28)Productmodel inmodels.pyto includestock_quantitywith adb_defaultvalue, and new migration files demonstrate adding, changing, and droppingdb_defaultvalues for fields. (models.py, [1];migrations/0018_add_db_defaults.py, [2];migrations/0019_change_db_default.py, [3];migrations/0020_drop_db_default.py, [4]Testing and introspection improvements:
db_defaultin their output, ensuring that both the serialized and native representations correctly reflect the new parameter. (test_describe_model.py, [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21]db_defaultin field metadata. (test_early_init.py, [1] [2] [3] [4] [5] [6] [7] [8] [9]Migration and utility enhancements:
db_defaultvalues, ensuring schema changes are correctly handled and tested. (migrations/0018_add_db_defaults.py, [1];migrations/0019_change_db_default.py, [2];migrations/0020_drop_db_default.py, [3]Changelog and documentation updates:
CHANGELOG.rstto document the newdb_defaultfeature, model construction improvements, and several bug fixes.