edgedb / edgedb

A graph-relational database with declarative schema, built-in migration system, and a next-generation query language
https://edgedb.com
Apache License 2.0
12.93k stars 396 forks source link

Error in `constraint expression on (...)` when using ranges #5878

Closed iaroslaff closed 9 months ago

iaroslaff commented 1 year ago

Steps to Reproduce:

  1. Create a very simple schema (shown below);
  2. Run edgedb migration create -I<you_edgedb_instance>;
  3. Run edgedb migrate -I<you_edgedb_instance>

Gives an error:

edgedb error: InternalServerError: function edgedbstd.c9f35653-1c46-11ee-b1be-95bee0448ec8(boolean, boolean, boolean, bigint, bigint) does not exist Hint: This is most likely a bug in EdgeDB. Please consider opening an issue ticket at ... Server traceback: edb.errors.InternalServerError: function edgedbstd.c9f35653-1c46-11ee-b1be-95bee0448ec8(boolean, boolean, boolean, bigint, bigint) does not exist edgedb error: error in one of the migrations

Schema:

module default {
    type User {
        name: str {
            constraint expression on ( contains(range(2, 30), len(__subject__)) );
        };
    };
};

But if you replace range(...) with simple string for experimentation - migration is created and applied perfectly well: constraint expression on ( contains("abc", __subject__) );

msullivan commented 10 months ago

Probably this is because of how range is special-cased in relgen.

If we can fix it by using a simple_special_case instead so it works in singleton mode, that's probably best?

Either way, we should produce a real error from somewhere when we need to compile a function call in singleton mode and it is marked func_sql_expr and we don't have a specialization