[Dbix-class] any factual comparisons of Oracle, PostgreSQL,
MySQL ?
Calle Dybedahl
calle at init.se
Fri Apr 15 06:50:50 GMT 2011
On 14 apr 2011, at 19:19, Matija Grabnar wrote:
>>
>
> Yes, you can put an empty string into a NOT NULL text column. You can also put a zero
> into a NOT NULL int column. Both are legitimate values for the type. And no, mysql will NOT
> accept a NULL value in a NOT NULL text column.
>
That's not the problem. This is the problem:
mysql> create table foo (bar text not null);
Query OK, 0 rows affected (0.07 sec)
mysql> insert into foo values ();
Query OK, 1 row affected, 1 warning (0.02 sec)
mysql> select * from foo;
+-----+
| bar |
+-----+
| |
+-----+
1 row in set (0.00 sec)
No NULL, no error. Just a warning and an empty string made up out of whole cloth. I expect a real database to reject that insert.
The warning, by the way, is this:
mysql> show warnings;
+---------+------+------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------+
| Warning | 1364 | Field 'bar' doesn't have a default value |
+---------+------+------------------------------------------+
Only if you try to set a default value, MySQL tells you that TEXT and BLOB columns can't have them.
--
Calle Dybedahl
calle at init.se -*- +46 703 - 970 612
More information about the DBIx-Class
mailing list