dolt icon indicating copy to clipboard operation
dolt copied to clipboard

Delete joins throw `table doesn't support DELETE FROM`

Open druvv opened this issue 3 years ago • 1 comments

CREATE TABLE t (col1 int);

DELETE t
FROM t
JOIN dolt_conflicts_t c ON t.col1 = c.their_col1;

druvv avatar Jul 07 '22 00:07 druvv

cc: https://github.com/dolthub/dolt/issues/2134

VinaiRachakonda avatar Jul 07 '22 00:07 VinaiRachakonda

Root cause is #2134

zachmu avatar Feb 11 '23 01:02 zachmu

This needs a better repro. We also don't support delete joins on tables with primary keys.

timsehn avatar Feb 17 '23 19:02 timsehn

$ dolt init
Successfully initialized dolt data repository.
$ dolt sql -q "create table t1 (pk int, c1 int, primary key(pk)); create table t2 (pk int primary key)"
$ dolt ls 
Tables in working set:
     t1
     t2

$ dolt sql -q "insert into t1 values (0,0), (1,1); insert into t2 values (1);"
Query OK, 2 rows affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
$ dolt sql -q "delete from t1 join t2 on t1.pk=t2.pk"
Error parsing SQL
syntax error at position 20 near 'join'
delete from t1 join t2 on t1.pk=t2.pk
                    ^
syntax error at position 20 near 'join'

Should just delete (1, 1) in t1

timsehn avatar Feb 17 '23 19:02 timsehn

> create table xy (x int primary key, y int);
> delete a  from xy a join xy b on a.x = b.x;
table doesn't support DELETE FROM

max-hoffman avatar Feb 17 '23 19:02 max-hoffman

This spill the right error:

$ dolt sql -q "delete t1 from t1 join t2 on t1.pk=t2.pk"
error on line 1 for query delete t1 from t1 join t2 on t1.pk=t2.pk: table doesn't support DELETE FROM
table doesn't support DELETE FROM

timsehn avatar Feb 17 '23 19:02 timsehn

DELETE JOIN support was released yesterday in dolt version 0.54.1

fulghum avatar Mar 02 '23 18:03 fulghum