#601: ProgrammingError: column "product" specified more than onceLINE 1:
...tus,product,severity,keywords,cc,time,changetime, product) V...
^
---------------------------+--------------------
Reporter: ogaerick | Owner: nobody
Type: defect | Status: new
Priority: blocker | Milestone:
Component: multiproduct | Version: 0.6.0
Resolution: | Keywords:
---------------------------+--------------------
Comment (by olemis):
Below I explain the reason why I'm still getting the same error this side
.
Replying to [comment:5 rjollos]:
> When I create a ticket using the quick ticket form, the following SQL is
executed (`[trac] debug_sql = true`):
> {{{
> 04:32:59 AM Trac[dbcursor] DEBUG: SQL: INSERT INTO ticket
(summary,reporter,owner,description,type,status,priority,product,milestone,component,version,resolution,time,changetime,
product) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,'prod1')
> 04:32:59 AM Trac[util] DEBUG: SQL: INSERT INTO ticket
(summary,reporter,owner,description,type,status,priority,product,milestone,component,version,resolution,time,changetime,
product) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,'prod1')
> }}}
>
> The duplication of the `product` field, caused by the addition of the
`product` select in #569, doesn't seem to cause a problem with SQLite, but
I'll attempt to reproduce with PostgreSQL.
>
> I'm not seeing a duplication of the `product` field for tickets created
from the `/newticket` URL (i.e. the full new ticket form):
> {{{
> 03:46:38 AM Trac[dbcursor] DEBUG: Original SQl: INSERT INTO ticket
(summary,reporter,owner,descriobserving this
issueption,type,status,priority,milestone,component,version,keywords,cc,time,changetime)
VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
> 03:46:38 AM Trac[dbcursor] DEBUG: SQL: INSERT INTO ticket
(summary,reporter,owner,description,type,status,priority,milestone,component,version,keywords,cc,time,changetime,
product) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,'@')
> }}}
>
Unfortunately `INSERT` statements are not logged in my instance . I can
only see lines for `SELECT` statements . I'd appreciate if you share any
ideas .
> The latter finding isn't too surprising since there shouldn't be a
product select field within the `#inplace-propertyform` form. The product
select should only exist on the breadcrumb. Do you see a product select
field in the new ticket form when on the `/newticket` page?
As far as I can tell it always inserts product field twice my side . I
reproduced the sequence of invocations leading to the error in
`trac.ticket.model.Ticket` and this is what I get
{{{#!py
>>> from trac.env import open_environment as oe
>>> genv = oe('/path/to/blood-hound.net')
>>> from multiproduct.env import ProductEnvironment as PE
>>> penv = PE(genv, 'dataviz')
>>> from multiproduct.dbcursor import translate_sql
# Headless test mode ;)
>>> sql = translate_sql(penv, "INSERT INTO ticket (summary, product)
VALUES ('S', 'swlcu')")
>>> sql
u"INSERT INTO ticket (summary, product, product) VALUES ('S',
'swlcu','dataviz')"
>>> from trac.ticket.model import Ticket
>>> t = Ticket(penv)
>>> self = t
# Copy and paste lines 226-235 in trac/ticket/model.py
>>> if True:
... std_fields = []
... custom_fields = []
... for f in self.fields:
... fname = f['name']
... if fname in self.values:
... if f.get('custom'):
... custom_fields.append(fname)
... else:
... std_fields.append(fname)
...
# The query in lines 238-241
>>> orig = ("INSERT INTO ticket (%s) VALUES (%s)"
... % (','.join(std_fields),
... ','.join(['%s'] * len(std_fields))))
>>> orig
'INSERT INTO ticket (owner,type,priority,product,version) VALUES
(%s,%s,%s,%s,%s)'
>>> sql = translate_sql(penv, orig)
>>> sql
u"INSERT INTO ticket (owner,type,priority,product,version, product) VALUES
(%s,%s,%s,%s,%s,'dataviz')"
}}}
`product` appears twice because
1. it is included in `std_fields` via ITicketFieldsProvider
2. and appended once again after translation
All this happens using PostgreSQL backend .
--
Ticket URL: <https://issues.apache.org/bloodhound/ticket/601#comment:9>
Apache Bloodhound <https://issues.apache.org/bloodhound/>
The Apache Bloodhound issue tracker