Skip to content

Problem with Propertyname "order" #31

sebastiandeutsch opened this Issue Apr 17, 2012 · 10 comments

4 participants


When you add


it will generate some code without any errors. Unfortunately the SQL generated by the querybuilder will throw an Exception since ORDER is a reserved keyword. Maybe greenDAO should throw an Exception in the generator when a reserved word is used.


This is weird, because I have unit tests for special property/column names. Also for QueryBuilder:

However, I did not test "order" yet...


I just added an "order" property to those unit tests. It seems your use case is different and the current unit test do not cover it. Could you supply more info on your case, e.g. your query, the generated SQL, and the exception? Thanks.


I added another unit test (5aa643c), but still cannot reproduce this error. Please let me know your query leading to the error. Without being able to reproduce, I'd have to close the issue otherwise.


Hi, I've put up an Repository to reproduce the "bug" - I understand if you don't fix it, since it's not a real bug, it's more the lameness of SQLite that you cannot escape fieldnames. But maybe you should enlist all reserved words in the docu, or in the FAQ.


Thanks for getting back. I thought you were referring to greenDAO's QueryBuilder class. If it's about using SimpleCursorAdapter, you should try escaping your column names with a single quote, e.g. 'order' instead of order.

That's what QueryBuilder is doing and the unit tests seem to run correctly.


I guess the question is whether to have column names wrapped inside single quotes somewhere in Properties.


Using a field named "order" as an order field in a to-many relationship breaks because it is not quoted. See

Anywhere columns are put into generated SQL, they should be escaped using a method.


I will make a PR to do that if you will merge it.


fixed PropertyOrderList in master, no other issues reported by this ticket

@greenrobot greenrobot closed this Jun 28, 2015
@greenrobot greenrobot added the Bug label Jun 28, 2015
@greenrobot greenrobot added this to the Next Major milestone Jun 28, 2015

I think it is not greendao bug. you can modify that from the JSON. Please check my answer:

//add this to daogenerator and generate the daogenerator
beacon.addStringProperty("order_food"); //Daogenerator

//add this to network manager
//add this into your network manager
FieldNamingStrategy strategy = new FieldNamingStrategy() {
public String translateName(Field field) {
if(field.getName().equalsIgnoreCase("order_food")) {
return "order";
} else {
return field.getName();

//add this in your Gson


hopefully it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.