question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to deal with patching

See original GitHub issue

I’m working with an API that streams changes to models in real time, and the payload is a JSON object containing only the fields that changed.

What is the suggested way to patch those changes in? The only thing I could think of is:

CREATE TABLE User (
  id TEXT PRIMARY KEY NOT NULL DEFAULT "0",
  token TEXT NOT NULL DEFAULT "",
  deviceId TEXT NOT NULL DEFAULT "",
  birthday TEXT AS LocalDate
);

updateId:
UPDATE CurrentUser SET id = :id;

updateToken:
UPDATE CurrentUser SET token = :token;

updateDeviceId:
UPDATE CurrentUser SET deviceId = :deviceId;

updateBirthday:
UPDATE PersistedCurrentUser SET birthday = :birthday;

fun updateUser(json: JsonObject) {
  if(json.contains("id")) query.updateId(json.get("id").asString)
  if(json.contains("token")) query.updateToken(json.get("token").asString)
  if(json.contains("deviceId")) query.updateDeviceId(json.get("deviceId").asString)
  if(json.contains("birthday")) query.updateBirthday(json.get("birthday").asLocalDate)
}

I don’t think a function can be generated that only updates explicitly defined columns (what would the default argument be, since null can’t be used; what if you want to set the column to null).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
eygrabercommented, Jun 5, 2020

It’s a bit verbose, but I’ve gotten used to it by now. I’ve really been appreciating the simplicity of SqlDelight, and I’m kind of happy that this isn’t being done.

0reactions
AlecStrongcommented, Jun 5, 2020

ayyy happy to hear that

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle patch management - Network World.com
Open season on clients ; Do ; Establish a team or appoint an individual to monitor for new. vulnerabilities. ; Create a process...
Read more >
What is Patch Management? Benefits & Best Practices - Rapid7
Patch management is the process of distributing and applying updates to software. These patches are often necessary to correct errors (also referred to...
Read more >
How to Get a Handle on Patch Management | Threatpost
Best practices, according to Graham, include creating a patching cadence based on vendor releases. IT should also identify and prioritize ...
Read more >
8 Patch Management Best Practices You Should Know About
Another thing to do when handling patch management is to ensure that you have a clear patch management policy that you'll follow with...
Read more >
How to Handle Updates and Patches Properly - MSP360
Manage Patches on a Per-User Basis. Don't take a one-size-fits-all approach to patches and updates. Tailor your patch management policies and schedules to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found