You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Peter Frühberger <Pe...@hte-company.de> on 2008/03/13 11:46:08 UTC

Possible incorrect unique.vm in mysql

I am using version 3.3-RC3 of the torque maven plugin.


The following snippet of code:
<unique name="NAME_IDX">
<unique-column name="NAME"/>	
</unique>

generates the following mysql code:

Create ...
	...
    UNIQUE (NAME)
);

The unique index name (NAME_IDX) is missing, it should correctly be:

Create ...
	UNIQUE NAME_IDX (NAME);
);


changing the unique.vm in sql/base/mysql/unique.vm from
#foreach ($unique in $table.Unices) 
UNIQUE($unique.ColumnList), 
#end

to
#foreach ($unique in $table.Unices) 
UNIQUE $unique.Name ($unique.ColumnList), 
#end


fixes this problem for me.

Thx
Peter Frühberger
(sorry for sending through an exchange server ;-))




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


RE: Possible incorrect unique.vm in mysql

Posted by Peter Frühberger <Pe...@hte-company.de>.
Issue filed at:
http://issues.apache.org/jira/browse/TORQUE-110

Peter

Am Donnerstag, den 13.03.2008, 15:26 +0100 schrieb Peter Frühberger:
> I will do this, but momentarily the apache bugtracker site is a bit
> laggy, needs endless time to load...
> 
> I` ll recheck tomorrow
> 
> Thx again
> Peter
> 
> Am Donnerstag, den 13.03.2008, 15:01 +0100 schrieb Thomas Fischer:
> > Ah ok, I overlooked that a name could be specified. But the dtd says
> > 
> > <!ELEMENT index (option*,index-column+)>
> > <!ATTLIST index
> >   name CDATA #IMPLIED
> > >
> > 
> > and in this case you are right, the name should be used.  Would you mind to
> > create a jira issue ?
> > 
> >    Thanks,
> > 
> >      Thomas
> > 
> > 
> > Peter Frühberger <Pe...@hte-company.de> schrieb am 13.03.2008
> > 14:47:39:
> > 
> > > Thx for your reply,
> > >
> > > Yes it is totally correct for mysql to create unique index without
> > > special naming. mysql just uses the Name auf die Index-column as the
> > > unique index name.
> > >
> > > But, if you do want to specify your own index naming, it is not
> > > possible. The name attribut from <unique name="..."> is ignored totally.
> > >
> > >
> > > In my opinion, torque should treat this like the following:
> > >
> > > if ("unique name" is specified) {
> > >  unique $uniq.name ('column')
> > > }
> > > else {
> > > unique ('column')
> > > }
> > >
> > > Thx
> > > Peter
> > >
> > > Am Donnerstag, den 13.03.2008, 14:36 +0100 schrieb Thomas Fischer:
> > > > As far as I know, you CAN define and index name, but you need not. For
> > > > example, I have thested the following works with mysql 5.0
> > > >
> > > > CREATE TABLE `test` (`test` VARCHAR( 10 ) NOT NULL , UNIQUE (test))
> > > >
> > > > So in my eyes, the SQL generated by Torque is perfectly valid. Or did I
> > > > miss something ?
> > > >
> > > >            Thomas
> > > >
> > > > Peter Frühberger <Pe...@hte-company.de> schrieb am
> > 13.03.2008
> > > > 11:46:08:
> > > >
> > > > > I am using version 3.3-RC3 of the torque maven plugin.
> > > > >
> > > > >
> > > > > The following snippet of code:
> > > > > <unique name="NAME_IDX">
> > > > > <unique-column name="NAME"/>
> > > > > </unique>
> > > > >
> > > > > generates the following mysql code:
> > > > >
> > > > > Create ...
> > > > >    ...
> > > > >     UNIQUE (NAME)
> > > > > );
> > > > >
> > > > > The unique index name (NAME_IDX) is missing, it should correctly be:
> > > > >
> > > > > Create ...
> > > > >    UNIQUE NAME_IDX (NAME);
> > > > > );
> > > > >
> > > > >
> > > > > changing the unique.vm in sql/base/mysql/unique.vm from
> > > > > #foreach ($unique in $table.Unices)
> > > > > UNIQUE($unique.ColumnList),
> > > > > #end
> > > > >
> > > > > to
> > > > > #foreach ($unique in $table.Unices)
> > > > > UNIQUE $unique.Name ($unique.ColumnList),
> > > > > #end
> > > > >
> > > > >
> > > > > fixes this problem for me.
> > > > >
> > > > > Thx
> > > > > Peter Frühberger
> > > > > (sorry for sending through an exchange server ;-))
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > > > > For additional commands, e-mail: torque-user-help@db.apache.org
> > > > >
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > > > For additional commands, e-mail: torque-user-help@db.apache.org
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > > For additional commands, e-mail: torque-user-help@db.apache.org
> > >
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 

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


RE: Possible incorrect unique.vm in mysql

Posted by Peter Frühberger <Pe...@hte-company.de>.
I will do this, but momentarily the apache bugtracker site is a bit
laggy, needs endless time to load...

I` ll recheck tomorrow

Thx again
Peter

Am Donnerstag, den 13.03.2008, 15:01 +0100 schrieb Thomas Fischer:
> Ah ok, I overlooked that a name could be specified. But the dtd says
> 
> <!ELEMENT index (option*,index-column+)>
> <!ATTLIST index
>   name CDATA #IMPLIED
> >
> 
> and in this case you are right, the name should be used.  Would you mind to
> create a jira issue ?
> 
>    Thanks,
> 
>      Thomas
> 
> 
> Peter Frühberger <Pe...@hte-company.de> schrieb am 13.03.2008
> 14:47:39:
> 
> > Thx for your reply,
> >
> > Yes it is totally correct for mysql to create unique index without
> > special naming. mysql just uses the Name auf die Index-column as the
> > unique index name.
> >
> > But, if you do want to specify your own index naming, it is not
> > possible. The name attribut from <unique name="..."> is ignored totally.
> >
> >
> > In my opinion, torque should treat this like the following:
> >
> > if ("unique name" is specified) {
> >  unique $uniq.name ('column')
> > }
> > else {
> > unique ('column')
> > }
> >
> > Thx
> > Peter
> >
> > Am Donnerstag, den 13.03.2008, 14:36 +0100 schrieb Thomas Fischer:
> > > As far as I know, you CAN define and index name, but you need not. For
> > > example, I have thested the following works with mysql 5.0
> > >
> > > CREATE TABLE `test` (`test` VARCHAR( 10 ) NOT NULL , UNIQUE (test))
> > >
> > > So in my eyes, the SQL generated by Torque is perfectly valid. Or did I
> > > miss something ?
> > >
> > >            Thomas
> > >
> > > Peter Frühberger <Pe...@hte-company.de> schrieb am
> 13.03.2008
> > > 11:46:08:
> > >
> > > > I am using version 3.3-RC3 of the torque maven plugin.
> > > >
> > > >
> > > > The following snippet of code:
> > > > <unique name="NAME_IDX">
> > > > <unique-column name="NAME"/>
> > > > </unique>
> > > >
> > > > generates the following mysql code:
> > > >
> > > > Create ...
> > > >    ...
> > > >     UNIQUE (NAME)
> > > > );
> > > >
> > > > The unique index name (NAME_IDX) is missing, it should correctly be:
> > > >
> > > > Create ...
> > > >    UNIQUE NAME_IDX (NAME);
> > > > );
> > > >
> > > >
> > > > changing the unique.vm in sql/base/mysql/unique.vm from
> > > > #foreach ($unique in $table.Unices)
> > > > UNIQUE($unique.ColumnList),
> > > > #end
> > > >
> > > > to
> > > > #foreach ($unique in $table.Unices)
> > > > UNIQUE $unique.Name ($unique.ColumnList),
> > > > #end
> > > >
> > > >
> > > > fixes this problem for me.
> > > >
> > > > Thx
> > > > Peter Frühberger
> > > > (sorry for sending through an exchange server ;-))
> > > >
> > > >
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > > > For additional commands, e-mail: torque-user-help@db.apache.org
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > > For additional commands, e-mail: torque-user-help@db.apache.org
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 

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


RE: Possible incorrect unique.vm in mysql

Posted by Thomas Fischer <fi...@seitenbau.net>.
Ah ok, I overlooked that a name could be specified. But the dtd says

<!ELEMENT index (option*,index-column+)>
<!ATTLIST index
  name CDATA #IMPLIED
>

and in this case you are right, the name should be used.  Would you mind to
create a jira issue ?

   Thanks,

     Thomas


Peter Frühberger <Pe...@hte-company.de> schrieb am 13.03.2008
14:47:39:

> Thx for your reply,
>
> Yes it is totally correct for mysql to create unique index without
> special naming. mysql just uses the Name auf die Index-column as the
> unique index name.
>
> But, if you do want to specify your own index naming, it is not
> possible. The name attribut from <unique name="..."> is ignored totally.
>
>
> In my opinion, torque should treat this like the following:
>
> if ("unique name" is specified) {
>  unique $uniq.name ('column')
> }
> else {
> unique ('column')
> }
>
> Thx
> Peter
>
> Am Donnerstag, den 13.03.2008, 14:36 +0100 schrieb Thomas Fischer:
> > As far as I know, you CAN define and index name, but you need not. For
> > example, I have thested the following works with mysql 5.0
> >
> > CREATE TABLE `test` (`test` VARCHAR( 10 ) NOT NULL , UNIQUE (test))
> >
> > So in my eyes, the SQL generated by Torque is perfectly valid. Or did I
> > miss something ?
> >
> >            Thomas
> >
> > Peter Frühberger <Pe...@hte-company.de> schrieb am
13.03.2008
> > 11:46:08:
> >
> > > I am using version 3.3-RC3 of the torque maven plugin.
> > >
> > >
> > > The following snippet of code:
> > > <unique name="NAME_IDX">
> > > <unique-column name="NAME"/>
> > > </unique>
> > >
> > > generates the following mysql code:
> > >
> > > Create ...
> > >    ...
> > >     UNIQUE (NAME)
> > > );
> > >
> > > The unique index name (NAME_IDX) is missing, it should correctly be:
> > >
> > > Create ...
> > >    UNIQUE NAME_IDX (NAME);
> > > );
> > >
> > >
> > > changing the unique.vm in sql/base/mysql/unique.vm from
> > > #foreach ($unique in $table.Unices)
> > > UNIQUE($unique.ColumnList),
> > > #end
> > >
> > > to
> > > #foreach ($unique in $table.Unices)
> > > UNIQUE $unique.Name ($unique.ColumnList),
> > > #end
> > >
> > >
> > > fixes this problem for me.
> > >
> > > Thx
> > > Peter Frühberger
> > > (sorry for sending through an exchange server ;-))
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > > For additional commands, e-mail: torque-user-help@db.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


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


RE: Possible incorrect unique.vm in mysql

Posted by Peter Frühberger <Pe...@hte-company.de>.
Thx for your reply,

Yes it is totally correct for mysql to create unique index without
special naming. mysql just uses the Name auf die Index-column as the
unique index name.

But, if you do want to specify your own index naming, it is not
possible. The name attribut from <unique name="..."> is ignored totally.


In my opinion, torque should treat this like the following:

if ("unique name" is specified) {
 unique $uniq.name ('column')
}
else {
unique ('column')
}

Thx
Peter

Am Donnerstag, den 13.03.2008, 14:36 +0100 schrieb Thomas Fischer:
> As far as I know, you CAN define and index name, but you need not. For
> example, I have thested the following works with mysql 5.0
> 
> CREATE TABLE `test` (`test` VARCHAR( 10 ) NOT NULL , UNIQUE (test))
> 
> So in my eyes, the SQL generated by Torque is perfectly valid. Or did I
> miss something ?
> 
>            Thomas
> 
> Peter Frühberger <Pe...@hte-company.de> schrieb am 13.03.2008
> 11:46:08:
> 
> > I am using version 3.3-RC3 of the torque maven plugin.
> >
> >
> > The following snippet of code:
> > <unique name="NAME_IDX">
> > <unique-column name="NAME"/>
> > </unique>
> >
> > generates the following mysql code:
> >
> > Create ...
> >    ...
> >     UNIQUE (NAME)
> > );
> >
> > The unique index name (NAME_IDX) is missing, it should correctly be:
> >
> > Create ...
> >    UNIQUE NAME_IDX (NAME);
> > );
> >
> >
> > changing the unique.vm in sql/base/mysql/unique.vm from
> > #foreach ($unique in $table.Unices)
> > UNIQUE($unique.ColumnList),
> > #end
> >
> > to
> > #foreach ($unique in $table.Unices)
> > UNIQUE $unique.Name ($unique.ColumnList),
> > #end
> >
> >
> > fixes this problem for me.
> >
> > Thx
> > Peter Frühberger
> > (sorry for sending through an exchange server ;-))
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 

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


RE: Possible incorrect unique.vm in mysql

Posted by Thomas Fischer <fi...@seitenbau.net>.
As far as I know, you CAN define and index name, but you need not. For
example, I have thested the following works with mysql 5.0

CREATE TABLE `test` (`test` VARCHAR( 10 ) NOT NULL , UNIQUE (test))

So in my eyes, the SQL generated by Torque is perfectly valid. Or did I
miss something ?

           Thomas

Peter Frühberger <Pe...@hte-company.de> schrieb am 13.03.2008
11:46:08:

> I am using version 3.3-RC3 of the torque maven plugin.
>
>
> The following snippet of code:
> <unique name="NAME_IDX">
> <unique-column name="NAME"/>
> </unique>
>
> generates the following mysql code:
>
> Create ...
>    ...
>     UNIQUE (NAME)
> );
>
> The unique index name (NAME_IDX) is missing, it should correctly be:
>
> Create ...
>    UNIQUE NAME_IDX (NAME);
> );
>
>
> changing the unique.vm in sql/base/mysql/unique.vm from
> #foreach ($unique in $table.Unices)
> UNIQUE($unique.ColumnList),
> #end
>
> to
> #foreach ($unique in $table.Unices)
> UNIQUE $unique.Name ($unique.ColumnList),
> #end
>
>
> fixes this problem for me.
>
> Thx
> Peter Frühberger
> (sorry for sending through an exchange server ;-))
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


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