I'm loading a ton of records into a MySQL database using Ruby and Datamapper. These records are mostly inserts but there are a fair number of updates. I basically want to 'upsert' all the columns for these records in the database. The only options I can find are:

1) Query for a record. If it exists, update it. If not, create a record. (Always one extra query)
2) Try to create a new record. Catch duplicate key errors. Query for the existing record. Update those records. (When there is an update, 2 extra queries)

I'd like to utilize MySQL's `On Duplicate Key Update` because it seems much more efficient. Is there a way to do this in Datamapper? Any other suggestions?