Doctrine 1
  1. Doctrine 1
  2. DC-950

Doctrine_Record magic _set() doesn't validate field type for timestamp/datetime/etc..

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: Record
    • Labels:
      None

      Description

      So I ran into this recently. the magic _set() in Doctrine_Record doesn't check/validate the type of the field. The use case is when you you do something like:
      setCreatedAt(time()); This will not work correctly with date/time or timestamp types in Doctrine, even though Propel handles this fine. Also MYSQL will not throw an error with default sql_mode and will put garbage data into the database.

      The only way to generate the right date/time value is to always format that string with the "right" format. This should be easier and can be easier if it supported either a timestamp (time() or a DateTime() object (just like Symfony plugin does for setDateTimeObject() function). This is just a few lines of code, let me know if I should attach a patch.

      I would love to see the Doctrine_Record implement this functionality. There's a ton of results on frustrated users trying to figure out how to set the date/time values properly using Doctrine.

        Activity

        Hide
        Gennady Feldman added a comment -

        Symfony actually added a work around by writing another function "setDateTimeObject()" to set these fields in a more friendly way. Ideally I would love to see support for time() and date_create() natively in Doctrine.

        Show
        Gennady Feldman added a comment - Symfony actually added a work around by writing another function "setDateTimeObject()" to set these fields in a more friendly way. Ideally I would love to see support for time() and date_create() natively in Doctrine.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Gennady Feldman
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: