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

55 Views Asked by At

Let's say I have a simple user table with the following columns: name, id, token. I get these values from a server so whenever I get them I want to update it inside my local database.

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 put resolver, I check if the user given from the server 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 (from the user I got from the local db) 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.

P.S. I asked this question over at the GitHub page but realized it may be more appropriate to have it here.

1

There are 1 best solutions below

0
On BEST ANSWER

At the moment you can do this with custom PutResolver where you can implement Put operation as you need.

We also working on annotation support for our annotation processor so it'll be able to skip writing null values.