Giter Club home page Giter Club logo

csdoctrineactassortableplugin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

csdoctrineactassortableplugin's Issues

Integrity constraint violation when deleting multiple items

Hi,

I am using your excellent Symfony plugin, but Im encountering an issue when Im deleting multiple records (with the sortable behaviour offcourse :) ).
Whenever I delete a big set with a Collection delete statement (e.g. $records_collection->delete(); ), I get the following error:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '6-27' for key 'answer_position_sortable_idx'

with the following stack trace:

  1. at () in SF_ROOT_DIR\lib\symfony\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Connection.php line 1082
  2. at Doctrine_Connection->rethrowException(object('PDOException'), object('Doctrine_Connection_Statement')) in SF_ROOT_DIR\lib\symfony\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Connection\Statement.php line 269
  3. at Doctrine_Connection_Statement->execute(array('1', '6', '27')) in SF_ROOT_DIR\lib\symfony\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Connection.php line 1042
  4. at Doctrine_Connection->exec('UPDATE answer SET position = position - ? WHERE (position > ? AND question_id = ?) ORDER BY position', array('1', '6', '27')) in SF_ROOT_DIR\lib\symfony\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query\Abstract.php line 973
  5. at Doctrine_Query_Abstract->_execute(array()) in SF_ROOT_DIR\lib\symfony\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query\Abstract.php line 1026
  6. at Doctrine_Query_Abstract->execute() in SF_ROOT_DIR\plugins\csDoctrineActAsSortablePlugin\lib\listener\Sortable.php line 74
  7. at Doctrine_Template_Listener_Sortable->postDelete(object('Doctrine_Event')) in SF_ROOT_DIR\lib\symfony\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Record\Listener\Chain.php line 282
  8. at Doctrine_Record_Listener_Chain->postDelete(object('Doctrine_Event')) in SF_ROOT_DIR\lib\symfony\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Connection\UnitOfWork.php line 490
  9. at Doctrine_Connection_UnitOfWork->_postDelete(object('Answer')) in SF_ROOT_DIR\lib\symfony\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Connection\UnitOfWork.php line 266
    1. at Doctrine_Connection_UnitOfWork->_executeDeletions(array(object('Answer'))) in SF_ROOT_DIR\lib\symfony\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Connection\UnitOfWork.php line 173
    2. at Doctrine_Connection_UnitOfWork->delete(object('Answer')) in SF_ROOT_DIR\lib\symfony\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Record.php line 2182
    3. at Doctrine_Record->delete(object('Doctrine_Connection_Mysql')) in SF_ROOT_DIR\lib\symfony\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Collection.php line 973
    4. at Doctrine_Collection->delete() in SF_ROOT_DIR\apps\application\modules\api_guidequestions\actions\actions.class.php line 443
    5. at api_guidequestionsActions->executeDeleteanswers(object('sfWebRequest')) in SF_ROOT_DIR\lib\symfony\action\sfActions.class.php line 60
    6. at sfActions->execute(object('sfWebRequest')) in SF_ROOT_DIR\lib\symfony\filter\sfExecutionFilter.class.php line 92
    7. at sfExecutionFilter->executeAction(object('api_guidequestionsActions')) in SF_ROOT_DIR\lib\symfony\filter\sfExecutionFilter.class.php line 78
    8. at sfExecutionFilter->handleAction(object('sfFilterChain'), object('api_guidequestionsActions')) in SF_ROOT_DIR\lib\symfony\filter\sfExecutionFilter.class.php line 42
    9. at sfExecutionFilter->execute(object('sfFilterChain')) in SF_ROOT_DIR\lib\symfony\filter\sfFilterChain.class.php line 53
    10. at sfFilterChain->execute() in SF_ROOT_DIR\lib\symfony\filter\sfBasicSecurityFilter.class.php line 72
    11. at sfBasicSecurityFilter->execute(object('sfFilterChain')) in SF_ROOT_DIR\lib\symfony\filter\sfFilterChain.class.php line 53
    12. at sfFilterChain->execute() in SF_ROOT_DIR\lib\symfony\filter\sfRenderingFilter.class.php line 33
    13. at sfRenderingFilter->execute(object('sfFilterChain')) in SF_ROOT_DIR\lib\symfony\filter\sfFilterChain.class.php line 53
    14. at sfFilterChain->execute() in SF_ROOT_DIR\lib\symfony\controller\sfController.class.php line 238
    15. at sfController->forward('api_guidequestions', 'deleteanswers') in SF_ROOT_DIR\lib\symfony\controller\sfFrontWebController.class.php line 48
    16. at sfFrontWebController->dispatch() in SF_ROOT_DIR\lib\symfony\util\sfContext.class.php line 170
    17. at sfContext->dispatch() in SF_ROOT_DIR\web\index.php line 24

It seems like a bug, so therefore Im creating this issue.

Call to undefined method Doctrine_Record_Listener_Chain::canUpdateWithOrderBy()

Hi, I´m getting the following error when calling $object->promote() from an action:

Fatal error: Call to undefined method Doctrine_Record_Listener_Chain::canUpdateWithOrderBy() in /Volumes/MacintosHD2/public_html/clientes/turiex/plugins/csDoctrineActAsSortablePlugin/lib/template/Sortable.php on line 407

Reverting to commit c19eb95 solves the issue.

Conflicts with SoftDelete

When using Sortable with SoftDelete it can't reorder the positions because the position of the deleted row is still exists and throws an sql error (position is a unique field).
So i added a new line to the beginning of postDelete():

public function postDelete(Doctrine_Event $event)
{
  $fieldName = $this->_options['name'];
  $object    = $event->getInvoker();
  $position  = $object->$fieldName;
  $conn      = $object->getTable()->getConnection();

// quick FIX for softdelete + sortable conflict by [email protected]
$conn->execute("UPDATE ". $object->getTable()->getTableName() ." SET ". $fieldName ." = NULL WHERE id = ". $object->getId() ."");

...
}

problem with PostgreSQL

In Doctrine_Template_Sortable::moveToPosition(), an ORDER BY clause is used within an 'UPDATE' request, which PostgreSQL (I use version 8.4.6) doesn't allow.

My workaround was to remove the '->orderBy(...)' lines in the function.

after last rev update cant demote or promote

getting the following error
Fatal error: Call to undefined method Doctrine_Record_Listener_Chain::canUpdateWithOrderBy() in \plugins\csDoctrineActAsSortablePlugin\lib\template\Sortable.php on line 407

what trying to promote or demote from admin generator symfony 1.4

Updating uniqueBy column

There is still a bug while updating a uniqueBy column :

If the uniqueBy column refer to a Parent object, on PostUpdate, the listener should refresh Positions for the OLD Parent children's.

Otherwise (just the case right now) the positions on the OLD Parent children's will contain a whole at the OldPosition of the modified object.

Conflicts with SoftDelete when cascade delete

I have a model with two objects where one of them has a composite relation with the other. Both objects uses SoftDelete, and the parent cascades the SoftDelete to dependant objects that act as Sortable.
The problem arrise when you delete one element of the parent object. I tryed adding the deleted_at field to the uniqueBy. But, as all the related objects have the same deleted_at value, when the postDelete tries to reorder all the records, it throws a constraint violation.

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.