Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1716

Better unique constraints handling or even updateIfExists/findOneOrCreate

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.2.1
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      It is too hard handle rows duplication now. As adviced here http://stackoverflow.com/questions/3967226/checking-for-duplicate-keys-with-doctrine-2 we should catch \PDOException with code 23000. This is bad behavior.

      So I propose:
      a. Add DuplicateRowException wich will throwed by flush method (maybe wrapped PDOException) with method "getDuplicatedProperties" (based on sql error description parsing + mapping)
      b. Add method findOneOrCreate (hello, Propel!) or updateIfExists to ObjectInterface, EntityManager
      c. Combine a, b

        Activity

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Konstantin
          • Votes:
            6 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated: