Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthorThijs
    • CommentTimeFeb 3rd 2008 edited
     

    I'm not sure you could call this a bug, but if you're validating uniqueness on a date field using MySQL it is something to be aware of.

    In the installer: 'datum' is a ordinary date field (and not a datetime field. I didn't need hours and minutes)

    function up_1()
    {
        $this->createTable('meterreadingdates', "
          id,
          user_id,
          datum date
        ");
    }
    

    There should be only one record for every 'datum', so in the model is a validation on uniqueness.

    class Meterreadingdate extends ActiveRecord
    {
        var $belongs_to = 'user';
        var $has_many   = 'meterreadings';
    
        function validate(){
            $this->validatesUniquenessOf('datum');
        }
    }
    

    But, here it comes, just before saving a new row Akelos checks the uniqueness of the 'datum' field thinking it's a datetime field.

    From the $this-> meterreadingdate->dbug() :

    SELECT * FROM meterreadingdates WHERE meterreadingdates.datum = '2008-02-03 00:00:00' LIMIT 1
    

    .. because of the ' 00:00:00' bit an already existing record is not found. (at least not using MySQL)

    Changing the column type from date to datetime solves the problem of course.

    • CommentAuthorKaste
    • CommentTimeFeb 17th 2008
     

    I think we can call this a bug. do you have a test? ->TRAC

    • CommentAuthorThijs
    • CommentTimeFeb 19th 2008
     

    Okay, I'll make a test and make a ticket in the Trac (somewhere next month though)

    • CommentAuthorKaste
    • CommentTimeFeb 22nd 2008
     

    now ticket #124

Add your comments
    Username Password
  • Format comments as