Dbforge alter add column always create NOT NULL field |
Hi!
The query of ALTER TABLE ADD COLUMN is automatically concatened by NOT NULL in CodeIgniter working with PostgreSQL PHP Code: $this->dbforge = new CI_DB_postgre_forge; So I always got an error message when there is already data inside the table: i'm using a french computer ERREUR: la colonne « location » contient des valeurs NULL ALTER TABLE "data"."circuits" ADD "location" integer NOT NULL How to avoid this ?
I don't know if it is a bug but I add these lines when I call for add_column or _alter_table() now:
PHP Code: if (substr($sql, -8, 8) == "NOT NULL") { Remove the last NOT NULL text in CodeIgniter-built query
https://codeigniter.com/userguide2/database/forge.html
PHP Code: $field = array( You shouldn't be calling _alter_table() directly, but, if you need to call it directly for some reason, you should look at the function definition, because the ~6th argument controls whether the field is defined with ' NULL' or ' NOT NULL'.
Thanks for your return. I am newbie with CI so I didn't dare to step inside CI system codes!
|
Welcome Guest, Not a member yet? Register Sign In |