Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sequence default fails in migration #3494

Closed
elprans opened this issue Feb 15, 2022 Discussed in #3493 · 3 comments · Fixed by #3527
Closed

Sequence default fails in migration #3494

elprans opened this issue Feb 15, 2022 Discussed in #3493 · 3 comments · Fixed by #3527
Assignees

Comments

@elprans
Copy link
Member

elprans commented Feb 15, 2022

Discussed in #3493

Originally posted by tchak February 15, 2022
I have the following schema:

module default {
  scalar type ProjectNumber extending sequence;

  type Project {
    required property number -> ProjectNumber {
      constraint exclusive;
    }
    required property name -> str;
  }
}

I expect number to be autofilled. But when I use this schema from TypeScript driver type signature refuses to let me create a Project without specifying a number property. I tried the following schema but it failed on migration:

module default {
  scalar type ProjectNumber extending sequence;

  type Project {
    required property number -> ProjectNumber {
      constraint exclusive;
      default := sequence_next(introspect ProjectNumber);
    }
    required property name -> str;
  }
}

Is this is a bug or intended behaviour ?

@elprans
Copy link
Member Author

elprans commented Feb 15, 2022

        File "/home/elvis/dev/edgedb/edgedb/edb/pgsql/delta.py", line 3061, in get_pointer_default
          default_value = schemamech.ptr_default_to_col_default(
        File "/home/elvis/dev/edgedb/edgedb/edb/pgsql/schemamech.py", line 417, in ptr_default_to_col_default
          sql_expr = compiler.compile_ir_to_sql_tree(ir, singleton_mode=True)
        File "/home/elvis/dev/edgedb/edgedb/edb/pgsql/compiler/__init__.py", line 129, in compile_ir_to_sql_tree
          raise errors.InternalServerError(*args) from e
      edb.errors.InternalServerError: no IR compiler handler for <class 'edb.ir.ast.TypeIntrospection'>

@tchak
Copy link
Contributor

tchak commented Feb 15, 2022

Thanks for quick answer!
So once the bug is resolved if I want correctly typed behaviour in the query builder I should use the second version of the schema? The documentation makes it sound as if autoincrement behaviour is enabled without explicit default with a call to sequence_next.

@elprans
Copy link
Member Author

elprans commented Feb 15, 2022

Yes, sequence scalars have an implicit default, you don't need to specify it explicitly. The querybuilder needs to be adjusted to be aware of the fact.

msullivan added a commit that referenced this issue Feb 21, 2022
Fixes #3494.

At least kind of. We could also probably support this. The main problem
is just that sequence_next wants the type as an extra argument.
msullivan added a commit that referenced this issue Feb 21, 2022
Fixes #3494.

At least kind of. We could also probably support this. The main problem
is just that sequence_next wants the type as an extra argument.
msullivan added a commit that referenced this issue Feb 21, 2022
Fixes #3494.

At least kind of. We could also probably support this. The main problem
is just that sequence_next wants the type as an extra argument.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants