I've just started working with MySQL, but the other database I'm familiar with (mssql) treats the primary key and the autoincrement attributes of a field separately. And while I certainly don't mean to say what mssql implements is the right way, I had been under the impression that in general db terms they really are separate things. E.g. there could be instances where you want an integer primary key, but don't want it autoincrement.
Also, the native/idbroker thing is merely whether the database handles autoincrementing or the Torque idbroker does, I don't think it should give any indication as to which columns should or should be not autoincremented. James said that if you use idbroker with MySQL integer primary keys, they do autoincrement regardless of whether autoIncrement is set in the schema. To me, this is the bug. Autoincrementing should only be done if autoIncrement=true is set on a column. Can this patch be rolled back and the idbroker thing be changed so that it doesn't autoincrement whenever it sees an integer primary key? (I'm assuming that there is not a MySQL-specific reason that users would assume native MySQL primary keys would be autoincrement as compared to, say, mssql native primary keys which would not. E.g. MySQL automatically treats integer primary keys as autoincrement, but given that this patch is necessary, I assume there isn't). Thanks, Stephen > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Thursday, July 04, 2002 10:29 AM > To: [EMAIL PROTECTED] > Subject: cvs commit: jakarta-turbine-torque/src/templates/sql/base/mysql > columns.vm > > mpoeschl 2002/07/04 08:29:17 > > Modified: src/templates/sql/base/mysql columns.vm > Log: > patch by James Turner <[EMAIL PROTECTED]> > Assuming folks think (as I do) that native MySQL primary key columns should be > autoincrementing, here's a patch that implements it. > > Revision Changes Path > 1.4 +5 -0 jakarta-turbine-torque/src/templates/sql/base/mysql/columns.vm > > Index: columns.vm > > ===================================================== > ============== > RCS file: /home/cvs/jakarta-turbine- > torque/src/templates/sql/base/mysql/columns.vm,v > retrieving revision 1.3 > retrieving revision 1.4 > diff -u -r1.3 -r1.4 > --- columns.vm 8 Nov 2001 04:31:30 -0000 1.3 > +++ columns.vm 4 Jul 2002 15:29:17 -0000 1.4 > @@ -4,6 +4,11 @@ > #set ( $default = $col.DefaultSetting ) > #set ( $nullString = $strings.select($col.isNotNull(), > $dbprops.get("NOTNULL"),"") ) > #set ( $autoIncrement = $strings.select($col.isAutoIncrement(), > $dbprops.get("AUTOINCREMENT"),"") ) > + #if ((($database.getDefaultIdMethod() == "native") && ($table.getIdMethod() > == "")) || ($table.getIdMethod() == "native")) > + #if ($col.isPrimaryKey() && ($col.Type == "INTEGER")) > + #set ( $autoIncrement = $dbprops.get("AUTOINCREMENT")) > + #end > + #end > #set ( $entry = "$col.Name $type $size $default $nullString $autoIncrement," ) > $strings.sub($strings.collapseSpaces($entry)," ,",",") > #end > > > > > -- > To unsubscribe, e-mail: <mailto:turbine-torque-dev- > [EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:turbine-torque-dev- > [EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
