Doctrine 1
  1. Doctrine 1
  2. DC-208

Make it possible to define an expression/constant for temporal columns via yaml

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Can't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      some_date:
      type: timestamp
      notnull: true
      default: CURRENT_TIMESTAMP

      http://trac.doctrine-project.org/ticket/1740

      In general (maybe 1.3?) it might make sense to enable people to somehow say that the default should not be quoted. Maybe an additional "flag" like the "fixed: true" we have for string type definitions?

      However for 1.2 I propose that we look if we can change so that default values are never quoted. Rather they are expected to be an expression/constant. This is somewhat unclean, but should address the most common uses cases with minimal invasion into the yaml syntax. Furthermore even if one does need the string to be quoted (for example when setting a default date "2009-03-03", then one could hard quotes into the default "'2009-03-03'" and it should work on most RDBMS (of course only if they support the ISO date format .. which should be the case for even the most obsure locale settings).

        Activity

        Hide
        Lukas Kahwe added a comment -

        i guess for mysql this feature would actually need to work through a trigger, which makes this change even less appealing. maybe we should instead create a behavior that can handle either setting the CURRENT_* constant or setup a trigger.

        In general I think there is some merit to also making it optionally possible to have defaults set inside the model before the data is send to the server (especially for time it can be good to use only the date/time settings from a single server). But this again isnt anything for doctrine 1.2 .. maybe this ticket should be cleaned up into a 2.0 ticket and/or a ticket for a behavior?

        Show
        Lukas Kahwe added a comment - i guess for mysql this feature would actually need to work through a trigger, which makes this change even less appealing. maybe we should instead create a behavior that can handle either setting the CURRENT_* constant or setup a trigger. In general I think there is some merit to also making it optionally possible to have defaults set inside the model before the data is send to the server (especially for time it can be good to use only the date/time settings from a single server). But this again isnt anything for doctrine 1.2 .. maybe this ticket should be cleaned up into a 2.0 ticket and/or a ticket for a behavior?
        Hide
        Jonathan H. Wage added a comment -

        The issue is not present in 2.0. Database default values are not supported(I'm 99% sure). A default value just consists of simple oop. private $field = 'value'; in the entity class definition.

        Show
        Jonathan H. Wage added a comment - The issue is not present in 2.0. Database default values are not supported(I'm 99% sure). A default value just consists of simple oop. private $field = 'value'; in the entity class definition.
        Hide
        Whitefawn added a comment -

        I am using "default now()" quite often in other project. It feels like Doctrine restricting me here and not really helping.

        Is it possible to implement this somehow?

        Show
        Whitefawn added a comment - I am using "default now()" quite often in other project. It feels like Doctrine restricting me here and not really helping. Is it possible to implement this somehow?

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Lukas Kahwe
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: