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

create_or_update does not call post_save #647

Open
attilamester opened this issue Oct 14, 2022 · 3 comments
Open

create_or_update does not call post_save #647

attilamester opened this issue Oct 14, 2022 · 3 comments

Comments

@attilamester
Copy link

attilamester commented Oct 14, 2022

Hi! In neomodel==4.0.8, create_or_update does not call the post_save hook. Is this by design intended? Thanks!

@a-takahashi223
Copy link
Contributor

I ran the following code in 4.0.8.

class RelA(StructuredRel):
    def pre_save(self):
        print("relation pre_save")

    def post_save(self):
        print("relation post_save")


class NodeA(StructuredNode):
    b = RelationshipTo("NodeB", "SOME_REL", model=RelA)

    def pre_save(self):
        print("node pre_save")

    def post_save(self):
        print("node post_save")

    def pre_delete(self):
        print("node pre_delete")

    def post_delete(self):
        print("node post_delete")

    def post_create(self):
        print("node post_create")


class NodeB(StructuredNode):
    pass


a = NodeA().save()
a.b.connect(NodeB().save())
a.delete()

Output:

node pre_save
node post_create
node post_save
relation pre_save
relation post_save
node pre_delete
node post_delete

All hooks works well.

get_or_create() and create_or_update() do not invoke post_create. https://neomodel.readthedocs.io/en/latest/hooks.html

@mariusconjeaud mariusconjeaud changed the title Some hooks are only available using django_neomodel (pre_save, post_save, pre_delete, post_delete) create_or_update does not call post_save Feb 1, 2023
@mariusconjeaud
Copy link
Collaborator

Changed the title to your actual problem. Wouldn't know if this is by design, or something to add. Do you have an idea @a-takahashi223 ?

@a-takahashi223
Copy link
Contributor

I ran the test because the original title "Some hooks are only available using django_neomodel (pre_save, post_save, pre_delete, post_delete)" is concerned. I don't know about django_neomodel or create_or_update. Sorry.

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

3 participants