Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update to latest D1 Database interface #71

Merged

Conversation

dtbuchholz
Copy link
Contributor

Summary

The D1 Database exec method has changed an now expects a ExecResult instead of a Result<T>. If you're using the latest @cloudflare/workers-types, the ORM response will be incorrect for methods like CreateTable or DropTable, which use exec under the hood. This PR bumps to the latest version and makes slight changes to fix this return type.

Details

The latest D1 APIs can be found here. The is what exec looks like:

exec(query: string): Promise<D1ExecResult>;

And D1ExecResult:

interface D1ExecResult {
  count: number;
  duration: number;
}

The proposed changes simply swap out the outdated return type of D1Result<T> for D1ExecResult where needed. Also, chai was updated in order to fix an import issue in the tests.

How it was tested

After updating these deps and making slight changes to database.ts and model.ts, the tests pass without needing any changes.

@changeset-bot
Copy link

changeset-bot bot commented Oct 27, 2023

🦋 Changeset detected

Latest commit: f96d35e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
d1-orm Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@Skye-31 Skye-31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR

@Skye-31 Skye-31 merged commit 5c168e9 into Interactions-as-a-Service:main Oct 29, 2023
3 checks passed
@github-actions github-actions bot mentioned this pull request Oct 29, 2023
@dtbuchholz dtbuchholz deleted the update-d1-latest-interface branch November 6, 2023 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants