When using the RealDictCursor from psycopg2 extras, is the behavior of RealDictCursor well defined for the case where you have repeated column names (such as in a join)? That is, obviously a dictionary can only have one value for a key, so is it safe to assume that the value for the column name key in the case of repeated column names is always going to be the one that appears LAST in the query?
Not at all: the result is at best an error, at worse an undefined behaviour. Even if at the moment the result appears consistent we may change the implementation in the future.
Do specify explicit names for the columns, and never use `select *` in production, which may result in accidental duplications (maybe not now, but in the future, when you add an apparently unrelated field to a table and grep can't help you).