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.99k stars 400 forks source link

Mismatched extending constraint causes an internal error #1441

Closed vpetrovykh closed 4 years ago

vpetrovykh commented 4 years ago

Steps to Reproduce:

db> CREATE ABSTRACT CONSTRAINT `🚀🍿` EXTENDING max_len_value;
OK: CREATE
db> CREATE SCALAR TYPE foo EXTENDING str {
...     CREATE CONSTRAINT `🚀🍿`(10);
... };
ERROR: InternalServerError: 'NoneType' object has no attribute 'get_parameter_name'
  Hint: This is most likely a bug in EdgeDB. Please consider opening an issue ticket at https://github.com/edgedb/edgedb/issues/new?template=bug_report.md
  Server traceback:
      Traceback (most recent call last):
        File "/home/victor/dev/magicstack/edgedb/edb/server/procpool/worker.py", line 75, in worker
          res = await meth(*args)
        File "/home/victor/dev/magicstack/edgedb/edb/server/compiler/compiler.py", line 1480, in compile_eql_tokens
          return self._compile(ctx=ctx, tokens=eql_tokens)
        File "/home/victor/dev/magicstack/edgedb/edb/server/compiler/compiler.py", line 1141, in _compile
          comp: dbstate.BaseQuery = self._compile_dispatch_ql(ctx, stmt)
        File "/home/victor/dev/magicstack/edgedb/edb/server/compiler/compiler.py", line 1076, in _compile_dispatch_ql
          return self._compile_ql_ddl(ctx, ql)
        File "/home/victor/dev/magicstack/edgedb/edb/server/compiler/compiler.py", line 763, in _compile_ql_ddl
          cmd = s_ddl.delta_from_ddl(
        File "/home/victor/dev/magicstack/edgedb/edb/schema/ddl.py", line 466, in delta_from_ddl
          _, cmd = _delta_from_ddl(ddl_stmt, schema=schema, modaliases=modaliases,
        File "/home/victor/dev/magicstack/edgedb/edb/schema/ddl.py", line 496, in _delta_from_ddl
          schema = cmd.apply(schema, context)
        File "/home/victor/dev/magicstack/edgedb/edb/schema/delta.py", line 1531, in apply
          schema = self._create_innards(schema, context)
        File "/home/victor/dev/magicstack/edgedb/edb/schema/inheriting.py", line 622, in _create_innards
          return super()._create_innards(schema, context)
        File "/home/victor/dev/magicstack/edgedb/edb/schema/delta.py", line 1498, in _create_innards
          schema = op.apply(schema, context=context)
        File "/home/victor/dev/magicstack/edgedb/edb/schema/delta.py", line 1527, in apply
          schema = self._create_begin(schema, context)
        File "/home/victor/dev/magicstack/edgedb/edb/schema/constraints.py", line 641, in _create_begin
          constr_base, attrs, inh = Constraint.get_concrete_constraint_attrs(
        File "/home/victor/dev/magicstack/edgedb/edb/schema/constraints.py", line 226, in get_concrete_constraint_attrs
          args_map = qlutils.index_parameters(
        File "/home/victor/dev/magicstack/edgedb/edb/edgeql/utils.py", line 92, in index_parameters
          result[p.get_parameter_name(schema)] = e
      AttributeError: 'NoneType' object has no attribute 'get_parameter_name'
1st1 commented 4 years ago

Well, this one is independent of emojis, it doesn't work with "normal" names either.

1st1 commented 4 years ago

The problem is that you didn't specify any args and the ddl compiling pipeline didn't check that the new constraint is therefore incompatible with what it extends.

vpetrovykh commented 4 years ago

Oh. I tested it with plain max_len_value, but not the derived constraint. Not a unicode bug (which is probably a good thing), but a bug with validation for sure.

1st1 commented 4 years ago

I'm on this.