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

Fixing issue in exclusion of new entities when positions are updated. #1279

Merged
merged 1 commit into from Apr 8, 2015

Conversation

leonex-cs1
Copy link
Contributor

In some circumstances the update of positions is executed before all new entities are persisted. In this case the new entities' identifier is NULL, which makes the query AND n.{$meta->identifier[0]} NOT IN (:excluded) failing, because xyz NOT IN (NULL) is always false.

This patch is addressing the code added in #1214.

l3pp4rd added a commit that referenced this pull request Apr 8, 2015
Fixing issue in exclusion of new entities when positions are updated.
@l3pp4rd l3pp4rd merged commit 0f130d2 into doctrine-extensions:master Apr 8, 2015
@l3pp4rd
Copy link
Contributor

l3pp4rd commented Apr 8, 2015

thanks ;)

@francescolaffi
Copy link

thanks, got bitten by the bug addressed by this patch

we downgraded to 2.3.11 while waiting this to be included in a stable release

meanwhile since we were adding new elements with position 0 this resulted in having quite a bit of mangled positions sets (duplicates, negative positions, ...), here is a query similar to what we used to bring stuff to working order again, in case anyone else is in the same situation

set @current_group := null, @pos := 0;
update my_table
set position_column = IF(group_column = @current_group, @pos := @pos+1, @pos := 0),
    group_column = (@current_group := group_column)
order by group_column ASC, position_column ASC;

Its for a simple situation in mysql, but it can be adapted to other situations/dbs.

@rvanlaak
Copy link
Contributor

rvanlaak commented May 5, 2015

Does Sortable work on Symfony 2.6.6 for you? The sorting condition is not added to my query. Reverting to 2.6.5 does solve this.

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

4 participants