[sqlalchemy] Re: Problem with non-null fields

2008-05-09 Thread jason kirtland

TP wrote:
 Hi, I have a model with a field called 'name' that is set to be non-
 null. When I look at the actual table created in MySQL the field
 really does say it cannot be null. However, when I try to set it to
 None and commit() the changes, I get a warning printed
 
 /Users/tp/sw/python-extensions/lib/python2.5/site-packages/
 SQLAlchemy-0.4.5-py2.5.egg/sqlalchemy/databases/mysql.py:1488:
 Warning: Column 'name' cannot be null
 
 
 But the underlying database IS changed with the field being set to the
 empty string ''.
 
 This seems wrong doesn't it? Am I doing something wrong? I'm using
 SQLAlchemy 0.4.5 on Mac OS X with MySQL 5.1.
 
 Thanks for any help!

It's a server configuration issue- the server is using a legacy 
compatibility mode.  Check the mysql docs for configuring sql mode to a 
modern, strict setting.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Problem with non-null fields

2008-05-09 Thread TP

Who knew that marking a field as non-null didn't really make it non-
null? Apparently you have to add the following to your my.cnf to tell
MySQL your're actually serious about enforcing things:

sql-mode='STRICT_TRANS_TABLES'

On May 9, 11:30 am, jason kirtland [EMAIL PROTECTED] wrote:
 TP wrote:
  Hi, I have a model with a field called 'name' that is set to be non-
  null. When I look at the actual table created in MySQL the field
  really does say it cannot be null. However, when I try to set it to
  None and commit() the changes, I get a warning printed

  /Users/tp/sw/python-extensions/lib/python2.5/site-packages/
  SQLAlchemy-0.4.5-py2.5.egg/sqlalchemy/databases/mysql.py:1488:
  Warning: Column 'name' cannot be null

  But the underlying database IS changed with the field being set to the
  empty string ''.

  This seems wrong doesn't it? Am I doing something wrong? I'm using
  SQLAlchemy 0.4.5 on Mac OS X with MySQL 5.1.

  Thanks for any help!

 It's a server configuration issue- the server is using a legacy
 compatibility mode.  Check the mysql docs for configuring sql mode to a
 modern, strict setting.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---