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

Bug: NULL Fields definition not working for MSQLi Forge in Migration due property $_null and $null names difference #4693

Closed
joelsodias opened this issue May 17, 2021 · 0 comments · Fixed by #4696
Labels
bug Verified issues on the current code behavior or pull requests that will fix them database Issues or pull requests that affect the database layer

Comments

@joelsodias
Copy link
Contributor

Describe the bug

Using Migrations, when you define NULL fields, they are not created as NULLable in MariaDB database.

Table definition with 3 fields set up as NULLable
image

Look at the result table in database, where the 3 fields do not accept NULL
image

Looking at Database\Forge.php I noticed there is a differente between a protected property $_null in MySQLi\Forge and $null in Database\Forge

Here it is possible to see when the decision depends on the $null property wich is empty
image

Unfortunately in MySQLi\Forge the property is defined as $_null so it is ignored by Database\Forge
image

Suggested Solution

As far as I could work on it, it is a simply change $_null to $null in MySQLi\Forge line 92 solves the problem

After the change NULLable filds passed to work as expected.

image

It still need some additional tests to understand why $_null was written like that, as well as search for any colateral behavior.

CodeIgniter 4 version
Master Branch

Affected module(s)
vendor\codeigniter4\framework\system\Database\MySQLi\Forge.php

@joelsodias joelsodias added the bug Verified issues on the current code behavior or pull requests that will fix them label May 17, 2021
@paulbalandan paulbalandan added the database Issues or pull requests that affect the database layer label May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them database Issues or pull requests that affect the database layer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants