-
Notifications
You must be signed in to change notification settings - Fork 3
Add support for array parameters #2
Conversation
Thanks for the pull request! I’ve been thinking about this issue for a while, and I still don’t have a good answer. I like the approach you propose because it’s transparent and natural, but it may lead the prepared statement cache to blow up. Maybe we should just add a warning explaining the situation in the documentation? Also, I use Prettier without tweaking any settings—why do you think the |
RE prettier |
The cache size growing out of control is a gotcha of
In the situation where the user wants to cache the statements but wants control over purging the cache you could do db.all(sql`...`)
db.statementCache.clear() // clears the entire statement cache
db.all(sql`...`, { statementCacheNamespace: 'foo' })
db.statementCache.clear('foo') // clears the cache for only statements tagged with namespace foo This last one seems a bit overkill but just an idea. As it might be useful to cache statements on a per request basis, 'foo' might be the Also good to note that the suggested approach of caching based on size of the array parameter length will work out of the box with this implementation. |
Also I realize you didn't ask for this PR so no worries if you're not interested in it's contents. |
You make excellent points. I’ll work on this at some point in the near future. Thank you very much!
Oh, I’m merging this, for sure! |
I merged this and published as part of version 2.0.0 (major bump because of move to ESM). Thank you very much for the pull request! |
Now you can do
Also added a prettier config matching current formatting.