Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-3026

Provide DQL TYPE() function to access discriminator column value

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.2
    • Fix Version/s: None
    • Component/s: DQL
    • Security Level: All
    • Labels:

      Description

      It is not currently possible to figure out which type a value is associated with if you do not wish to perform object hydrations. There should be a TYPE() function in DQL which returns the value of the discriminator column or the associated class name, e.g

      SELECT u.id, TYPE(u) FROM Some\Base\Class u

      which would return

      [[1, 'foo'], [2, 'bar']]

      if there were two classes foo and bar which inherit from the base class.

        Activity

        Hide
        Marco Pivetta added a comment -

        I'd add that these should be 2 functions:

        • TYPE(e) gives you the class name for a given fetched result
        • DISCRIMINATOR(e) gives you the discriminator value for a given fetched result
        Show
        Marco Pivetta added a comment - I'd add that these should be 2 functions: TYPE(e) gives you the class name for a given fetched result DISCRIMINATOR(e) gives you the discriminator value for a given fetched result
        Hide
        Benjamin Eberlei added a comment -

        Not an issue or something to add as a new feature. There is no way to get the discriminator value.

        Show
        Benjamin Eberlei added a comment - Not an issue or something to add as a new feature. There is no way to get the discriminator value.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Nils Adermann
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: