Currently table column name equals to object variable name. I think is not safe, as if someone re-name variable -> Proxy is re-generated which lead to database migration. I think it will be better to have possibility to declare table column names via annotations. E.g.
public class User extends RealmObject {
@Row("id")
private int id;
@Row("age")
private int age;
@Row("first_name")
private String name;
}
P.S. I know you have a lot of work but it would be great if you can share your TODO list, to know what to expect in next version.
Absolutely a good idea. And something we also intend to add as optional.
I'll see what we can do with the todo list. Initially our priority is to
make the current feature set easy to use and understand and be responsive
to whatever issues people may run into.
And that's a little hard to plan in advance :-)
On Sun, Oct 5, 2014 at 10:09 PM, Dmytro Danylyk [email protected]
wrote:
Currently table column name equals to object variable name. I think is not
safe, as if someone re-name variable -> Proxy is re-generated which lead
to database migration. I think it will be better to have possibility to
declare table column names via annotations. E.g.public class User extends RealmObject {
@Row("id") private int id; @Row("age") private int age; @Row("first_name") private String name;}
P.S. I know you have a lot of work but it would be great if you can share
your TODO list, to know what to expect in next version.—
Reply to this email directly or view it on GitHub
https://github.com/realm/realm-java/issues/451.
I would suggest you to put Limitations in README file so people didn't spam issues.
Totally in support of having a “Current Limitations” section in our docs! We have one for Cocoa and soon we’ll get a good sense of what to put in it for Java.
Personally I think it would be confusing to have the column name be potentially defined in two different ways, and I think allowing optional annotations only gives ways to developers’ worst instincts :D Pretty soon you’ll have a spaghetti of mapping not unlike an ORM. But I’m probably missing something! Is there any case where you’d see annotations for column names be absolutely necessary?
@timanglade
"name" in realm.where(Dog.class).contains("name", "rex").findAll();I think that is what we want to keep though, so there is never anything crazy happening logic-wise like this:
@Row("name")
private String last_name;
@Row("othername")
private String name;
I personally prefer using "raw" SQL statements declared in strings.xml
But, I don't know if people would be happy to learn another language to use realm. API - is more convenient and clear way.
Maybe Proxy objects could generate row names as well, and give us public access to it.
realm.where(Dog.class).contains(Dog.ROW_NAME, "rex").findAll();
Hello Dmytro,
To have something like Dog.ROW_NAME we would need it to be a field either
in RealmObject, which is not possible, or in Dog, which is defined by
users. If we put it in DogRealmProxy it would not be accessible in Dog and
we don't want users to have to use a generated class directly. So, that's
where the decision to use "name" instead comes from. We're also
experimenting with other fluent query interfaces, but the current one seems
to present the best compromise so far.
On Tue, Oct 7, 2014 at 9:52 AM, Dmytro Danylyk [email protected]
wrote:
I personally prefer using "raw" SQL statements declared in strings.xml
https://github.com/dmytrodanylyk/android-concurrent-database/blob/dev-ver-2/database/res/values/queries.xmlBut, I don't know if people would be happy to learn another language to
use realm. API - is more convenient and clear way.Maybe Proxy objects could generate row names as well, and give us public
access to it.realm.where(Dog.class).contains(Dog.ROW_NAME, "rex").findAll();
—
Reply to this email directly or view it on GitHub
https://github.com/realm/realm-java/issues/451#issuecomment-58148991.
@emanuelez thanks for response.
+1 for this feature
This feature will be useful to help organizations that enforce certain coding convention (in particular to naming attribute of a class). Hopefully this feature will chip in soon.
+1 for this feature.
Folding this issue into #1470. Lets continue the discussion there.
Features absolutely Needed , like one in Android Room
@ColumnInfo(name = Constants.DESTINATION)
public String destination;
Most helpful comment
Features absolutely Needed , like one in Android Room
@ColumnInfo(name= Constants.DESTINATION)publicString destination;