kotolex / surrealist

Python library to work with SurrealDB
MIT License
20 stars 0 forks source link

`.set("a=1", b=2)` silently ignores kwargs #44

Closed NicoWeio closed 4 months ago

NicoWeio commented 4 months ago

This happened to me when using db.relate and I guess the same issue exists elsewhere. I would have liked surrealist to either combine the string and the kwargs or raise an exception when trying to use both.

kotolex commented 4 months ago

I assumed that if the user uses a string representation, he will no longer use kwargs, but you are right - it can be confusing. I guess "combine the string and the kwargs" will be the best choice here E.g.

# RELATE person:john->wrote->article:best SET title = "title", text = "text";
print(db.relate("person:john->wrote->article:best").set('title = "title"', text="text"))

# RELATE person:john->wrote->article:best SET title = "title", text = "text";
print(db.relate("person:john->wrote->article:best").set(title="title", text="text"))

# RELATE person:john->wrote->article:best SET title = "title", text = "text";
print(db.relate("person:john->wrote->article:best").set('title = "title", text = "text"'))
kotolex commented 4 months ago

Same exists for update and create, but it all use same class, fix it with version 0.5

kotolex commented 4 months ago

45

kotolex commented 4 months ago

@NicoWeio please update to 0.5, it should work there pip install surrealist==0.5.0

NicoWeio commented 4 months ago

Works nicely – thanks for the quick fix!