Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SUGAR reformats entity properties #48

Closed
QuickBrownFoxy opened this issue Sep 23, 2013 · 7 comments
Closed

SUGAR reformats entity properties #48

QuickBrownFoxy opened this issue Sep 23, 2013 · 7 comments
Labels

Comments

@QuickBrownFoxy
Copy link

public class Book extends SugarRecord {
String ISBN_ID;
String title_string;
}
becomes below columns
ISBNID
TITLESTRING

it shouldn't touch property names should it?

@satyan
Copy link
Collaborator

satyan commented Sep 24, 2013

The intent is to have a consistent column naming convention.. But, on second thought, not a bad idea to just use the property names as it is..

@QuickBrownFoxy
Copy link
Author

Any time scale for the change?

@satyan
Copy link
Collaborator

satyan commented Sep 25, 2013

I'd take some time to change this.. I'm considering options like making this configuration with annotations or any particular interface. That's because some apps may want to have a different column name than the property name.

However, for you, you could just change the
https://github.com/satyan/sugar/blob/master/library/src/com/orm/StringUtil.java

Remove the property renaming logic and you'd get the same property names as the column names.
Let me know if this helps.

@rlabanca
Copy link

rlabanca commented Nov 4, 2013

Satyan,

I'm having a similar problem. My model is:
public class Region extends SugarRecord {

private String externalId;
private String name;
    ...

}

And the externalId was created as "external_id" column. So, when I build a query, I have to send the prop as the name of the column instead of the name of the property. Example:
List list = Select.from(Region.class)
.where(Condition.prop("external_id").eq("abc123"))
.list();

Could you call the StringUtil.toSQLName when we add a property to a condition?

The code would be like this:
public Condition(String property) {
this.property = StringUtil.toSQLName(property);
}

I think it will solve the problem.

Thanks!!

@satyan
Copy link
Collaborator

satyan commented Nov 7, 2013

Hmm.. that's a nice suggestion. I'm considering Annotations for custom property names as well. Thanks, I'll look at this option too.

@whoshuu whoshuu added the feature label Apr 1, 2015
@whoshuu
Copy link
Collaborator

whoshuu commented Apr 1, 2015

The right approach is probably to beef up the query builder modules, with a specific interface for userland names that'll automatically do the name conversions under the hood.

@sibelius
Copy link
Contributor

sibelius commented Dec 2, 2015

now we have @column annotation that enable us to use any name for a specific column

@sibelius sibelius closed this as completed Dec 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants