Repository navigation
Serialize arrays in SQLite inserts, and return ids from batch inserts only when needed - #353
Merged
Merged
Conversation
lehni
force-pushed
the
fix/sqlite-batch-insert
branch
2 times, most recently
from
October 12, 2026 21:08
0c06029 to
b53be4a
Compare
… only when needed
lehni
force-pushed
the
fix/sqlite-batch-insert
branch
from
October 12, 2026 21:13
b53be4a to
bf0799b
Compare
lehni
marked this pull request as ready for review
October 12, 2026 21:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A follow-up to #349, after a review of it:
insert()stores objects and arrays in columns that aren'tjsonAttributesas JSON in every insert, not only in batches. knex leaves arrays as'[object Object]'even in single rows, which Batch inserts on SQLite, and inserts of models with ids on all databases #349 didn't cover.returningwhen there are ids to return. Models that have their ids aren't matched to the returned rows by position then, whose order SQLite doesn't guarantee.idColumnwork on all databases, like models that have their ids, as there is nothing to return. Ids that$beforeInserthooks give the models count too, and queries that abeforeInserthook cancels don't throw.select ... union all, and batches of more than 500 rows or 32766 values fail.relate()of several ids works on all databases.relate()of several ids$relatedQuery()array inserts, except on MySQLInvalid column name 'id'Vincit/objection.js#2305onConflict().ignore()in a batch, composite ids, and noreturningfor models with ids. Other tests cover ids from$beforeInserthooks and cancelled batches on all databases.