workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

🐛 BUG: d1 `first()` errors if no results are found

Open GregBrimble opened this issue 2 years ago • 1 comments

What version of Wrangler are you using?

d1

What operating system are you using?

macOS

Describe the Bug

At least in local mode, result is returned, rather than results, so the logic in the facade results.length crashes.

GregBrimble avatar Jul 25 '22 11:07 GregBrimble

According to the docs an D1_NORESULTS error should be thrown if this is the case (not the generic error that's being produced here).

isaac-mcfadyen avatar Aug 01 '22 20:08 isaac-mcfadyen

It seems now that local mode returns null, whereas remote mode returns D1_NORESULTS

Skye-31 avatar Oct 06 '22 14:10 Skye-31

Closing this issue as it looks like we fixed it in the lead up to developer week.

Local:

results:  Object {
  TOTAL: 0
}

Remote:

results:  Object {
  TOTAL: 0
}

rozenmd avatar Nov 21 '22 13:11 rozenmd