GithubHelp home page GithubHelp logo

p4bgroup / phalcon-nested-sets Goto Github PK

View Code? Open in Web Editor NEW
2.0 5.0 2.0 2.94 MB

Nested Set Model implementation for Phalcon Framework

License: MIT License

PHP 100.00%
phalcon nested-sets behaviour tree phalcon-framework

phalcon-nested-sets's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

phalcon-nested-sets's Issues

parent_id is not correctly calculated on delete

Initial structure

categories

id name parent lft rgt depth tree
1 online 0 1 14 0 online
4 wireless 1 2 3 1 wireless
5 neural 1 4 11 1 neural
13 back-end 5 5 6 2 back-end
14 redundant 5 7 8 2 redundant
15 haptic 5 9 10 2 haptic
6 auxiliary 1 12 13 1 auxiliary

Operation: delete id 5

categories

id name parent_id lft rgt depth _name
1 online 0 1 12 0 online
4 wireless 1 2 3 1 wireless
13 back-end 0 4 5 1 back-end
14 redundant 0 6 7 1 redundant
15 haptic 0 8 9 1 haptic
6 auxiliary 1 10 11 1 auxiliary

Problem:

categories: 13,14,15, should have parent 1
actual: categories 13,14,14 have parent 0

move node to separate sub-tree

Table

categories

id name parent_id lft rgt depth _name
1 online 0 1 14 0 online
4 wireless 1 2 3 1 wireless
5 neural 1 4 11 1 neural
13 back-end 5 5 6 2 back-end
14 redundant 5 7 8 2 redundant
15 haptic 5 9 10 2 haptic
6 auxiliary 1 12 13 1 auxiliary
2 back-end 0 15 28 0 back-end
7 multi-byte 2 16 17 1 multi-byte
8 wireless 2 18 25 1 wireless
16 virtual 8 19 20 2 virtual
17 bluetooth 8 21 22 2 bluetooth
18 multi-byte 8 23 24 2 multi-byte
9 optical 2 26 27 1 optical
3 back-end 0 29 42 0 back-end
10 auxiliary 3 30 31 1 auxiliary
11 cross-platform 3 32 39 1 cross-platform
19 open-source 11 33 34 2 open-source
20 haptic 11 35 36 2 haptic
21 back-end 11 37 38 2 back-end
12 wireless 3 40 41 1 wireless

action

update category 5, set parent 17

expected

category 5, parent id = 17

actual

category 5, parent id is 0

delete root calculates parent wrong

Table

categories

id name parent_id lft rgt depth _name
1 online 0 1 14 0 online
4 wireless 1 2 3 1 wireless
5 neural 1 4 11 1 neural
13 back-end 5 5 6 2 back-end
14 redundant 5 7 8 2 redundant
15 haptic 5 9 10 2 haptic
6 auxiliary 1 12 13 1 auxiliary
2 back-end 0 15 28 0 back-end
7 multi-byte 2 16 17 1 multi-byte
8 wireless 2 18 25 1 wireless
16 virtual 8 19 20 2 virtual
17 bluetooth 8 21 22 2 bluetooth
18 multi-byte 8 23 24 2 multi-byte
9 optical 2 26 27 1 optical
3 back-end 0 29 42 0 back-end
10 auxiliary 3 30 31 1 auxiliary
11 cross-platform 3 32 39 1 cross-platform
19 open-source 11 33 34 2 open-source
20 haptic 11 35 36 2 haptic
21 back-end 11 37 38 2 back-end
12 wireless 3 40 41 1 wireless

action

delete category id 2

expected

categories 7, 8, 9 should have parent 0
categories 16, 17, 18 should keep the parent to 8

actual

categories 16,17,18 have parent 0

fix: update of the parent field should only affect immediate sub-nodes

root node moved as leaf

Table

categories

id name parent_id lft rgt depth _name
1 online 0 1 14 0 online
4 wireless 1 2 3 1 wireless
5 neural 1 4 11 1 neural
13 back-end 5 5 6 2 back-end
14 redundant 5 7 8 2 redundant
15 haptic 5 9 10 2 haptic
6 auxiliary 1 12 13 1 auxiliary
2 back-end 0 15 28 0 back-end
7 multi-byte 2 16 17 1 multi-byte
8 wireless 2 18 25 1 wireless
16 virtual 8 19 20 2 virtual
17 bluetooth 8 21 22 2 bluetooth
18 multi-byte 8 23 24 2 multi-byte
9 optical 2 26 27 1 optical
3 back-end 0 29 42 0 back-end
10 auxiliary 3 30 31 1 auxiliary
11 cross-platform 3 32 39 1 cross-platform
19 open-source 11 33 34 2 open-source
20 haptic 11 35 36 2 haptic
21 back-end 11 37 38 2 back-end
12 wireless 3 40 41 1 wireless

action

category id 1 updated as sub-category for category id 14

expected

categories 4-6 should have parent 0, depth 0
categories 13-15 should keep parent, depth 1
category 1 - parent set to 14, depth set to 2

actual

parent id is 0, depth is actually set to 3
category 13-15 parent is 0

updating a category calculates parent and depth wrong

Table

categories

id name parent_id lft rgt depth _name
1 online 0 1 14 0 online
4 wireless 1 2 3 1 wireless
5 neural 1 4 11 1 neural
13 back-end 5 5 6 2 back-end
14 redundant 5 7 8 2 redundant
15 haptic 5 9 10 2 haptic
6 auxiliary 1 12 13 1 auxiliary
2 back-end 0 15 28 0 back-end
7 multi-byte 2 16 17 1 multi-byte
8 wireless 2 18 25 1 wireless
16 virtual 8 19 20 2 virtual
17 bluetooth 8 21 22 2 bluetooth
18 multi-byte 8 23 24 2 multi-byte
9 optical 2 26 27 1 optical
3 back-end 0 29 42 0 back-end
10 auxiliary 3 30 31 1 auxiliary
11 cross-platform 3 32 39 1 cross-platform
19 open-source 11 33 34 2 open-source
20 haptic 11 35 36 2 haptic
21 back-end 11 37 38 2 back-end
12 wireless 3 40 41 1 wireless

action

update category id 5, parent 13

expected

category 5, parent is 13, depth is 2

actual

category 5, parent is 0, depth is 3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.