Skip to content

Conversation

@mohd-akram
Copy link
Contributor

Description of change

Use the pragma method in better-sqlite3. This is the recommended way to run pragmas.

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run format to apply prettier formatting
  • npm run test passes with this change
  • The new commits follow conventions explained in CONTRIBUTING.md

This is the recommended way to run pragmas.
Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

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

Thank you @mohd-akram for your help.
Are any drawbacks about this change?

@mohd-akram
Copy link
Contributor Author

@gioboa No drawbacks that I'm aware of.

@gioboa
Copy link
Collaborator

gioboa commented Jan 22, 2025

@gioboa No drawbacks that I'm aware of.

Thanks 👍

@alumni
Copy link
Collaborator

alumni commented Jan 22, 2025

Are any drawbacks about this change?

If you want to use bun's sqlite driver (similar to better-sqlite3), it won't have the pragma method 😛

Bun-related issue: #11236

Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

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

So this is not working with bun 🤔
An idea is to check the runtime and create a condition in the code eg. detect Bun.
What do you think?

@alumni
Copy link
Collaborator

alumni commented Jan 24, 2025

We don't support bun at the moment, so my comment was there just in case we would like to 🤷🏻

I played a bit with bun:sqlite and I was able get it to work with typeorm for a basic use case with only with 2 minor changes (see the linked issue).

Later edit: bun has a ticket to add support for .pragma: oven-sh/bun#2023

@angelxmoreno
Copy link

what is the status of this PR? have the admins agreed or disagreed to review/merge this work?

Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

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

It looks good to me
Thanks @mohd-akram

@qodo-free-for-open-source-projects

PR Code Suggestions ✨

No code suggestions found for the PR.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 1, 2025

commit: d435d68

@coveralls
Copy link

Coverage Status

coverage: 80.758%. remained the same
when pulling d435d68 on mohd-akram:improve-better-sqlite3
into c4f5d12 on typeorm:master.

Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

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

Tests are fine.
What's the benefit of using pragma ? is it faster? reliable?

@alumni
Copy link
Collaborator

alumni commented Dec 1, 2025

hmm, better-sqlite3 does not mention exactly what:

It's better to use this method instead of normal prepared statements when executing PRAGMA, because this method normalizes some odd behavior that may otherwise be experienced.

https://github.com/WiseLibs/better-sqlite3/blob/master/docs/api.md#pragmastring-options---results

Copy link
Collaborator

@gioboa gioboa 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 your help @mohd-akram

@gioboa gioboa merged commit ec3ea10 into typeorm:master Dec 1, 2025
64 checks passed
@mohd-akram mohd-akram deleted the improve-better-sqlite3 branch December 1, 2025 21:44
ThbltLmr pushed a commit to ThbltLmr/typeorm that referenced this pull request Dec 2, 2025
mgohin pushed a commit to mgohin/typeorm that referenced this pull request Jan 15, 2026
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.

5 participants