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 Federico Fissore <fe...@concept.it> on 2007/03/14 10:27:51 UTC
Reserved names in column names
Hope this is not as trivial
When generating my sql script out of the schema for the mysql database I
get something like
CREATE TABLE question_option
(
id_question_option MEDIUMINT NOT NULL AUTO_INCREMENT,
id_question MEDIUMINT NOT NULL,
option VARCHAR(255) NOT NULL,
PRIMARY KEY(id_question_option),
FOREIGN KEY (id_question) REFERENCES question (id_question)
) ENGINE InnoDB;
A part the InnoDB clause that I've added to table.vm file, the problem
here is the "option" column. "option" seems to be a reserved keyword in
mysql so running the script fails. I'm having such an issue because
we've developed against postgresql, which works fine, and I currently
need to install my app onto an existing mysql
The solution is really simple, prepending and appending two "`" so that
it comes something like
CREATE TABLE question_option
(
id_question_option MEDIUMINT NOT NULL AUTO_INCREMENT,
id_question MEDIUMINT NOT NULL,
`option` VARCHAR(255) NOT NULL,
PRIMARY KEY(id_question_option),
FOREIGN KEY (id_question) REFERENCES question (id_question)
) ENGINE InnoDB;
Is there an option to enable such "`" for column names or something like
that?
Thank you in advance
Federico
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
RE: Reserved names in column names
Posted by Thomas Fischer <fi...@seitenbau.net>.
As far as I recall, the column definitions are not generated by a template
but by the Column.getSQLString() method in the generator. You would have to
patch the Column object to get the behaviour you want (The `'s will not
hurt for the other columns if you always use mysql, but I'm not sure about
non-mysql databases).
Thomas
Federico Fissore <fe...@concept.it> schrieb am 14.03.2007
10:27:51:
> Hope this is not as trivial
>
> When generating my sql script out of the schema for the mysql database I
> get something like
>
> CREATE TABLE question_option
> (
> id_question_option MEDIUMINT NOT NULL AUTO_INCREMENT,
> id_question MEDIUMINT NOT NULL,
> option VARCHAR(255) NOT NULL,
> PRIMARY KEY(id_question_option),
> FOREIGN KEY (id_question) REFERENCES question (id_question)
> ) ENGINE InnoDB;
>
>
> A part the InnoDB clause that I've added to table.vm file, the problem
> here is the "option" column. "option" seems to be a reserved keyword in
> mysql so running the script fails. I'm having such an issue because
> we've developed against postgresql, which works fine, and I currently
> need to install my app onto an existing mysql
>
> The solution is really simple, prepending and appending two "`" so that
> it comes something like
>
> CREATE TABLE question_option
> (
> id_question_option MEDIUMINT NOT NULL AUTO_INCREMENT,
> id_question MEDIUMINT NOT NULL,
> `option` VARCHAR(255) NOT NULL,
> PRIMARY KEY(id_question_option),
> FOREIGN KEY (id_question) REFERENCES question (id_question)
> ) ENGINE InnoDB;
>
>
> Is there an option to enable such "`" for column names or something like
> that?
>
> Thank you in advance
>
> Federico
>
> ---------------------------------------------------------------------
> 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