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

Computed referencing computed global spuriously rejected as cycle #4181

Open
msullivan opened this issue Aug 1, 2022 · 2 comments
Open

Computed referencing computed global spuriously rejected as cycle #4181

msullivan opened this issue Aug 1, 2022 · 2 comments

Comments

@msullivan
Copy link
Member

  global current_user_id -> uuid;
  global current_user := (select User filter .id ?= global current_user_id);
  
  type User {
    multi link following -> User {
      property created_at -> datetime {
        default := datetime_current();
        readonly := true;
      }
    };
    multi link followers := .<following[is User];
    
    property is_followed := global current_user in .followers;
  }

is rejected with an error

error: definition dependency cycle between property 'is_followed' of object type 'default::User' and global 'default::current_user'

That's not really fair, though. The reference to current_user is just in a computed, and that computed isn't used by the global anyway.

The error comes from SDL processing. If you try to do this directly with DDL, it works just fine.

@msullivan
Copy link
Member Author

@vpetrovykh let me know if you want to take a look at this one, otherwise I'll try to get to it

@studentiks
Copy link

EdgeDB 3.0-dev.7198+88d8c5

Maybe related example?

Access policy gives CycleError. Commenting access policy allows creating first migration and uncommenting it again allows creating second migration that matches this schema.

  global login -> str;
  alias current_user := (select Users filter .login = global login limit 1);

  type Companies {
    required property name -> str { constraint exclusive };


    ### this access policy gives CycleError:
    ### dependency cycle between ('create', 'default::__|company@default|CompanyData') and ('create', 'default::__|company@default|Users')
    access policy login_can_read_own
      allow select
      using ( current_user.company.id ?= .id );
  }

  abstract type CompanyData {
    required link company -> Companies
    {
      default := (select Companies limit 1);
    };
  }

  type Users extending CompanyData {
    required property login -> str { constraint exclusive; };
  }

}


Gives CycleError:

  File "/home/roman/.local/share/edgedb/portable/3.0-dev.7198/lib/python3.10/site-packages/edb/common/topological.py", line 149, in visit
          raise CycleError(
      edb.common.topological.CycleError: dependency cycle between ('create', 'default::__|company@default|CompanyData') and ('create', 'default::__|company@default|Users')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants