Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating rules for the fields with default values #537

Merged
merged 4 commits into from
Oct 24, 2023

Conversation

manky
Copy link
Contributor

@manky manky commented Sep 27, 2023

Q A
Is bugfix?
New feature? ✔️
Breaks BC?

This may sound unimportant, but if you are using yii\behaviors\AttributeTypecastBehavior and the cast depends on the rules() method of your model, for example, fields validated via yii\validators\NumberValidator and without any value will be cast to integer/float. So the value of the empty fields will become 0

An important part is that default rules should be at the beginning of the rule list.

@what-the-diff
Copy link

what-the-diff bot commented Sep 27, 2023

PR Summary

  • Introduction of $nullable and $defaultValues Arrays
    We have introduced two new arrays - $nullable and $defaultValues. These arrays are used to specify if certain columns are allowed to be null and to provide default values to some columns respectively.

  • Updating $nullable for Specific Columns
    We have made changes in the code that allow us to ensure that, for specific columns which are allowed to be null, there can be entries in the $nullable array indicating this.

  • Populating $defaultValues for Given Columns
    Changes have also been made that allow us to provide default values for specific columns, if any. These are then recorded in the $defaultValues array.

  • Added Validation for Nullable and Default Value Columns
    New validation rules have been included to check the columns that are nullable or have default values. This helps in reducing errors and ensuring data integrity.

  • Modification in Database Driver Name Checking
    A modification has been made in the condition that checks the database driver name. Now, it specifically checks if the driver's name is 'pgsql' and the column type is 'integer'. This ensures more accurate and efficient checking of database driver specifications.

@manky manky changed the title Add: Generating rules for the fields with default values Generating rules for the fields with default values Sep 27, 2023
@manky manky marked this pull request as ready for review September 28, 2023 10:57
@samdark samdark added the type:enhancement Enhancement label Oct 19, 2023
Copy link
Member

@samdark samdark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Please add a line for changelog. Thanks.

@manky
Copy link
Contributor Author

manky commented Oct 24, 2023

The line has been added to the changelog. Thanks.

@samdark samdark merged commit be02a08 into yiisoft:master Oct 24, 2023
11 checks passed
@samdark
Copy link
Member

samdark commented Oct 24, 2023

Thank you!

@samdark samdark added this to the 2.2.7 milestone Oct 24, 2023
thiagotalma added a commit to thiagotalma/yii2-gii that referenced this pull request Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants