idlesign/django-firebird

Uncertain primary key of the last inseted row

Closed this issue · 3 comments

I have written an issue and the patch in the original branch. It is significant also for Django 1.2.

http://code.google.com/p/django-firebird/issues/detail?id=13

  • fixed: uncertain primary key of the last inserted row. Closed by 85c1671.
  • fixed: server version resolver

You wrote comment: base.py: line 172
def last_insert_id(self, cursor, table_name, pk_name):
# This method is unreliable, but nothing else could be done in Firebird prior 2

No. The module with such commnent looks very untrustworthy now. It is not obvious, that this is only fallback method for old Firebird.

I think, it would be better to be more particular about the unreliability:
# Fallback method for Firebird version prior 2.
# This is unreliable if two processes insert at the same time, but the exact
# method for old Firebird version according to http://firebirdfaq.org/faq243/
# is not worth of effort.

(It would require some string manipulation with prepared SQL in Django and temporary saving the value at nonstandard place. The code with both the new and an old fallback fallback exact solution would be less readible.)

The module with such commnent looks very untrustworthy now.

Um, I prefer to think that those comments are for developers. There is reasonably small amount of end users looking under the hood.
That's not as I'm saying that this backend is ready for the end users :)

Anyway, thanks for the notice.