SQL

Keep a stale edit from replacing a newer job

BOTIE

Connect current job and proposal to Compare the expected record version. Inspect the boolean result before applying the patch.
Ready to test
0 passed · 0 failed · 2 not run

An empty floor. Start with the information your machine needs.

Received result

Your answer will arrive here.

Examples, experiments and workspace controls
Live values

Connect a tool's inputs to see what it produces. You can try a branch before connecting it to Result.

Try your own inputs

Use a copy of the example to try your own data. Keep the problem's assumptions in mind, and predict the effect of a change before checking the output. You can also add another branch to compare two ways of doing the calculation.

Start at an output arrow, then click or drag to an input. Drag empty space to pan. Delete removes a selection. Ctrl/Cmd+Z undoes a change.
Context for this challenge

Connect current job and proposal to Compare the expected record version. Inspect the boolean result before applying the patch.

The proposed status was chosen using an earlier job version.

Inspect the component calculation
Compare the expected record version(
  Current job record: Stored job
  Edit proposal: Versioned edit
)
Examples and results
Stored job
{
  "id": "J1",
  "status": "assigned",
  "version": 4
}
Versioned edit
{
  "id": "J1",
  "expected_version": 4,
  "status": "done"
}
Required result
true
Stored job
{
  "id": "J2",
  "status": "open",
  "version": 4
}
Versioned edit
{
  "id": "J1",
  "expected_version": 4,
  "status": "done"
}
Required result
false
Try a fresh construction

This clears this draft, including its undo history. Earlier successful attempts stay recorded. Build again without opening hints to record an independent attempt.

Stuck? Inspect a worked construction

The tools below form one possible solution. You can assemble it, follow its signals, and undo that change to return to your own construction.

Assumptions and test precision

The workshop is a sequential optimistic-check model. It does not simulate locks, isolation levels or simultaneous transactions. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.

Your last tested pieces can start the full construction. An existing draft there keeps its own pieces.

A matching revision on a different job

This check uses the pieces from “Make the edit consume a matching version”.

BOTIE

J8 is currently open at version 9. Its proposal expects version 9 and changes status to assigned. Predict the new record, including the consumed version.
Stored job
{
  "id": "J8",
  "status": "open",
  "version": 9
}
Versioned edit
{
  "id": "J8",
  "expected_version": 9,
  "status": "assigned"
}

Use a number, text, or an array matching the requested result. For a matrix, put each row in brackets. Saving your prediction runs your current construction on these inputs and checks the earlier examples too.

Build a construction in the workspace above first. This case will test those pieces.

Why does this single-record version check not automatically enforce a rule involving several different jobs?

Choose isolation and locking from the complete invariant, then test the actual concurrent interleaving.

The workshop is a sequential optimistic-check model. It does not simulate locks, isolation levels or simultaneous transactions.

Work through the SQL challenges →
Continue the courseFind One Pump’s Readings Without Checking Every Pump →