﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
1073	method_save in meta/__init__.py could make use   of mysql features	Ian@…	Adrian Holovaty	"I was looking at method_save, and noticed it might not be the best way of doing it for mysql

in mysql you have got 2 features which might help out a bit.
{{{
REPLACE [LOW_PRIORITY | DELAYED]
    [INTO] tbl_name [(col_name,...)]
    VALUES ({expr | DEFAULT},...),(...),...
}}}
http://dev.mysql.com/doc/refman/5.0/en/replace.html

which will replace the record if it already exists

and 
{{{
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name [(col_name,...)]
    VALUES ({expr | DEFAULT},...),(...),...
    [ ON DUPLICATE KEY UPDATE col_name=expr, ... ]
}}}

http://dev.mysql.com/doc/refman/5.0/en/insert.html

with the ON DUPLICATE KEY UPDATE part allowing you to deal with a duplicate record.

using one of these might simplify the logic going on here, as well as possibly reducing the number of trips to the DB server.
"	defect	closed	Database layer (models, ORM)		normal	wontfix		dev@…	Unreviewed	0	0	0	0	0	0
