Skip to content
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

Can not bulk_update object when it has the json field with sqlite #519

Closed
ponytailer opened this issue Jan 11, 2022 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@ponytailer
Copy link
Contributor

ponytailer commented Jan 11, 2022

error:

sqlite3.InterfaceError: Error binding parameter 8 - probably unsupported type.

the real sql was UPDATE item_config SET created_at=?, updated_at=?, sid=?, item_id=?, title=?, pic_url=?, on_sale_timestamp=?, hot=?, pairs=? WHERE item_config.id = ? !!!! [1641890802, 1641890802, '123', '1', 'test-1', '', 0, 0, ['2', '3'], 1]
the pairs is the json type.

But item.update(pairs=["1"]) can work

@ponytailer ponytailer added the bug Something isn't working label Jan 11, 2022
@ponytailer ponytailer changed the title Can not bulk_update object when it has the json field in sqlite Can not bulk_update object when it has the json field with sqlite Jan 11, 2022
@collerek
Copy link
Owner

I need something I can reproduce.
Can you provide model and update code you use?

@ponytailer
Copy link
Contributor Author

ponytailer commented Jan 11, 2022

sorry, my mistake.

DB: sqlite 3.28.0

import ormar

class ItemConfig(ormar.Model):
    class Meta(BaseMeta):
        tablename = "item_config"

    id: Optional[int] = ormar.Integer(primary_key=True)
    item_id: str = ormar.String(max_length=32, index=True)
    pairs: List[str] = ormar.JSON(default=[])

items = await ItemConfig.objects.filter(ItemConfig.id > 1).all()

for item in items:
     item.pairs = ["1"]

await ItemConfig.objects.bulk_update(items)

@collerek
Copy link
Owner

Fixed in 0.10.24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants