edgedb icon indicating copy to clipboard operation
edgedb copied to clipboard

Generate empty block when necessary.

Open Androidown opened this issue 3 years ago • 4 comments

Currently an empty ALTER TYPE ddl like

ALTER TYPE Foo {};

will be re-generated by codegen module as

ALTER TYPE FOO;

, which is invalid syntax.

This is bad because in production it will create a broken migration record with script field value as ALTER TYPE FOO;, and dump - restore that DB will fail with a syntax error (although I don't know if include_migration might be false in a dump/restore process).

Androidown avatar Sep 19 '22 10:09 Androidown

All commit authors signed the Contributor License Agreement.
CLA signed

gel-data-cla[bot] avatar Sep 19 '22 10:09 gel-data-cla[bot]

The idea here looks reasonable. Could you look at the test failure?

msullivan avatar Sep 19 '22 21:09 msullivan

@Androidown where is this empty ALTER TYPE coming from? While the fix is correct, I think ultimately EdgeDB should reject this command as it's a no-op.

1st1 avatar Sep 19 '22 21:09 1st1

@Androidown where is this empty ALTER TYPE coming from? While the fix is correct, I think ultimately EdgeDB should reject this command as it's a no-op.

I agree that such ddl is a no-op and no migration record should be created. But currently you can reproduce this problem with the following DDL

CREATE TYPE X;
ALTER TYPE X {};

Both are valid edgeql syntax and will run as expect. But if you take a look at table schema::Migration, there will be a record of which the value of field script is ALTER TYPE X;.

Androidown avatar Sep 20 '22 01:09 Androidown