Skip to content

Commit b2be393

Browse files
committed
BUG23567257: Fix _id auto-generation
On inserting a document into a collection without specifying the `_id` attribute, the following error is thrown: Data too long for column '_id' at row 1 UUID generates a 36 character long string but `_id` can only take a maximum of 32 characters. Generating the UUID as a 32-character hexadecimal string fixes the issue. The existing tests for `Collection.add` will pass with this fix.
1 parent b8ec2ac commit b2be393

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/mysqlx/dbdoc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def keys(self):
5353

5454
def ensure_id(self):
5555
if "_id" not in self.__dict__:
56-
self.__dict__["_id"] = str(uuid.uuid4())
56+
self.__dict__["_id"] = uuid.uuid4().hex
5757
return self.__dict__["_id"]
5858

5959
def __str__(self):

0 commit comments

Comments
 (0)