-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[Bug] SQLite multiple inserts need to be broken down to chunks of 100 #50
Comments
In the meantime for people having the same problem here is my temporary workaround : In the problematic seed : // Slice for SQLite
$slicer = floor(999 / sizeof($photos[0]));
$slices = array_chunk($photos, $slicer);
foreach ($slices as $slice) {
DB::table('photos')->insert($slice);
}
return [$photos[0]]; And in the next seed: // Run photos seeds again
DB::table('photos')->delete();
include 'photos.php'; |
Eh, I don't really know of a clean way to work around this unfortunately. Sounds like more of an upstream PHP issue. |
This was referenced Dec 7, 2016
joelharkes
pushed a commit
to joelharkes/framework_old
that referenced
this issue
Mar 7, 2019
…n-budgets-endpoints Organization budgets endpoints
michaeldrennen
added a commit
to michaeldrennen/Geonames
that referenced
this issue
May 26, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently SQLite multiple inserts only work with chunks of 100 entries. Above it, it throws the following exception :
SQLSTATE[HY000]: General error: 1 too many SQL variables
.Something with array_chunk maybe.
This isn't a problem in most parts of the application since inserts can be manually splited but is hugh problem in seeds because even if you split the query and insert the first chunks beforehand, seeding empties the database before inserting the seeded values.
UPDATE : Apparently this isn't as much a matter of entries as a matter of placeholders. See the #9 of this page on the SQLite website for more details. So if you insert entries with 5 columns (id, name, description, created_at, updated_at) you can insert
999 / 5
= 199 entries.Maybe check if the limit can be put higher via PHP.
The text was updated successfully, but these errors were encountered: