Opened 9 years ago
Closed 9 years ago
#25638 closed Bug (needsinfo)
update using Concat with Value causes error-encoding in SQLite
Reported by: | Bear | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.8 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Suppose we want to concat a string to the end of a Charfield.
If we use:
Model.objects.update(field=Concat('field', Value("end")))`
it will commit successfully, but the field will inlcude error-encoding text in SQLite. If we select the field from db, db will say "OperationalError: Could not decode to UTF-8 column 'name' with text".
Instead,
Model.objects.update(field=Concat('field', Value("end"), None))
it will be OK.
Change History (4)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
@timgraham did you try setting the initial value of name
and/or the Value()
to a string with non-ASCII characters?
comment:3 by , 9 years ago
Description: | modified (diff) |
---|
No trouble with this either:
def test_concat_update(self): author = Author.objects.create(name='Jὀy') Author.objects.update(name=Concat('name', Value('eὀd'))) author.refresh_from_db() self.assertEqual(author.name, 'Jὀyeὀd')
comment:4 by , 9 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
This test added to
tests/db_functions/tests.py
passes for me:Can you provide a failing test or clarify the steps to reproduce?