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

[BUG]D1PreparedStatement::run and all documenation mismatch

Open robmv opened this issue 11 months ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

What version of workers-rs are you using?

0.5.0

What version of wrangler are you using?

3.99.0

Describe the bug

The Rust documentation for PreparedStatement::run say that it only returns metadata, In reality it is returning the result rows too, checking the run implementation and comparing it with all, and it invokes the respective JS native run and all implementations, but run does an extra step not done by all:

let result = cast_to_d1_error(result)?;

On the JS documentation side, it says that run and all should be treated as aliases, there is no mention of one only returning metadada, and as these are the basis of the Rust wrappers, the Rust side always returns the results too.

D1PreparedStatement::run is functionally equivalent to D1PreparedStatement::all, and can be treated as an alias.

Note: I wish the documentation clarified a little more when meta data fields aren't present, there are many Option metadata fields.

Steps To Reproduce

No response

robmv avatar Jan 03 '25 16:01 robmv