text column.Run this:
Yii::$app->db->createCommand()->insert('table_name', [
'column_name' => '' // empty string
])->execute();
The row should be inserted.
A yii\db\IntegrityException exception is thrown because the empty string gets converted to null by yii\db\ColumnSchema::typecast(), despite the ColumnSchema鈥檚 $allowNull property being set to false.
| Q | A
| ---------------- | ---
| Yii version | 2.0.15.1
I fixed this in Craft by extending yii\db\ColumnSchema and overriding the typecast() method: craftcms/cms@6140530a69692a90d08e5eacb24cdfe0b984edb9
Would you like to make a pull request to Yii?
done :)
Nevermind, I misunderstood what the code was doing (missed the ! before in_array(). Bug ended up being due to Craft adding support for additional text column types (mediumtext, etc.). So it makes sense that the fix should only be implemented in Craft: craftcms/cms@c3568e4e444cfcb0d73a0ea553cd0bae183f2d07
Most helpful comment
Nevermind, I misunderstood what the code was doing (missed the
!beforein_array(). Bug ended up being due to Craft adding support for additional text column types (mediumtext, etc.). So it makes sense that the fix should only be implemented in Craft: craftcms/cms@c3568e4e444cfcb0d73a0ea553cd0bae183f2d07