UPDATE table
SET column = '123'
WHERE id = 2
AND NOT EXISTS (
SELECT 1
FROM table
WHERE column = '123'
);
Should NOT work if there is a row with column value 123 in the table already and YET it works and changes the row.
Huge problem for me so fix it as soon as possible.
Thanks for reporting. Would you mind opening an issue on GitHub (Issues · crate/crate · GitHub), so our development team can interact with you directly?
While Crate.io is a company, the community is a place for a civilised discussion around CrateDB for everyone. Also CrateDB itself is open source software under Apache License v2.0. Which implies that we are open to feedback and contributions to make it a better software, however it also specifically states, that we provide the software
“AS IS”,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
Huge problem for me so fix it as soon as possible.
While we typically don’t discriminate on bugs in any way, if you need a speedy bug fix for a specific problem, I’d typically recommend to get in a commercial agreement.
Unfortunately you also left out one very important detail in your example, specifically that you defined id as PRIMARY KEY. Considering that - and while I see this as a bug - I would not consider this “HUGE”, as with WHERE id = 2 you specifically select on one record, and one record only.
To elaborate more on the request for raising a GitHub issue: On opening a new issue, you will see a form with several input fields. This structure helps to process issues in a standardized way, such as having complete steps to reproduce. As @proddata already mentioned, your issue depends on the details of your CREATE TABLE statement (primary key definition), which wasn’t shared.
Additionally, you will receive direct updates from the development team when a fix is available, as well as potentially additional information, like applicable workarounds. I find it a fair ask to raise a GitHub issue in return for that.
Also, FWIW, while waiting for a fix you may want to try the following workaround which seems to work for me on 5.5.2:
INSERT INTO f2 (id,column1)
SELECT id
,CASE WHEN NOT EXISTS (
SELECT 1
FROM f2
WHERE column1 = '123'
)
THEN '123'
ELSE column1
END
FROM f2
WHERE id = 2
ON CONFLICT(id) DO UPDATE SET column1 = excluded.column1;
Hi,
This will be available on the next release which is coming soon, but in the meanwhile you can see this working already on the latest nightly build (docker image: crate/crate:nightly-5.6.0-2024-01-09-00-02)