make them 2 separate methods and allow you to override the traditional insert_or_update behavior in the object declaration as part of the meta object maybe

__PACKAGE__->meta->use_on_duplicate_key_update(1);

then the helper will know whether to over ride to the new method or to default to the existing one. I  think its ok because ODK will need access to meta anyways to know which keys are unique or primary. that the great part about this statement, if you have a PK and a unique key, it will update if either matches. which is also a reason why it should be turned on explicitly as it may surprise some people with both a PK and a unique key

On 6/1/06, John Siracusa <[EMAIL PROTECTED]> wrote:
On 6/1/06 5:43 PM, John Siracusa wrote:
>> also there since isnt anything like insert_or_update should i :
>> $class->insert unless $class->update;
>>
>> or is save smart enough for that?
>
> The save() method will do the right thing.

Actually, it'll only do the right thing when it knows if an object is in the
db (e.g., if it was previously load()ed.  I'll add an insert_or_update()
helper.

>> any plans for supporting on duplicate key update?
>
> I'm not sure what you mean by this...

Okay, now I do know what you mean, and it appears to be a MySQL-ism.  It
shouldn't be hard to add, however.  Any ideas on an interface?  I'm leaning
towards making two helpers instead of just one: insert_or_update() and
insert_and_on_duplicate_key_update(), which you can rename to whatever you
want when you use them, naturally:

    package MyDB::Base;
    ...
    use Rose::DB::Object::Helpers
    {
      insert_and_on_duplicate_key_update => 'insert_or_update',
    };

Or should I just make the insert_or_update() method use "on duplicate key"
automatically when running against mysql version <whatever> or later?  Hm, I
don't want to have to check the db version once per db object, though.  Any
better ideas?

-John




-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to