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

Unexpected InvalidReferenceError in rewrite update expression #7307

Open
devlzcode opened this issue May 6, 2024 · 0 comments
Open

Unexpected InvalidReferenceError in rewrite update expression #7307

devlzcode opened this issue May 6, 2024 · 0 comments
Labels

Comments

@devlzcode
Copy link

devlzcode commented May 6, 2024

  • EdgeDB Version: EdgeDB 5.3+a480d96
  • EdgeDB CLI Version: EdgeDB CLI 5.1.0+8ff9f85
  • OS Version: macOS 14.4

Steps to Reproduce:

  1. Run edgedb migration create with the schema.

Schema:

module default {
    type User  {
        required name: str;
    };

    type Item {
        required name: str;
    };

    type UserItem {
        required status: str;
        status_last_updated_at: datetime {
            rewrite update using (
                if __specified__.status then datetime_of_statement()
                else __old__.status_last_updated_at
            )
        };
        required item: Item;
        user: User;
        user_last_updated_at: datetime {
            rewrite update using (
                if __specified__.user then datetime_of_statement()
                else __old__.user_last_updated_at
            )
        };
    };

    type Trade {
        required sender: User;
        required recipient: User;
        multi sender_item_ids: uuid;
        multi recipient_item_ids: uuid;
        trigger on_insert after insert for each do (
            for i in {
                (__new__.sender, <UserItem><uuid>__new__.recipient_item_ids),
                (__new__.recipient, <UserItem><uuid>__new__.sender_item_ids)
            } union (update i.1 set { user := i.0 })
        )
    };
}

InvalidReferenceError: status is not a member of tuple<__type__: std::bool, id: std::bool, item: std::bool, user: std::bool, status_last_updated_at: std::bool>

The culprit for this issue appears to be the on_insert trigger in Trade because when removed it no longer occurs. Removing status_last_updated_at will also fix the issue but is an odd behavior considering that user_last_updated_at uses the same logic. #6800 might be a similar issue, however it mentions using an extended type which I have none of.

Edit: Modifying the update clause in the trigger to include status := "test" will also fix the issue.

@raddevon raddevon added the bug label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants