58 | | cursor.execute("SELECT CURRVAL('\"%s_%s_seq\"')" % (table_name, pk_name)) |
| 58 | # This is tricky. It's possible for len(seq_guts) to be exactly 59. |
| 59 | # That's not too long, and Postgres doesn't clip it. But, if the |
| 60 | # tablename is 28, and the pk_name is 30, (plus the '_'), then |
| 61 | # unconditionally clipping both parts to 29 removes an extra char, |
| 62 | # and we get a wrong answer. |
| 63 | seq_guts = '%s_%s' % (table_name,pk_name) |
| 64 | if len(seq_guts) > 59: |
| 65 | seq_guts = "%s_%s" % (table_name[:29], pk_name[:29]) |
| 66 | cursor.execute("SELECT CURRVAL('\"%s_seq\"')" % (seq_guts)) |