cozodb / cozo

A transactional, relational-graph-vector database that uses Datalog for query. The hippocampus for AI!
https://cozodb.org
Mozilla Public License 2.0
3.24k stars 92 forks source link

UUID values get coerced into list of ints if inside a json object #269

Open creatorrr opened 2 weeks ago

creatorrr commented 2 weeks ago

This query:

{
  ?[x] <- [[rand_uuid_v4()]]
  :create _t1 { x }
}
{
  ?[m, x] := *_t1{ x }, m = {"x": x}
}

returns:

{"x":[121,28,28,145,81,157,79,140,149,37,235,235,103,33,105,109]}   791c1c91-519d-4f8c-9525-ebeb6721696d

but should return the uuidv4 string instead. Currently I was unable to find a way to output the string :(

creatorrr commented 2 weeks ago

for anyone else who ran into this, current workaround I am using (in python):

from uuid import UUID

uuid_int_list_to_uuid4 = lambda data: UUID(bytes=b"".join([i.to_bytes(1, 'big') for i in data]))