Ticket #2658 (new defect)

Opened 8 months ago

Last modified 1 week ago

Type Casts in Postgresl 8.3

Reported by: victorhg@gmail.com Assigned to: coderanger
Priority: highest Component: MasterTicketsPlugin
Severity: blocker Keywords:
Cc: shanec@activestate.com, nulleke76@gmail.com, dag.viggo@lokoen.org, carlos@boreste.us, bernd.tegge@hereschwerke.com, kmacinni@hotmail.com, brad-trachacks@fewerhassles.com Trac Release: 0.11

Description

Hello,

I've been trying to use the MasterTicketsPlugin with postgresql 8.3. There are some issues with type checking (PSQGL has a strong type checking mechanism):

model.py

cursor.execute('SELECT dest FROM mastertickets WHERE source=%s ORDER BY dest', (self.tkt.id,))

should be

cursor.execute('SELECT dest FROM mastertickets WHERE source='%s' ORDER BY dest', (self.tkt.id,))

Am i right?? I'm receiveing the psql error:

2008-02-29 11:38:17 BRT HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
2008-02-29 11:38:17 BRT COMMAND:  SELECT dest FROM mastertickets WHERE source=1 ORDER BY dest

The TracInstall comes with the follwing alert, related with the problem described above:
Warning: PostgreSQL 8.3 uses a strict type checking mechanism. To use Trac with the 8.3 Version of PostgreSQL, you will need trac-0.11 or later.

thanks

Attachments

model.py.diff (1.1 kB) - added by anonymous on 09/04/08 04:24:34.
fix
model.py.2.diff (1.1 kB) - added by anonymous on 09/04/08 04:24:45.
fix
model.py.unified.diff (2.4 kB) - added by brad-trachacks@fewerhassles.com on 09/05/08 10:45:35.
Same change model.py.diff but as unified diff.
pg-mastertickets-types.patch (0.5 kB) - added by mixedpuppy on 10/02/08 19:31:47.
fix table creation to deal with strict types for postgres

Change History

02/29/08 08:50:32 changed by victorhg@gmail.com

  • release changed from 0.10 to 0.11.

sorr

03/04/08 15:23:34 changed by anonymous

  • cc set to nulleke76@gmail.com.

07/14/08 06:55:48 changed by dag.viggo@lokoen.org

  • cc changed from nulleke76@gmail.com to nulleke76@gmail.com, dag.viggo@lokoen.org.

07/16/08 15:33:41 changed by anonymous

  • cc changed from nulleke76@gmail.com, dag.viggo@lokoen.org to nulleke76@gmail.com, dag.viggo@lokoen.org, carlos@boreste.us.

07/24/08 09:03:05 changed by anonymous

  • cc changed from nulleke76@gmail.com, dag.viggo@lokoen.org, carlos@boreste.us to nulleke76@gmail.com, dag.viggo@lokoen.org, carlos@boreste.us, bernd.tegge@hereschwerke.com.

08/22/08 18:42:43 changed by anonymous

  • cc changed from nulleke76@gmail.com, dag.viggo@lokoen.org, carlos@boreste.us, bernd.tegge@hereschwerke.com to nulleke76@gmail.com, dag.viggo@lokoen.org, carlos@boreste.us, bernd.tegge@hereschwerke.com, kmacinni@hotmail.com.

09/04/08 04:24:34 changed by anonymous

  • attachment model.py.diff added.

fix

09/04/08 04:24:45 changed by anonymous

  • attachment model.py.2.diff added.

fix

09/04/08 04:25:53 changed by apatrushev@gmail.com

diff -r /tmp/masterticketsplugin/0.11/mastertickets/model.py mastertickets/model.py
22c22
<         cursor.execute('SELECT dest FROM mastertickets WHERE source=%s ORDER BY dest', (self.tkt.id,))
---
>         cursor.execute('SELECT dest FROM mastertickets WHERE source=%s ORDER BY dest', (str(self.tkt.id),))
26c26
<         cursor.execute('SELECT source FROM mastertickets WHERE dest=%s ORDER BY source', (self.tkt.id,))
---
>         cursor.execute('SELECT source FROM mastertickets WHERE dest=%s ORDER BY source', (str(self.tkt.id),))
53c53
<                     cursor.execute('INSERT INTO mastertickets (%s, %s) VALUES (%%s, %%s)'%sourcedest, (self.tkt.id, n))
---
>                     cursor.execute('INSERT INTO mastertickets (%s, %s) VALUES (%%s, %%s)'%sourcedest, (str(self.tkt.id), str(n)))
57c57
<                     cursor.execute('DELETE FROM mastertickets WHERE %s=%%s AND %s=%%s'%sourcedest, (self.tkt.id, n))
---
>                     cursor.execute('DELETE FROM mastertickets WHERE %s=%%s AND %s=%%s'%sourcedest, (str(self.tkt.id), str(n)))
62c62
<                                    (n, field))
---
>                                    (n, str(field)))

09/05/08 10:45:35 changed by brad-trachacks@fewerhassles.com

  • attachment model.py.unified.diff added.

Same change model.py.diff but as unified diff.

09/05/08 10:49:18 changed by brad-trachacks@fewerhassles.com

  • cc changed from nulleke76@gmail.com, dag.viggo@lokoen.org, carlos@boreste.us, bernd.tegge@hereschwerke.com, kmacinni@hotmail.com to nulleke76@gmail.com, dag.viggo@lokoen.org, carlos@boreste.us, bernd.tegge@hereschwerke.com, kmacinni@hotmail.com, brad-trachacks@fewerhassles.com.

Just ran into the same problem and was able to fix it with the model.py.diff patch. (I have no idea if that's a good solution.)

The attached model.py.diff and model.py.2.diff files are identical:

5d543b1e2db100be8d4a382cf264da21  model.py.diff
5d543b1e2db100be8d4a382cf264da21  model.py.2.diff

FWIW, I attached a unified diff version.

09/29/08 16:07:02 changed by khym@azeotrope.org

Shouldn't that last chunk in the diff change n to str(n), rather than field to str(field)?

10/02/08 19:19:48 changed by mixedpuppy

  • cc changed from nulleke76@gmail.com, dag.viggo@lokoen.org, carlos@boreste.us, bernd.tegge@hereschwerke.com, kmacinni@hotmail.com, brad-trachacks@fewerhassles.com to shanec@activestate.com, nulleke76@gmail.com, dag.viggo@lokoen.org, carlos@boreste.us, bernd.tegge@hereschwerke.com, kmacinni@hotmail.com, brad-trachacks@fewerhassles.com.

since dest and source contain ticket id, why use a text field? wouldn't a simpler approach be to change the table to have integer fields?

10/02/08 19:31:47 changed by mixedpuppy

  • attachment pg-mastertickets-types.patch added.

fix table creation to deal with strict types for postgres


Add/Change #2658 (Type Casts in Postgresl 8.3)




Change Properties
Action