From a57d4c439c61bd5c8af5ff837b5e15a21e92900c Mon Sep 17 00:00:00 2001 From: adustman Date: Fri, 24 Mar 2000 05:47:17 +0000 Subject: [PATCH] Make keys for rows returned as dictionary unique by using "table.column" instead of "column" when there are two columns in the result set with the same name. --- mysql/_mysqlmodule.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mysql/_mysqlmodule.c b/mysql/_mysqlmodule.c index ff6a184..0ae305e 100644 --- a/mysql/_mysqlmodule.c +++ b/mysql/_mysqlmodule.c @@ -756,7 +756,18 @@ _mysql_ResultObject_fetch_row_as_dict(self, args) Py_INCREF(Py_None); v = Py_None; } - PyMapping_SetItemString(r, fields[i].name, v); + if (!PyMapping_HasKeyString(r, fields[i].name)) { + PyMapping_SetItemString(r, fields[i].name, v); + } else { + int len; + char buf[256]; + strncpy(buf, fields[i].table, 256); + len = strlen(buf); + strncat(buf, ".", 256-len); + len = strlen(buf); + strncat(buf, fields[i].name, 256-len); + PyMapping_SetItemString(r, buf, v); + } Py_DECREF(v); } return r;