← OSS Labs
knex/knex · OSS Lab

The Missing RETURNING

Empty INSERT with RETURNING returns no data

lockNot currently playableReady-check eligible · human review pending
EasyDatabaseReady-check eligible · human review pending
OSS Labs are training exercises derived from public open-source bug-fix history. Completing a lab is not an upstream contribution or merged PR. Buglyst is not affiliated with these projects.
f44f75aSource commit
8198fa6Parent commit
MITLicense
591Files
112,949Visible LOC
~20mEst. time

What this lab trains

checkRepository navigation
checkFailing test reproduction
checkRoot cause tracing
checkMinimal patch reasoning
checkPR-style explanation

Failing signal

What you’ll see when you run the visible regression test.

SymptomEmpty INSERT with RETURNING returns no dataEntry point hintThe test inserts an empty row and expects data back — but gets nothing. The query compiler has a shortcut for empty INSERTs.

Repo navigation focus

A public-safe starting path for the large repo snapshot.

Start here
  • test/unit/sqlite-empty-insert-returning.test.js
Likely area
  • lib/dialects/sqlite3/query/sqlite-querycompiler.js
Investigation path
  1. Run the failing test: npx mocha --exit test/unit/sqlite-empty-insert-returning.test.js.
  2. The assertion expects the INSERT response to include a RETURNING clause — it doesn't.
  3. Navigate to the SQLite query compiler. Find the isEmpty() guard in the insert method.
  4. The empty path returns immediately — look at the non-empty path below to see how RETURNING is handled.
  5. Add the same returning check and append to the empty insert branch.
Repo scale
  • 593 files
  • ~92k LOC
  • Real Knex repo snapshot

PR-style report (preview)

The structured report you produce on accept. This is the format, not a real completion.

differencePR-STYLE REPORT
Sample format
The Missing RETURNINGknex/knex

Problem

A regression reproduced from public bug-fix history causes a visible test to fail on the parent snapshot.

Root cause

Written by you, in your own words, after tracing the failing test into the runtime source. (Filled in from your submission — not provided here.)

Fix summary

A minimal patch that makes the visible regression test pass without breaking neighbouring behaviour.

Files changed

  • descriptiontest/<regression>.test.js
  • descriptionlib/<runtime-source>.js

Files inspected

  • descriptiontest/<regression>.test.js
  • descriptionlib/<runtime-source>.js

Tests run

  • terminalVisible regression test
  • terminalHidden edge-case validation

Validation result

Visible checks: pendingHidden validation: pending

Resume-safe summary

Completed an OSS-backed Buglyst debugging lab based on public bug-fix history: reproduced a failing test, traced the root cause, and shipped a minimal patch that passed visible and hidden validation. Not an upstream contribution.

OSS Labs are training exercises derived from public open-source bug-fix history. Completing a lab is not an upstream contribution or merged PR. Buglyst is not affiliated with these projects.