cloudflare / cloudflare/workers-rs

[BUG]D1PreparedStatement::run and all documenation mismatch

Open
#690 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
3.7k
Forks
429
Avg merge
20h 28m
Merged PRs (30d)
7

Description

### 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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.