-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix: [SQLite3][Postgres][SQLSRV][OCI8] Forge::modifyColumn() changes NULL constraint incorrectly #7371
fix: [SQLite3][Postgres][SQLSRV][OCI8] Forge::modifyColumn() changes NULL constraint incorrectly #7371
Conversation
Because sanity-tests fail, we cannot run database-live-tests... |
6338612
to
156419a
Compare
6d2bfe1
to
89c4bc8
Compare
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have also changed the behavior of other drivers to match the behavior of MySQL.
89c4bc8
to
7480fd5
Compare
I 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
20cfb13
Compare
20cfb13
to
16177e7
Compare
07d4457
to
7e13c3a
Compare
9c05b29
to
e8e7a6b
Compare
5c2f42f
to
88c087c
Compare
e4be766
to
4653dff
Compare
Rebased and add upgrade note. |
@codeigniter4/database-team Please review. |
Any comment? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
I believe this code is okay. The issue is that this behavior is okay. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that using:
null
value
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.
It should be `NULL`.
Apply suggestions from code review Co-authored-by: Michal Sniatala <[email protected]>
bbbebf7
to
3b416c8
Compare
@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 NULL
unpredictably.NULL
/NOT NULL
when you don’t specifynull
value.$forge->modifyColumn()
always setsNULL
when you don’t specifynull
value.Checklist: