On 10/19/07, Oleg Broytmann <[EMAIL PROTECTED]> wrote: > Hello! Hi Oleg,
> On Fri, Oct 19, 2007 at 09:39:05AM +0200, Markus Gritsch wrote: > > in SQLObject a BoolCol() is stored as TINYINT(4) in the MySQL backend > > and as TINYINT in the SQLite backend. Both are not optimal IMO: > > Booleans are stored as TINYINT which is TINYINT(1). Why do you think it > is TINYINT(4)?! > > See http://dev.mysql.com/doc/refman/4.1/en/numeric-types.html >From this page I cannot tell that TINYINT is the equivalent to TINYINT(1), maybe I just didn't see it. When running the following code #--- from sqlobject import * class Table1( SQLObject ): name = BoolCol() sqlhub.threadConnection = connectionForURI( 'mysql://[EMAIL PROTECTED]/test?debug=True' ) Table1.dropTable( ifExists = True ) Table1.createTable( ifNotExists = True ) #--- which results in the following debug output 1/Query : DESCRIBE table1 1/Query : DESCRIBE table1 1/Query : CREATE TABLE table1 ( id INT PRIMARY KEY AUTO_INCREMENT, name TINYINT ) the table seen in the attachment is created. It says TINYINT(4). > > *) MySQL knows BOOL (and since version 4.1 also BOOLEAN), which is a > > synonym for TINYINT(1). > > (http://dev.mysql.com/doc/refman/4.1/en/numeric-type-overview.html) > > Ok. As they're only synonyms I think I can use them in the current > branches. Expect a new round of betas today or in a few days. > > > *) TINYINT is not part of ANSI SQL and should IMO therefore not be > > used in the SQLite backend. SQLAlchemy uses BOOLEAN. > > Due to "column affinity" I'd better use a name that contains "INT" > - just INT(1) or INTEGER(1): http://sqlite.org/datatype3.html > Ok? Specifying INT or INTEGER or something else does IMO not really have any impact on the column affinity of SQLite. As I see it, the affinity changes according to the data stored in the column. Maybe I'm wrong. However, SQLite also accepts 'FOO' or 'BAR' as the column type when creating the table. As of INT(1): From looking at the ANSI SQL standard, I think it is not possible to add parenthesis after INT: http://savage.net.au/SQL/sql-99.bnf.html#exact%20numeric%20type A few lines below there is a boolean type specified, which should IMO be used (as it is done in SQLAlchemy): http://savage.net.au/SQL/sql-99.bnf.html#boolean%20type Kind regards, Markus
<<attachment: screenshot.png>>
------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss