179 | | # TODO: This assumes the database supports subqueries. |
180 | | placeholders.append('(SELECT COUNT(*) FROM %s WHERE %s = %%s)' % \ |
181 | | (backend.quote_name(self._meta.db_table), backend.quote_name(self._meta.order_with_respect_to.column))) |
182 | | db_values.append(getattr(self, self._meta.order_with_respect_to.attname)) |
| 179 | if settings.DATABASE_ENGINE == 'mysql': |
| 180 | placeholders.append('%s') |
| 181 | subsel = 'SELECT COUNT(*) FROM %s WHERE %s = %%s' % ( |
| 182 | backend.quote_name(self._meta.db_table), |
| 183 | backend.quote_name(self._meta.order_with_respect_to.column)) |
| 184 | cursor.execute(subsel, (getattr(self, self._meta.order_with_respect_to.attname),)) |
| 185 | db_values.append(cursor.fetchone()[0]) |
| 186 | else: |
| 187 | # TODO: This assumes the database supports subqueries. |
| 188 | placeholders.append('(SELECT COUNT(*) FROM %s WHERE %s = %%s)' % \ |
| 189 | (backend.quote_name(self._meta.db_table), backend.quote_name(self._meta.order_with_respect_to.column))) |
| 190 | db_values.append(getattr(self, self._meta.order_with_respect_to.attname)) |