Changeset 2289
- Timestamp:
- 02/07/06 12:47:32 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/django/db/models/fields/related.py
r2287 r2289 124 124 new_ids = set([obj._get_pk_val() for obj in objs]) 125 125 cursor = connection.cursor() 126 rowcount =cursor.execute("SELECT %s FROM %s WHERE %s = %%s AND %s IN (%s)" % \126 cursor.execute("SELECT %s FROM %s WHERE %s = %%s AND %s IN (%s)" % \ 127 127 (rel_col_name, join_table, this_col_name, 128 128 rel_col_name, ",".join(['%s'] * len(new_ids))), 129 129 [this_pk_val] + list(new_ids)) 130 existing_ids = set([row[0] for row in cursor.fetchmany(rowcount)]) 130 if cursor.rowcount is not None and cursor.rowcount > 0: 131 existing_ids = set([row[0] for row in cursor.fetchmany(cursor.rowcount)]) 132 else: 133 existing_ids = set() 131 134 132 135 # Add the ones that aren't there already django/branches/magic-removal/tests/modeltests/many_to_many/models.py
r2275 r2289 43 43 >>> a2.save() 44 44 >>> a2.publications.add(p1, p2) 45 >>> a2.publications.add(p3) 46 47 # Adding a second time is OK 45 48 >>> a2.publications.add(p3) 46 49
