You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Scott Anderson <sa...@airvana.com> on 2007/10/11 17:31:44 UTC

RE: [JIRA] Commented: (CAY-878) Field names for INSERT are unquoted

Looks like CAY-289 wants strings escaped with square brackets. The
standard, for MySQL at least, is backquotes.

 

I worked around this problem by renaming the field in the database from
`group` to `groupId`

 

-----Original Message-----
From: Andrus Adamchik (JIRA) [mailto:dev@cayenne.apache.org] 
Sent: Thursday, October 11, 2007 4:14 AM
To: Scott Anderson
Subject: [JIRA] Commented: (CAY-878) Field names for INSERT are unquoted

 

 

    [
https://issues.apache.org/cayenne/browse/CAY-878?page=com.atlassian.jira
.plugin.system.issuetabpanels:comment-tabpanel#action_12529 ] 

 

Andrus Adamchik commented on CAY-878:

-------------------------------------

 

Support for that feature has been requested before (CAY-289)... We
finally need to find time and fix it.

 

> Field names for INSERT are unquoted

> -----------------------------------

> 

>                 Key: CAY-878

>                 URL: https://issues.apache.org/cayenne/browse/CAY-878

>             Project: Cayenne

>          Issue Type: Bug

>    Affects Versions: 3.0

>         Environment: MySQL/Tomcat/Cayenne

>            Reporter: Scott Anderson

>            Assignee: Andrus Adamchik

> 

> My INSERT query fails against MySQL because I have a field named
`group` that is not unquoted.

> Oct 10, 2007 4:12:31 PM org.apache.cayenne.access.QueryLogger logQuery

> INFO: INSERT INTO requests2 (autoengineer, close_time,
completion_comments, completion_passfail, completion_time, group, idx,
lab_action, lab_budget, lab_date_needed, lab_device_id, lab_location,
lab_program, lab_rack_no, lab_requesting_group, lab_serial_no,
model_affecting, model_changes, platform, priority, req_type, request,
rpt_affecting, rpt_changes, state, submission_comments, submit_time,
submitter, testcnt, ui_affecting, ui_changes, version) VALUES (?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?)

> Oct 10, 2007 4:12:31 PM org.apache.cayenne.access.QueryLogger
logQueryParameters

> INFO: [bind: NULL, '2005-11-02 10:51:13.0', '<br>IMPLEMENT COMMENTS:
All do...', NULL, '2005-11-02 10:34:39.0', NULL, 2, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, 'false', NULL, 'ClearQuest Tools',
03, NULL, 'Test Plan Import Problems', 'false', NULL, 'CLOSED', 'Please
update the CQ export to...', '2005-10-12 13:18:42.0', 'ddarrah', 0,
'false', NULL, NULL]

> Oct 10, 2007 4:12:32 PM org.apache.cayenne.access.QueryLogger
logQueryError

> INFO: *** error.

> com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error
in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near 'group, idx, lab_action,
lab_budget, lab_date_needed, lab_device_id, lab_location' at line 1

>     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)

>     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2941)

>     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)

>     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)

>     at com.mysql.jdbc.Connection.execSQL(Connection.java:3249)

>     at
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:
1268)

>     at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:15
41)

>     at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:14
55)

>     at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:14
40)

>     at
org.apache.cayenne.access.jdbc.BatchAction.runAsIndividualQueries(BatchA
ction.java:191)

>     at
org.apache.cayenne.access.jdbc.BatchAction.performAction(BatchAction.jav
a:84)

>     at
org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryActi
on.java:57)

>     at
org.apache.cayenne.access.DataNode.performQueries(DataNode.java:236)

>     at
org.apache.cayenne.access.DataDomainFlushAction.runQueries(DataDomainFlu
shAction.java:225)

>     at
org.apache.cayenne.access.DataDomainFlushAction.flush(DataDomainFlushAct
ion.java:143)

>     at
org.apache.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:803)

>     at
org.apache.cayenne.access.DataDomain$2.transform(DataDomain.java:770)

>     at
org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:82
9)

>     at
org.apache.cayenne.access.DataDomain.onSync(DataDomain.java:767)

>     at
org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:115
9)

>     at
org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:107
2)

>     at com.airvana.nmms.autodb.test.main(test.java:91)

> Exception in thread "main" org.apache.cayenne.CayenneRuntimeException:
[v.3.0-SNAPSHOT Sep 01 2007 17:06:09] Commit Exception

>     at
org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:119
1)

>     at
org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:107
2)

>     at com.airvana.nmms.autodb.test.main(test.java:91)

> Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You
have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'group, idx,
lab_action, lab_budget, lab_date_needed, lab_device_id, lab_location' at
line 1

>     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)

>     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2941)

>     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)

>     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)

>     at com.mysql.jdbc.Connection.execSQL(Connection.java:3249)

>     at
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:
1268)

>     at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:15
41)

>     at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:14
55)

>     at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:14
40)

>     at
org.apache.cayenne.access.jdbc.BatchAction.runAsIndividualQueries(BatchA
ction.java:191)

>     at
org.apache.cayenne.access.jdbc.BatchAction.performAction(BatchAction.jav
a:84)

>     at
org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryActi
on.java:57)

>     at
org.apache.cayenne.access.DataNode.performQueries(DataNode.java:236)

>     at
org.apache.cayenne.access.DataDomainFlushAction.runQueries(DataDomainFlu
shAction.java:225)

>     at
org.apache.cayenne.access.DataDomainFlushAction.flush(DataDomainFlushAct
ion.java:143)

>     at
org.apache.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:803)

>     at
org.apache.cayenne.access.DataDomain$2.transform(DataDomain.java:770)

>     at
org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:82
9)

>     at
org.apache.cayenne.access.DataDomain.onSync(DataDomain.java:767)

>     at
org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:115
9)

>     ... 2 more

 

-- 

This message is automatically generated by JIRA.

-

You can reply to this email to add a comment to the issue online.

 


Re: [JIRA] Commented: (CAY-878) Field names for INSERT are unquoted

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Oct 11, 2007, at 6:31 PM, Scott Anderson wrote:

> Looks like CAY-289 wants strings escaped with square brackets. The
> standard, for MySQL at least, is backquotes.

Yeah, the quote char differs between the DB's.

> I worked around this problem by renaming the field in the database  
> from
> `group` to `groupId`

Sure. Actually this is not a very common problem as most people would  
avoid using DB reserved keywords as column names, but we should still  
fix it in Cayenne for those few who do.

Andrus