Uh oh!
There was an error while loading. Please reload this page.
fix: [SQLite3][Postgres][SQLSRV][OCI8] Forge::modifyColumn() changes NULL constraint incorrectly - #7371
Conversation
kenjis
commented
Mar 23, 2023
Because sanity-tests fail, we cannot run database-live-tests... |
6338612 to
156419aCompare6d2bfe1 to
89c4bc8Comparekenjis
commented
Mar 23, 2023
Okay. SQLite3 database-live-tests passed. |
| $this->db->resetDataCache(); | ||
| $col1 = $this->getMetaData('col1', 'forge_test_modify'); | ||
| $this->assertTrue($col1->nullable); // Nullable if not specified. |
There was a problem hiding this comment.
@codeigniter4/database-team Should this be false? What do you think?
Maybe different databases have different defaults when not specifying null or not null?
There was a problem hiding this comment.
I have also changed the behavior of other drivers to match the behavior of MySQL.
89c4bc8 to
7480fd5CompareI didn't know but the following test passes on MySQL. $this->forge->dropTable('forge_test_modify', true);
$this->forge->addField([
'col1' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => false],
'col2' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => false],
'col3' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => false],
]);
$this->forge->createTable('forge_test_modify');
$this->forge->modifyColumn('forge_test_modify', [
'col1' => ['name' => 'new_name', 'type' => 'VARCHAR', 'constraint' => 1],
'col2' => ['type' => 'VARCHAR', 'constraint' => 1, 'null' => true],
'col3' => ['type' => 'VARCHAR', 'constraint' => 1, 'null' => false],
]);
$this->db->resetDataCache();
$col1 = $this->getMetaData('new_name', 'forge_test_modify');
$this->assertTrue($col1->nullable); // Nullable if not specified.$col2 = $this->getMetaData('col2', 'forge_test_modify');
$this->assertTrue($col2->nullable);
$col3 = $this->getMetaData('col3', 'forge_test_modify');
$this->assertFalse($col3->nullable);Added notes in the docs: 3b8a428 |
8068beb to
20cfb13Compare20cfb13 to
16177e7Compare07d4457 to
7e13c3aCompare9c05b29 to
e8e7a6bCompare5c2f42f to
88c087cComparee4be766 to
4653dffComparekenjis
commented
Mar 27, 2023
Rebased and add upgrade note. |
kenjis
commented
Apr 8, 2023
@codeigniter4/database-team Please review. |
kenjis
commented
Apr 25, 2023
Any comment? |
MGatner
left a comment
There was a problem hiding this comment.
I would prefer someone DB to take a look too but the code makes sense and tests look good so I trust this is appropriate.
kenjis
commented
Apr 26, 2023
I believe this code is okay. The issue is that this behavior is okay. |
michalsn
left a comment
There was a problem hiding this comment.
I think that using:
nullvalue
Could be a bit misleading, and some users may think they should define their table fields as null (at least for me). So, we could use something more specific.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
It should be `NULL`.
Apply suggestions from code review Co-authored-by: Michal Sniatala <michal@sniatala.pl>
bbbebf7 to
3b416c8Comparekenjis
commented
Apr 26, 2023
@michalsn Exactly! Applied your suggestions. |
Description
See #7302
$forge->modifyColumn()has been fixed. Due to a bug, in previous versions, SQLite3/Postgres/SQLSRV might changeNULL/NOT NULLunpredictably.NULL/NOT NULLwhen you don’t specifynullvalue.$forge->modifyColumn()always setsNULLwhen you don’t specifynullvalue.Checklist: