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
[email protected] -*- +46 703 - 970 612





_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to