New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update sequence when inserting record with fixed id? #1761
Comments
25th Nov 2010, porkaria said: ow Juan da uma força aí hahaha =[ |
26th Nov 2010, Jose Lorenzo Rodríguez said: Please do not assign ticket to anyone in particular |
24th Jun 2011, Mark Story said: I don't think we'll be able to address sequences or modify all of the testsuite to not use specific id's as that makes defining joins in the fixtures almost impossible. Moving to Future, as its a hardish problem, that could rely on api changes. |
7th Oct 2011, Brad Koch said: I'm running into this issue in the test case scenario Dieter mentioned. The best workaround I've found is to make the IDs of any explicitly declared records sufficiently high enough so that you don't have collisions, thus allowing you to be certain of what the IDs are without causing errors. Dealing with out of sync sequences is just difficult in general.. |
7th Oct 2011, Jose Lorenzo Rodríguez said: Another workaround it to not declare the id value in the fixture records, that way they will always start with 1. We could use a patch and a testcase if you feel like you're able to finally kill this bug :) I guess I could try to do it too later after 2.0 is out. |
7th Oct 2011, Brad Koch said: Well, there's a couple questions to answer before deciding to write a patch. It's the postgres autoincrementation methodology that has the flaw, not cake. The issue obviously occurs when id values are inserted that exceed the sequence value. The only framework level fixes are to either: The question that needs to be answered first is whether it's the framework's role to take on this responsibility. If the framework does pick up this responsibility, we'd be adding a bit of overhead to every query. If not, it's just something Postgres users need to be aware of and work around by not ever explicitly declaring ids. |
7th Oct 2011, Jose Lorenzo Rodríguez said: Yeah, you are right. The framework is just sticking to what postgres expects It should not be hard to write such trigger, and could be offered as part of |
25th Oct 2011, Brad Koch said: FYI, I'm working on a trigger as my time allows. Just need to work out a couple issues and run it by some other postgres people first. I'll post it when I've got something to share. |
Created by Dieter Plaetinck, 15th Apr 2010. (originally Lighthouse ticket #584):
when using sequences on a database that supports it (eg postgresql) (or serial columnt type).
if you:
ALTER SEQUENCE .. RESTART WITH 1
queries)$Model->save()
), the primary key will we duplicate and violate the unique constraint, because it uses the nextval (which is 1)I'm not sure what the recommended approach should be.
The text was updated successfully, but these errors were encountered: