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

How to ensure that a column won't get overriden by a null value? #639

Closed
sreejithraman opened this issue Apr 10, 2016 · 3 comments
Closed

Comments

@sreejithraman
Copy link

Let's say I have a simple user table with the following columns: name, id, token.

Sometimes token is given to me and in those cases update token. Other times token will be null and in those cases I just want to keep the existing value inside token.

One way I thought of was to make a put resolver. Inside the resolver, I check if the given user already has a value for token. If it doesn't, I do a get based on the user's id. If i get a user back, I grab the token and save that along with the new user info.

But won't that basically double the amount of time to insert? I was wondering if there was a quicker way.

@nikitin-da
Copy link
Collaborator

To get rid inserting the same values, maybe just store token in separate table token : user_id, token_value?
Create put resolver like in one-to-many example with custom performPut. And here you can insert token only when it is needed and use two hidden resolvers for simple user and token.

@nikitin-da
Copy link
Collaborator

There is related issue #595

@nikitin-da
Copy link
Collaborator

For generated resolvers there is ignoreNull property (#642).
In custom resolver we should not put null to contentValues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants