-
Notifications
You must be signed in to change notification settings - Fork 245
Open
Description
I try to store translations in many languages and get this error :
pony.orm.core.UnexpectedError: Object Label['𑂓𑂳𑂗𑂹𑂗𑂲','bho'] cannot be stored in the database. DataError: 1366 Incorrect string value: '\xF0\x91\x82\x93\xF0\x91...' for column 'label' at row 1
the database Is MySQL latest.
the class is
class Label(db.Entity):
label = Required(
str, sql_type="VARCHAR(255) CHARACTER SET \'utf8mb4\' COLLATE \'utf8mb4_general_ci\'", index='labels')
lang = Required(str, 10)
PrimaryKey(label, lang)
I specified the CHARACTER SET and COLLATE after trying different combinations which gave the same error
What's more disturbing is that the error is not trapped in my code, which could allow to skip some rare languages:
@db_session
def add(label: str, lang=DEFAULT) -> Label:
if not label:
return None
lang = lang or DEFAULT
try:
return Label[label, lang]
except:
pass
try:
return Label(label=label, lang=lang)
except:
return None
actually, it seems the error occurs later, when closing the session (see dump attached)
Metadata
Metadata
Assignees
Labels
No labels