Hacker News new | ask | show | jobs
by Olap84 3682 days ago
So given your rant, does any ORM cater for this condition better?

Does any web framework manage these? Given two almost identical requests that cause a race condition most frameworks fall down in my experience.

1 comments

There are some ORM's where you define the schema in the application code and it alters the DB schema on the fly, but that seems dangerous, too.

What I would do, given Rails' existing framework of "programmatically discover the table schema and magically generate logic from it", is set it up so that it observes uniqueness constraints and programmatically adds the validation when found. Also, the adapters should interpret server error messages, throw a custom exception class for "uniqueness constraint failed", and ActiveRecord should catch this exception class and turn it into a failed validation when you attempt to save a record.

If that's too much work, just be fucking honest, remove the uniqueness validation (because it's completely useless), and be upfront with us that we have to roll our own solution for it.