You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by "Will Glass-Husain (JIRA)" <ji...@apache.org> on 2007/10/25 19:40:50 UTC

[jira] Created: (TORQUE-106) Use "boolean" sql type not "bit" sql type with MySQL

Use "boolean" sql type not "bit" sql type with MySQL
----------------------------------------------------

                 Key: TORQUE-106
                 URL: https://issues.apache.org/jira/browse/TORQUE-106
             Project: Torque
          Issue Type: Bug
    Affects Versions: 3.2
            Reporter: Will Glass-Husain


In MySQL 5.0.3 the meaning of the BIT data type changed.  It used to be equivalent to tinyint(1) but now it is a new bitwise datatype.  This means that when Torque generates SQL files with a "bit" data type (mapped to the Java boolean) it is incorrect.

I suggest that Torque map the Torque "bit" type to the MySQL "Boolean" type instead when generating SQL.  See the reference from the MySQL manual below.

http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html

* BIT[(M)]

      A bit-field type. M indicates the number of bits per value, from 1 to 64. The default is 1 if M is omitted.

      This data type was added in MySQL 5.0.3 for MyISAM, and extended in 5.0.5 to MEMORY, InnoDB, and BDB. Before 5.0.3, BIT is a synonym for TINYINT(1).
    
*  TINYINT[(M)] [UNSIGNED] [ZEROFILL]

      A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.
   
* BOOL, BOOLEAN

      These types are synonyms for TINYINT(1). A value of zero is considered false. Non-zero values are considered true: 



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Commented: (TORQUE-106) Use "boolean" sql type not "bit" sql type with MySQL

Posted by "Thomas Fischer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TORQUE-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12539348 ] 

Thomas Fischer commented on TORQUE-106:
---------------------------------------

I do not understand the problem. The test project explicitly tests reading and writing booleans and it definitely works with mysql 5.
Are you saying that BOOL would be more appropriate or are there any errors you encounter ? If the latter is the case, please give details.
If the former is the case, what would be the advantage of using BOOL over BIT(1) ?

I am reluctant to change stuff if nothing is improved by it.
Even if the decision was made to change stuf, I'd not do it between RC's, unless it resolves a bug.


> Use "boolean" sql type not "bit" sql type with MySQL
> ----------------------------------------------------
>
>                 Key: TORQUE-106
>                 URL: https://issues.apache.org/jira/browse/TORQUE-106
>             Project: Torque
>          Issue Type: Bug
>    Affects Versions: 3.2
>            Reporter: Will Glass-Husain
>         Attachments: mysqlpatch.patch
>
>
> In MySQL 5.0.3 the meaning of the BIT data type changed.  It used to be equivalent to tinyint(1) but now it is a new bitwise datatype.  This means that when Torque generates SQL files with a "bit" data type (mapped to the Java boolean) it is incorrect.
> I suggest that Torque map the Torque "bit" type to the MySQL "Boolean" type instead when generating SQL.  See the reference from the MySQL manual below.
> http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html
> * BIT[(M)]
>       A bit-field type. M indicates the number of bits per value, from 1 to 64. The default is 1 if M is omitted.
>       This data type was added in MySQL 5.0.3 for MyISAM, and extended in 5.0.5 to MEMORY, InnoDB, and BDB. Before 5.0.3, BIT is a synonym for TINYINT(1).
>     
> *  TINYINT[(M)] [UNSIGNED] [ZEROFILL]
>       A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.
>    
> * BOOL, BOOLEAN
>       These types are synonyms for TINYINT(1). A value of zero is considered false. Non-zero values are considered true: 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Updated: (TORQUE-106) Use "boolean" sql type not "bit" sql type with MySQL

Posted by "Will Glass-Husain (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TORQUE-106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Will Glass-Husain updated TORQUE-106:
-------------------------------------

    Attachment: mysqlpatch.patch

> Use "boolean" sql type not "bit" sql type with MySQL
> ----------------------------------------------------
>
>                 Key: TORQUE-106
>                 URL: https://issues.apache.org/jira/browse/TORQUE-106
>             Project: Torque
>          Issue Type: Bug
>    Affects Versions: 3.2
>            Reporter: Will Glass-Husain
>         Attachments: mysqlpatch.patch
>
>
> In MySQL 5.0.3 the meaning of the BIT data type changed.  It used to be equivalent to tinyint(1) but now it is a new bitwise datatype.  This means that when Torque generates SQL files with a "bit" data type (mapped to the Java boolean) it is incorrect.
> I suggest that Torque map the Torque "bit" type to the MySQL "Boolean" type instead when generating SQL.  See the reference from the MySQL manual below.
> http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html
> * BIT[(M)]
>       A bit-field type. M indicates the number of bits per value, from 1 to 64. The default is 1 if M is omitted.
>       This data type was added in MySQL 5.0.3 for MyISAM, and extended in 5.0.5 to MEMORY, InnoDB, and BDB. Before 5.0.3, BIT is a synonym for TINYINT(1).
>     
> *  TINYINT[(M)] [UNSIGNED] [ZEROFILL]
>       A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.
>    
> * BOOL, BOOLEAN
>       These types are synonyms for TINYINT(1). A value of zero is considered false. Non-zero values are considered true: 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Commented: (TORQUE-106) Use "boolean" sql type not "bit" sql type with MySQL

Posted by "Will Glass-Husain (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TORQUE-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12538106 ] 

Will Glass-Husain commented on TORQUE-106:
------------------------------------------

Thanks for the detailed response.  

I'm not sure it makes sense though.  Torque already has hardcoded MySQL compatibility features.  MySQL 5.0.3 was released March 23, 2005 -- over 2.5 years ago.  Gradually, all the MYSQL users will hit this problem.    (And I'm guessing a large percentage of Torque users are MySQL users).

There may be other MySQL 5 optimizations that would be useful as well. (Subqueries were finally supported in MYSQL 4.1, for example).   

Incidentally, Hibernate solved this issue with a MySQL and a MYSQL5 mode.

I guess in the meantime I'll make a custom adapter.    I see now that it's not too difficult.

WILL



> Use "boolean" sql type not "bit" sql type with MySQL
> ----------------------------------------------------
>
>                 Key: TORQUE-106
>                 URL: https://issues.apache.org/jira/browse/TORQUE-106
>             Project: Torque
>          Issue Type: Bug
>    Affects Versions: 3.2
>            Reporter: Will Glass-Husain
>         Attachments: mysqlpatch.patch
>
>
> In MySQL 5.0.3 the meaning of the BIT data type changed.  It used to be equivalent to tinyint(1) but now it is a new bitwise datatype.  This means that when Torque generates SQL files with a "bit" data type (mapped to the Java boolean) it is incorrect.
> I suggest that Torque map the Torque "bit" type to the MySQL "Boolean" type instead when generating SQL.  See the reference from the MySQL manual below.
> http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html
> * BIT[(M)]
>       A bit-field type. M indicates the number of bits per value, from 1 to 64. The default is 1 if M is omitted.
>       This data type was added in MySQL 5.0.3 for MyISAM, and extended in 5.0.5 to MEMORY, InnoDB, and BDB. Before 5.0.3, BIT is a synonym for TINYINT(1).
>     
> *  TINYINT[(M)] [UNSIGNED] [ZEROFILL]
>       A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.
>    
> * BOOL, BOOLEAN
>       These types are synonyms for TINYINT(1). A value of zero is considered false. Non-zero values are considered true: 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Commented: (TORQUE-106) Use "boolean" sql type not "bit" sql type with MySQL

Posted by "Thomas Vandahl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TORQUE-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12538325 ] 

Thomas Vandahl commented on TORQUE-106:
---------------------------------------

I remember a problem with bit columns in the runtime test of Torque against MYSQL-5 which could be solved by using a new MYSQL JDBC driver, version 5.0 or higher. Could you please check if that applies to your case, too?

> Use "boolean" sql type not "bit" sql type with MySQL
> ----------------------------------------------------
>
>                 Key: TORQUE-106
>                 URL: https://issues.apache.org/jira/browse/TORQUE-106
>             Project: Torque
>          Issue Type: Bug
>    Affects Versions: 3.2
>            Reporter: Will Glass-Husain
>         Attachments: mysqlpatch.patch
>
>
> In MySQL 5.0.3 the meaning of the BIT data type changed.  It used to be equivalent to tinyint(1) but now it is a new bitwise datatype.  This means that when Torque generates SQL files with a "bit" data type (mapped to the Java boolean) it is incorrect.
> I suggest that Torque map the Torque "bit" type to the MySQL "Boolean" type instead when generating SQL.  See the reference from the MySQL manual below.
> http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html
> * BIT[(M)]
>       A bit-field type. M indicates the number of bits per value, from 1 to 64. The default is 1 if M is omitted.
>       This data type was added in MySQL 5.0.3 for MyISAM, and extended in 5.0.5 to MEMORY, InnoDB, and BDB. Before 5.0.3, BIT is a synonym for TINYINT(1).
>     
> *  TINYINT[(M)] [UNSIGNED] [ZEROFILL]
>       A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.
>    
> * BOOL, BOOLEAN
>       These types are synonyms for TINYINT(1). A value of zero is considered false. Non-zero values are considered true: 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Commented: (TORQUE-106) Use "boolean" sql type not "bit" sql type with MySQL

Posted by "CG Monroe (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TORQUE-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12538052 ] 

CG Monroe commented on TORQUE-106:
----------------------------------

Torque is designed to work across a wide variety of SQL servers and versions.  IMHO, this means there are a lot of "compromises" that go into Torque's design.  One of these is to try to limit the number of DB adapter variations.  I.e., we try not to have subversions of the major types of adapters, e.g MySQL5 and MySQL or MSSQL7, MSSQL2000, and MSSQL2005.  The main reason for this is that keeping track of all the little quirks and foibles of server versions, adds a LOT of effort to the release and maintenance testing.  

AFAIK, this change can't be implemented without either breaking compatibility with older version of MySQL or creating a new version-ed MySQL adapter.  I'm not sure the added benefit of a little bit of storage space saved is worth it.  Especially, since (AFAIK) the generated runtime code will still work with both a field generated from Torque's SQL and a "manually" generate new field.  (JDBC driver should interprate boolean, int 1/0, and the like correctly).

That said, if you have an application/site specific need for this level of support, Torque now allows for the easy creation of custom adapters and template files.  

There may be other issues here I'm not seeing and other folks may have different ideas... but this is my initial take on this.

> Use "boolean" sql type not "bit" sql type with MySQL
> ----------------------------------------------------
>
>                 Key: TORQUE-106
>                 URL: https://issues.apache.org/jira/browse/TORQUE-106
>             Project: Torque
>          Issue Type: Bug
>    Affects Versions: 3.2
>            Reporter: Will Glass-Husain
>         Attachments: mysqlpatch.patch
>
>
> In MySQL 5.0.3 the meaning of the BIT data type changed.  It used to be equivalent to tinyint(1) but now it is a new bitwise datatype.  This means that when Torque generates SQL files with a "bit" data type (mapped to the Java boolean) it is incorrect.
> I suggest that Torque map the Torque "bit" type to the MySQL "Boolean" type instead when generating SQL.  See the reference from the MySQL manual below.
> http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html
> * BIT[(M)]
>       A bit-field type. M indicates the number of bits per value, from 1 to 64. The default is 1 if M is omitted.
>       This data type was added in MySQL 5.0.3 for MyISAM, and extended in 5.0.5 to MEMORY, InnoDB, and BDB. Before 5.0.3, BIT is a synonym for TINYINT(1).
>     
> *  TINYINT[(M)] [UNSIGNED] [ZEROFILL]
>       A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.
>    
> * BOOL, BOOLEAN
>       These types are synonyms for TINYINT(1). A value of zero is considered false. Non-zero values are considered true: 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org