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

Fix sorting error on self-referencing fields #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mutr
Copy link

@mutr mutr commented Dec 3, 2019

There is a chance that models will be sorted wrong if self-referencing model coexists with foreign models.

How to reproduce:

  1. Open project test.tar.gz
  2. Run statik --watch --no-browser -v several times.
2019-12-03 05:41:47,299 statik.database DEBUG   Unsorted models: ['File', 'Info', 'Tag']                                                                                                    
2019-12-03 05:41:47,300 statik.database DEBUG   Sorting round: 1 (['File', 'Info', 'Tag'])                                                                                                  
2019-12-03 05:41:47,300 statik.database DEBUG   Sorting round: 2 (['Tag', 'File', 'Info'])                                                 
2019-12-03 05:41:47,301 statik.database DEBUG   Sorted models: ['Tag', 'File', 'Info'] (2 rounds)                   
2019-12-03 05:41:47,301 statik.database DEBUG   Loading data for model: Tag                                                                                                                 
2019-12-03 05:41:47,303 statik.database DEBUG   Loading 3 instance(s) for model: Tag                                                                  
2019-12-03 05:41:47,303 statik.database DEBUG   StatikDatabaseInstance(model=Tag, pk=0, value=tag1)                                  
2019-12-03 05:41:47,313 statik.database DEBUG   StatikDatabaseInstance(model=Tag, pk=1, value=tag2)                                                   
2019-12-03 05:41:47,314 statik.database DEBUG   StatikDatabaseInstance(model=Tag, pk=2, value=tag3)                            
2019-12-03 05:41:47,314 statik.database DEBUG   Loading 0 instance(s) for model: Tag                                                                  
2019-12-03 05:41:47,317 statik.database DEBUG   Loading data for model: File                                                         
2019-12-03 05:41:47,324 statik.database DEBUG   Loading 4 instance(s) for model: File                                                                 
2019-12-03 05:41:47,324 statik.database DEBUG   Attempting to look up primary keys for ManyToMany field relationship: ['0', '1', '2']
2019-12-03 05:41:47,326 statik.database WARNING 0 not found in <class 'statik.database.Info'>                                                  
2019-12-03 05:41:47,327 statik.database WARNING 1 not found in <class 'statik.database.Info'>                                                                                               
2019-12-03 05:41:47,335 statik.database WARNING 2 not found in <class 'statik.database.Info'>```

Expected behaviour: `Sorted models: ['Info', 'Tag', 'File']`

There is a chance that model will be sorted wrong if self-referencing model coexists with foreign models.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant