sqlite: add limits property to DatabaseSync#61298
sqlite: add limits property to DatabaseSync#61298mertcanaltin wants to merge 20 commits intonodejs:mainfrom
Conversation
|
Review requested:
|
f57afa7 to
ffd7dd0
Compare
louwers
left a comment
There was a problem hiding this comment.
Should we add SQLITE_MAX_LENGTH etc. as constants? https://sqlite.org/limits.html
SQLITE_MAX are compile-time preprocessor macros, so they can't be exported directly at runtime. however, the default values returned by db.limits are exactly these SQLITE_MAX values (assuming SQLite was compiled with default settings). so db.limits.length returns 1000000000 which equals SQLITE_MAX_LENGTH. if you want explicit constants, i could add SQLITE_LIMIT (the enum IDs used with sqlite3_limit()) to the constants object. |
|
@addaleax thanks for reviews, I tried solve |
|
I think my only main thought is regarding the intended behaviour when requested limits are out of range. Presumably we can add the relevant compile-time value to each |
thanks for comment, I tried use SQLITE_MAX_* |
I think this is actually a lot more ergonomic. Then if you want to reset a limit you can just do: db.limits.length = Infinity;Otherwise you'd need to look up the maximum limit. If you make a mistake, or the maximum limit changes, you get an exception... These limits are for limiting a database. If the user tries to set a limit that is too high, it may not be what "the result the user intended", but the intended result was impossible anyway... |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61298 +/- ##
==========================================
- Coverage 89.74% 89.72% -0.02%
==========================================
Files 674 674
Lines 204395 204562 +167
Branches 39274 39307 +33
==========================================
+ Hits 183427 183541 +114
- Misses 13275 13303 +28
- Partials 7693 7718 +25
🚀 New features to boost your workflow:
|
thanks for the suggestion ❤️ Yes, this is the current behavior values are passed directly to sqlite3_limit() which handles truncation silently. So db.limits.length = Infinity works as a convenient way to reset to the maximum. |
While I'm not fundamentally opposed to this pattern, note that Could we use |
|
@Renegade334 Thank you, I tried to apply what you said. |
|
Would it be possible to interpret Having a setter that accepts different types from the corresponding getter feels wrong to me. Also, I would except that 'resetting' a limit means it goes back to the value that was initially provided to the constructor. Not that it takes on the highest value (which is the same as the default value). Setting it to |
|
+1 Of course! I used Infinity instead of Null and updated the test documents. |
Co-authored-by: René <contact.9a5d6388@renegade334.me.uk>
Co-authored-by: René <contact.9a5d6388@renegade334.me.uk>
Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
|
Can you reinstate the range for loops again? |
I sended |
Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
There was a problem hiding this comment.
Woops. Looks like we forgot about SQLITE_LIMIT_WORKER_THREADS: https://www.sqlite.org/c3ref/c_limit_attached.html
Should it be added even though it can be set with a pragma?
Probably not, there are several other limits. https://www.sqlite.org/pragma.html
|
I solved conflict 🎉 |
Fixes: #61268
add limits property to databaseSync