From 6f536d29e7282e9c9be35fde45b8a33f885bca9e Mon Sep 17 00:00:00 2001 From: Mika Bostrom Date: Thu, 24 Sep 2009 07:08:32 +0300 Subject: [PATCH] Fix import on PostgreSQL Database.py : fillDefaultData() Remove manual 'id' from INSERT command. In database schema, TourneyTypes.id is a primary key and thus autoincrement. In postgres, autoincrements are implemented as sequences - inserting a value "manually" bypasses the sequence generation, which resulted in a remarkably weird error. Namely, upon the first hand to import, the insert fails due to primary key violation. The default value from an unused sequence is 1, but a row with such an id already exists. The solution is to create the single row of default data values with unspecified TourneyTypes.id, hence allowing postgres to generate the correct id from the sequence. This way the import works again. --- pyfpdb/Database.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 9a22c472..22630fb6 100755 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -1012,9 +1012,9 @@ class Database: if self.backend == self.SQLITE: c.execute("INSERT INTO TourneyTypes (id, siteId, buyin, fee) VALUES (NULL, 1, 0, 0);") else: - c.execute("""insert into TourneyTypes(id, siteId, buyin, fee, maxSeats, knockout + c.execute("""insert into TourneyTypes(siteId, buyin, fee, maxSeats, knockout ,rebuyOrAddon, speed, headsUp, shootout, matrix) - values (1, 1, 0, 0, 0, False, False, null, False, False, False);""") + values (1, 0, 0, 0, False, False, null, False, False, False);""") #end def fillDefaultData