Modify

Opened 16 years ago

Closed 15 years ago

#3102 closed defect (fixed)

burndown_job.py fails INSERT NULL id

Reported by: anonymous Owned by: daan
Priority: normal Component: ScrumBurndownPlugin
Severity: critical Keywords: INSERT NULL id in burndown table
Cc: Benoit Grégoire Trac Release: 0.11

Description

According to the definition of the burndown table, the id field cannot be null. Yet if burndown_job.py is run with an empty table, it attempts to INSERT a NULL for the id.

--- EXAMPLE ERROR ----

# python burndown_job.py /home/trac/client first run of burndown_job.py today - insert needed Traceback (most recent call last):

File "burndown_job.py", line 82, in ?

main()

File "burndown_job.py", line 76, in main

cursor.execute("INSERT INTO burndown(id,component_name, milestone_name, date, hours_remaining) "\

File "/usr/lib/python2.4/site-packages/Trac-0.11b1-py2.4.egg/trac/db/util.py", line 51, in execute

return self.cursor.execute(sql)

File "/usr/lib/python2.4/site-packages/Trac-0.11b1-py2.4.egg/trac/db/util.py", line 51, in execute

return self.cursor.execute(sql)

File "/usr/lib/python2.4/site-packages/pyPgSQL/PgSQL.py", line 3111, in execute

raise OperationalError, msg

libpq.OperationalError: ERROR: null value in column "id" violates not-null constraint

--- END EXAMPLE ERROR ---

--- CODE REFERENCE ---

burndown.py:69

sqlBurndownCreate = "CREATE TABLE burndown (" \

" id integer PRIMARY KEY NOT NULL,"\ " component_name text NOT NULL,"\ " milestone_name text NOT NULL," \ " date text,"\ " week text,"\ " year text,"\ " hours_remaining integer NOT NULL"\ ")"

burndown_job.py:73

cursor.execute("INSERT INTO burndown(id,component_name, milestone_name, date, hours_remaining) "\

" VALUES(NULL,'%s','%s','%s',%f)" % (comp[0], mile[0], today, hours))

--- END CODE REFERENCE ---

Attachments (1)

patch_null_and_integer.svndiff (3.4 KB) - added by Benoit Grégoire 16 years ago.
Patch for #3102

Download all attachments as: .zip

Change History (9)

comment:1 Changed 16 years ago by anonymous

Possible Patch:

create sequence burndown_id_seq;
alter table burndown alter column id set default nextval('burndown_id_seq');


--- old/burndown/burndown_job.py        2006-10-16 12:20:46.000000000 -0700
+++ new/burndown/burndown_job.py        2008-05-29 13:05:57.000000000 -0700
@@ -73,8 +73,8 @@
                     cursor.execute("UPDATE burndown SET hours_remaining = '%f' WHERE date = '%s' AND milestone_name = '%s'"\
                                         "AND component_name = '%s'" % (hours, today, mile[0], comp[0]))
                 else:
-                    cursor.execute("INSERT INTO burndown(id,component_name, milestone_name, date, hours_remaining) "\
-                                        "    VALUES(NULL,'%s','%s','%s',%f)" % (comp[0], mile[0], today, hours))
+                    cursor.execute("INSERT INTO burndown(component_name, milestone_name, date, hours_remaining) "\
+                                        "    VALUES('%s','%s','%s',%f)" % (comp[0], mile[0], today, hours))

     db.commit()

comment:2 Changed 16 years ago by anonymous

The same error is in burndown.py line 330. The id field cannot be null. The fix is the same as above.

In the UPDATE, hours_remaining is an integer field in the database, but here it is being set to a floating point.

I used

alter table burndown alter column hours_remaining type numeric(4,2);

to change the database field so it would accept a floaing value.

comment:3 Changed 16 years ago by anonymous

Cc: Benoit Grégoire added; anonymous removed

Changed 16 years ago by Benoit Grégoire

Patch for #3102

comment:4 Changed 16 years ago by Benoit Grégoire

Severity: normalcritical

I attached a SVN diff fixing both problems. Note that I used float, and the numeric restricted to the range above caused problems. I didn't test schema upgrade, only creation.

comment:5 Changed 16 years ago by daan

Owner: changed from Sam Bloomquist to daan

comment:6 Changed 15 years ago by daan

Which database is used? Is this tested for MySQL?

comment:7 Changed 15 years ago by Benoit Grégoire

I tested on postgres

comment:8 Changed 15 years ago by daan

Resolution: fixed
Status: newclosed

(In [5058]) Release of version 1.9.1 of the Trac Scrum burndown plugin. See http://stuq.nl/weblog/2008-12-25/scrum-burndown-plugin-191-released for more information.

A new version of the Scrum Burndown plugin for Trac is released, bringing compatibility for PostgreSQL, MySQL, Trac 0.11.2.1, and many bug fixes. Upgrading is recommended.

New features The Scrum burndown plugin is currently compatible and tested with Trac 0.10.5, Trac 0.11.1, Trac 0.11.2.1 Python 2.4 and Python 2.5. Additional to the previous SQLite compatibility, support for both PostgreSQL 8.3 and MySQL 5 has been added.

The following issues are fixed:

  • Fixes #1462 better control of milestone: a way to ‘reset’ a milestone
  • Fixes #1217 database upgrade fails after installing latest scrumburndownplugin
  • Fixes #2476 Error: ‘line_graph’ is undefined - stop graph from displaying
  • Fixes #1730 couldn’t upgrade
  • Fixes #2729 Error while running under PostgreSQL
  • Fixes #3102 burndown_job.py fails INSERT NULL id
  • Fixes #1909 Overshooting estimate reduces remaining effort while ticket is open
  • Fixes #1189 TracBurndown-01.05.10-py2.4.egg error
  • Fixes #1800 No chart when clicking Burndown chart button.
  • Fixes #4047 AttributeError: ‘NoneType’ object has no attribute ‘getValue’
  • Fixes #2224 Changing ticket component causes removal from burndown
  • Fixes #2562 Creating a new component breaks the burndown graphic for “All Components”
  • Fixes #4222 Install fails on mysql
  • Fixes #2218 ScrumBurndownPlugin, trac 0.10.4, mysql

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain daan.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.