the absense of which was preventing the new
GAE dialect from being loaded. [ticket:2529]
+ - [bug] Fixed cextension bug whereby the
+ "ambiguous column error" would fail to
+ function properly if the given index were
+ a Column object and not a string.
+ Note there are still some column-targeting
+ issues here which are fixed in 0.8.
+ [ticket:2553]
+
- [bug] Fixed the repr() of Enum to include
the "name" and "native_enum" flags. Helps
Alembic autogenerate.
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
typedef Py_ssize_t (*lenfunc)(PyObject *);
-#define PyInt_FromSsize_t(x) PyInt_FromLong(x)
-typedef intargfunc ssizeargfunc;
+#define PyInt_FromSsize_t(x) PyInt_FromLong(x)
+typedef intargfunc ssizeargfunc;
#endif
PyObject *processors, *values;
PyObject *processor, *value, *processed_value;
PyObject *row, *record, *result, *indexobject;
- PyObject *exc_module, *exception;
+ PyObject *exc_module, *exception, *cstr_obj;
char *cstr_key;
long index;
int key_fallback = 0;
int tuple_check = 0;
-
+
if (PyInt_CheckExact(key)) {
index = PyInt_AS_LONG(key);
} else if (PyLong_CheckExact(key)) {
if (exception == NULL)
return NULL;
- cstr_key = PyString_AsString(key);
- if (cstr_key == NULL)
+ // wow. this seems quite excessive.
+ cstr_obj = PyObject_Str(key);
+ if (cstr_obj == NULL)
+ return NULL;
+ cstr_key = PyString_AsString(cstr_obj);
+ if (cstr_key == NULL) {
+ Py_DECREF(cstr_obj);
return NULL;
+ }
+ Py_DECREF(cstr_obj);
PyErr_Format(exception,
"Ambiguous column name '%.200s' in result set! "
value = PySequence_GetItem(row, index);
tuple_check = 0;
}
-
+
if (value == NULL)
return NULL;
tmp = BaseRowProxy_subscript(self, name);
if (tmp == NULL && PyErr_ExceptionMatches(PyExc_KeyError)) {
PyErr_Format(
- PyExc_AttributeError,
+ PyExc_AttributeError,
"Could not locate column in row for column '%.200s'",
PyString_AsString(name)
);
lambda: r['user_id']
)
+ def test_ambiguous_column_by_col(self):
+ users.insert().execute(user_id=1, user_name='john')
+ ua = users.alias()
+ u2 = users.alias()
+ result = select([users.c.user_id, ua.c.user_id]).execute()
+ row = result.first()
+
+ assert_raises_message(
+ exc.InvalidRequestError,
+ "Ambiguous column name",
+ lambda: row[users.c.user_id]
+ )
+
+ # this is a bug, should be ambiguous.
+ # Fixed in 0.8
+ eq_(row[ua.c.user_id], 1)
+
+ # this is also a less severe bug - u2.c.user_id
+ # is not in the row at all so is not actually
+ # ambiguous. Still is like this in 0.8
+ # and is due to overly liberal "this is a derived column"
+ # rules.
+ assert_raises_message(
+ exc.InvalidRequestError,
+ "Ambiguous column name",
+ lambda: row[u2.c.user_id]
+ )
+
@testing.requires.subqueries
def test_column_label_targeting(self):
users.insert().execute(user_id=7, user_name='ed')