Skip to content

Update with where clause#408

Merged
youen merged 8 commits into
mainfrom
update-with-where-clause
Jun 18, 2026
Merged

Update with where clause#408
youen merged 8 commits into
mainfrom
update-with-where-clause

Conversation

@youen

@youen youen commented Dec 16, 2025

Copy link
Copy Markdown
Collaborator

Update with where clause

The update mode allows to update existing rows. You can use the --where flag (or -w) to specify a SQL WHERE clause. The update will only be performed if the condition matches.

$ lino push update dest --where "last_update > '2023-01-01'" < data.jsonl

The clause is added to the update query with an AND operator, combining it with the primary key condition.

Important: The --where clause is applied only to the start table of the push operation. If the push operation involves multiple tables (via recursion in the ingress descriptor), the condition will not be applied to child or parent tables.

Difference with __usingpk__

  • __usingpk__ is used to target a specific row to update when the primary key itself is being modified. It provides the "old" primary key to locate the record.
  • --where is used to add a logical condition to the update. It is useful for:
    • Optimistic locking: Update only if the record hasn't changed since last read (e.g. version = 1).
    • Business rules: Update only if the record is in a specific state (e.g. status = 'PENDING').

Both can be used together. __usingpk__ identifies which row to try to update, and --where adds an additional check to decide if the update should proceed.

@youen
youen marked this pull request as ready for review June 15, 2026 07:12
@youen
youen requested a review from adrienaury June 15, 2026 07:12
@youen
youen merged commit eb018fa into main Jun 18, 2026
4 checks passed
@youen
youen deleted the update-with-where-clause branch June 18, 2026 12:08
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

Successfully merging this pull request may close these issues.

2 participants