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.
This commit is contained in:
adustman
2000-03-24 05:47:17 +00:00
parent d4529e5d15
commit a57d4c439c

View File

@ -756,7 +756,18 @@ _mysql_ResultObject_fetch_row_as_dict(self, args)
Py_INCREF(Py_None);
v = Py_None;
}
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;