sam-tsai / activejdbc

Automatically exported from code.google.com/p/activejdbc
0 stars 0 forks source link

Table with column name `unique` fails #170

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a table with the column name `unique`
2. Try to create the model.  It will fail because column names are not enclosed 
in ``.

What is the expected output? What do you see instead?
Should be able to create/update.

What version of the product are you using? On what operating system?
MySql

Please provide any additional information below.

Original issue reported on code.google.com by marc.har...@gmail.com on 8 Aug 2012 at 7:31

GoogleCodeExporter commented 9 years ago
can you  pleas eprovide a full exception stack trace?

Original comment by ipolevoy@gmail.com on 8 Aug 2012 at 7:35

GoogleCodeExporter commented 9 years ago
shouldCreateAndSaveModel(org.javalite.activejdbc.CreateModelTest)  Time 
elapsed: 0.019 sec  <<< ERROR!
org.javalite.activejdbc.DBException: 
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 'unique, dob, name, last_name, created_at) VALUES 
('2012-08-08 13:49:51', 'blah',' at line 1, Query: INSERT INTO people 
(updated_at, unique, dob, name, last_name, created_at) VALUES (?, ?, ?, ?, ?, 
?), params: 2012-08-08 13:49:51.897,blah,2001-01-07,Sam,Margulis,2012-08-08 
13:49:51.897
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3176)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1153)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1404)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1318)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1303)
    at org.javalite.activejdbc.DB.execInsert(DB.java:521)
    at org.javalite.activejdbc.Model.insert(Model.java:2109)
    at org.javalite.activejdbc.Model.save(Model.java:2021)
    at org.javalite.activejdbc.test_models.Person.save(Person.java)
    at org.javalite.activejdbc.Model.saveIt(Model.java:1948)
    at org.javalite.activejdbc.test_models.Person.saveIt(Person.java)
    at org.javalite.activejdbc.Model.createIt(Model.java:1638)
    at org.javalite.activejdbc.test_models.Person.createIt(Person.java)
    at org.javalite.activejdbc.CreateModelTest.shouldCreateAndSaveModel(CreateModelTest.java:68)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115)
    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:102)
    at org.apache.maven.surefire.Surefire.run(Surefire.java:180)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
    at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)

Original comment by marc.har...@gmail.com on 8 Aug 2012 at 8:53

GoogleCodeExporter commented 9 years ago
Here's a test.

Original comment by marc.har...@gmail.com on 8 Aug 2012 at 9:29

Attachments:

GoogleCodeExporter commented 9 years ago
Here's a possible fix.

Original comment by marc.har...@gmail.com on 8 Aug 2012 at 11:40

Attachments: