xtdb / xtdb

An immutable database for application development and time-travel data compliance, with SQL and XTQL. Developed by @juxt

Home Page:https://xtdb.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Python] Support UUID's first class in expressions

FiV0 opened this issue · comments

Currently it's really awkward to work with python uuid's. You can ingest them as "standard" python uuid's but if you want to query for them you have to create an extra expr.UUID object. We should support everything that one can ingest without any special handling (str, numbers, uuid and likely a bunch of other primitives see #3328) also on the query side (as literal expressions).

def test_xtql_query_with_uuid(client):
    test_uuid = uuid.UUID('6f36f297-b6cf-4c9d-bf7e-8d2e9ed1329b')
    query = (From("people", None, None, False)
             .binding({"xt$id": expr.UUID('6f36f297-b6cf-4c9d-bf7e-8d2e9ed1329b')}, "age"))
    client.submit_tx([PutDocs("people", {"xt$id": test_uuid, "name": "Alice", "age": 30})])
    assert client.query(query) == [{"age": 30}]
commented

Isn't it the case that we're (most likely) not doing XTQL in Python anymore? So it may not be worth fixing this, given that what currently goes in from SQL is just a string. We've not focused on testing XTQL much.

Isn't it the case that we're (most likely) not doing XTQL in Python anymore? So it may not be worth fixing this, given that what currently goes in from SQL is just a string. We've not focused on testing XTQL much.

Yes. I am the guy who would like to keep XTQL in Python as we have it currently, so feel free to ignore these. It might be that in month or two the python sdk is no longer supported.

This one's relevant regardless of whether we keep XTQL in Python or not - there'll be UUIDs in result-sets either way.