Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 41 additions & 23 deletions MySQLdb/_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -1237,19 +1237,35 @@ _mysql_row_to_dict(
c = PyTuple_GET_ITEM(self->converter, i);
v = _mysql_field_to_python(c, row[i], length[i], &fields[i], self->encoding);
if (!v) goto error;
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);

PyObject *pyname = PyUnicode_FromString(fields[i].name);
if (pyname == NULL) {
Py_DECREF(v);
goto error;
}

PyObject *tmp = PyDict_SetDefault(r, pyname, v);
Py_DECREF(pyname);
if (!tmp) {
Py_DECREF(v);
goto error;
}
if (tmp == v) {
Py_DECREF(v);
continue;
}

pyname = PyUnicode_FromFormat("%s.%s", fields[i].table, fields[i].name);
if (!pyname) {
Py_DECREF(v);
goto error;
}
int err = PyDict_SetItem(r, pyname, v);
Py_DECREF(pyname);
Py_DECREF(v);
if (err) {
goto error;
}
}
return r;
error:
Expand All @@ -1275,20 +1291,22 @@ _mysql_row_to_dict_old(
PyObject *v;
c = PyTuple_GET_ITEM(self->converter, i);
v = _mysql_field_to_python(c, row[i], length[i], &fields[i], self->encoding);
if (!v) goto error;
{
int len=0;
char buf[256]="";
if (strlen(fields[i].table)) {
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);
if (!v) {
goto error;
}

PyObject *pyname;
if (strlen(fields[i].table)) {
pyname = PyUnicode_FromFormat("%s.%s", fields[i].table, fields[i].name);
} else {
pyname = PyUnicode_FromString(fields[i].name);
}
int err = PyDict_SetItem(r, pyname, v);
Py_DECREF(pyname);
Py_DECREF(v);
if (err) {
goto error;
}
}
return r;
error:
Expand Down
2 changes: 0 additions & 2 deletions setup_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def get_config():
libraries = ["kernel32", "advapi32", "wsock32", client]
include_dirs = [os.path.join(connector, r"include")]

extra_compile_args = ["/Zl", "/D_CRT_SECURE_NO_WARNINGS"]
extra_link_args = ["/MANIFEST"]

name = "mysqlclient"
Expand All @@ -53,7 +52,6 @@ def get_config():
ext_options = dict(
library_dirs=library_dirs,
libraries=libraries,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
include_dirs=include_dirs,
extra_objects=extra_objects,
Expand Down