question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing ids in query that bulk_create produces.

See original GitHub issue

Describe the bug Hi! Model.bulk_create excludes object ids from query that it produces. This leads the ids to an ascending order, even if otherwise specified.

To Reproduce

# models.py
class SomeModel(models.Model):
    id = fields.IntField(pk=True)
   field = fields.IntField()

# test_bulk_create.py
import models

async def test_bulk_create_ids():
    await models.SomeModel.bulk_create(
        [
            models.SomeModel(id=100, field=1),
            models.SomeModel(id=200, field=1)
        ]
    )
    objs = await models.SomeModel.all()
    assert objs[0].id == 1
    assert objs[1].id == 2

Expected behavior The bulk_create creates the ids according to objects that it gets.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
grigicommented, May 7, 2020

Oh, hold on. I missed the issue here. Blame lack of sleep. Apologies.

0reactions
grigicommented, May 8, 2020

This should be fixed in the next release. You can test by doing a

pip install https://github.com/tortoise/tortoise-orm/archive/develop.zip
``
Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL: find missing IDs in a table - Stack Overflow
Easiest solution for me: Create a select that gives all ids up to max sequence value (ex:1000000) ...
Read more >
mysql - How to get missing values in row order?
In MySQL you can use LIMIT (after ORDER BY ) instead of TOP . If the missing id values are in the beginning...
Read more >
SQL SERVER - Discussion - Effect of Missing Identity on System
So, the question is this: “Do you know a real-world scenario where a Missing Identity value in any table can create problems?“ I...
Read more >
Debugging missing data in SQL query results - Metabase
What to do when your query returns data that's missing rows or columns. ... SELECT * FROM orders o JOIN products p ON...
Read more >
SQL Scripts: How To Find Missing Indexes
The below query will show missing index suggestions for the specified ... This script also generates a CREATE INDEX script for each record, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found