xtdb

esp1 2024-10-12T23:49:48.945399Z

What is the idomatic way to do incremental update in XTQL? In SQL you can do update docs set foo = 'bar' where _id = 1; and it will only update foo and leave the rest of the data intact. However in XTQL [:put-docs :docs {:xt/id 1, :foo 'bar'}] will set the value of foo but wipe out all other data related to :xt/id 1.

jarohen 2024-10-13T10:38:56.297449Z

noted - thanks folks 🙏

1
jarohen 2024-10-13T10:40:59.637849Z

https://github.com/xtdb/xtdb/issues/3787

✔️ 1
seancorfield 2024-10-12T23:53:39.984219Z

Since it is document-based, you have to fetch the whole document, update that one field, and write a new version of the whole document back. In XT2, that is what that SQL statement does behind the scenes, even tho' it looks like it "will only update foo and the rest of the data intact".

seancorfield 2024-10-12T23:55:16.899469Z

In XT1, you could do that sort of thing with a transaction fn. I haven't really kept up with XTQL since I'd prefer to use SQL with XT2.

seancorfield 2024-10-12T23:58:35.500969Z

According to the XTQL docs, "update" is :insert-into with a query??? https://docs.xtdb.com/reference/main/xtql/txs.html#_update

seancorfield 2024-10-13T00:03:53.455989Z

(Looks like :insert-into is duplicated into the :update section so that must be wrong)

seancorfield 2024-10-13T00:05:57.475599Z

Ah, here we are: https://docs.xtdb.com/tutorials/introducing-xtql.html#_update

esp1 2024-10-13T00:24:35.370439Z

Aha! Thank you!

esp1 2024-10-13T01:05:01.418509Z

The incorrect documentation really threw me 😞. Hopefully that will be fixed!