On Oct 8, 9:58 am, "[email protected]" <[email protected]> wrote:
> http://www.google.com/url?sa=D&q=http://groups.google.com/group/sqlalchemy/browse_thread/thread/b9c020804456f066/c0a817c7f2133bbe&usg=AFQjCNGDNc-jptHjVeCKGE6qIa_Duh6YBw
>
> I had grumbled that mapping tinyint(1) to bool was an issue for people
> who were simply trying to process small integers.  I had no idea that
> some people used that as a convention for indicating a boolean field
> in MySQL.
>
> Since 1 == True and 0 == False, an integer field will behave like a
> bool for people who simply code with boolean values.

Well, as the other thread stated, if you ask MySQL for a bool, you get
a TINYINT(1) back, which isn't precisely the same as a default
TINYINT:

mysql> create table foo (a bool, another tinyint);
Query OK, 0 rows affected (0.00 sec)

mysql> show create table foo\G
*************************** 1. row ***************************
       Table: foo
Create Table: CREATE TABLE `foo` (
  `a` tinyint(1) default NULL,
  `another` tinyint(4) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

But as I said, it's not a big deal for me, since we can handle it
cleanly in the translation to base declarative.  I guess I should
submit a changeset for the docs to clarify the new behaviour then.

And yes, we end up throwing this data into JSON, so we really do want
it coerced to a Python boolean ASAP. :)

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
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.

Reply via email to