Code Monkey home page Code Monkey logo

Comments (1)

Aeon avatar Aeon commented on June 18, 2024

On 16-Apr-2010, at 11:21am, scott wrote (Trac issue 1504#comment:1):

I ran into this as well.

The problem is that currval of a sequence id is a a session-local value. It cannot be retrieved unless nextval has been called for the current session.

I fixed this by modifying:
/usr/lib/python2.6/dist-packages/trac/db/postgres_backend.py

to call setval, max(id) first to update the sequence value for the session

+++ /usr/lib/python2.6/dist-packages/trac/db/postgres_backend.py
@@ -215,5 +215,6 @@
         return _like_escape_re.sub(r'/\1', text)
 
     def get_last_id(self, cursor, table, column='id'):
+ cursor.execute("SELECT SETVAL('%s_%s_seq', max(%s)) FROM %s" % (table, column,column,table))
         cursor.execute("SELECT CURRVAL('%s_%s_seq')" % (table, column))
         return cursor.fetchone()[0] 

from mantis2trac.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.