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

Correctly parse boolean keywords (e.g. used in SQLite) in \yii\db\ColumnSchema::typecast() #20122

Merged
merged 2 commits into from
Mar 3, 2024

Conversation

rhertogh
Copy link
Contributor

@rhertogh rhertogh commented Mar 3, 2024

Q A
Is bugfix? ✔️
New feature?
Breaks BC?
Fixed issues -

SQLite uses keywords TRUE and FALSE for boolean values (https://www.sqlite.org/datatype3.html).

When creating a column with a default value of false this keyword is returned literally when getting the table definition. E.g.:
\Yii::$app->db->getSchema()->createColumnSchemaBuilder(Schema::TYPE_BOOLEAN)->defaultValue(false).

When this string is pared it always results in a true value (in PHP var_dump((bool)'false'); results in bool(true)).
This PR fixes the boolean parsing by ensuring the value is not the (case insensitive) string 'false'.

Copy link

what-the-diff bot commented Mar 3, 2024

PR Summary

  • Enhanced Typecasting in 'ColumnSchema.php'
    The function that converts different types of variables into another type has been updated in the ColumnSchema.php file. Now, it can handle 'boolean' values (true/false values) even if they are not written in a particular case, for example, not just 'false', but 'FALSE', 'False', 'fAlse' and so on. This improves the flexibility and user-friendliness of our system.

Copy link

codecov bot commented Mar 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.02%. Comparing base (78cc719) to head (8cf3f0f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #20122   +/-   ##
=======================================
  Coverage   48.02%   48.02%           
=======================================
  Files         445      445           
  Lines       43892    43892           
=======================================
  Hits        21080    21080           
  Misses      22812    22812           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

…emaDbTypecastBooleanPhpTypeProvider()` and added changelog line.
@rhertogh rhertogh marked this pull request as ready for review March 3, 2024 02:39
@samdark samdark added this to the 2.0.50 milestone Mar 3, 2024
@samdark samdark merged commit 283499c into yiisoft:master Mar 3, 2024
67 checks passed
@samdark
Copy link
Member

samdark commented Mar 3, 2024

Thank you!

skepticspriggan pushed a commit to skepticspriggan/yii2 that referenced this pull request Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants