Tryton - Issues

 

Message40676

Author risto3
Recipients Timitos, ced
Date 2018-05-13.14:10:16
Content
In persuing the latter, I'm testing this code:
        if not reconcile_date_exist:
            cursor.execute(
                *sql_table.update(
                    [sql_table.reconcile_date],
                    line.join(
                        move,
                        condition=move.id == line.move
                        ).join(
                        company,
                        condition=company.id == move.company
                        ).select(
                        Cast(
                            AtTimeZone(
                                AtTimeZone(sql_table.create_date, 'UTC'),
                                company.timezone),
                            'date'),
                        where=line.reconciliation == sql_table.id,
                        group_by=company.timezone)))

with the following added just prior:
        Company = pool.get('company.company')
        company = Company.__table__()

which generates the following:
'UPDATE "account_move_reconciliation" SET "reconcile_date" = (SELECT                                                                                                      
CAST("account_move_reconciliation"."create_date" AT TIME ZONE %s AT TIME ZONE %s AS date) FROM                                                                            
"account_move_line" AS "b" INNER JOIN "account_move" AS "c" ON ("c"."id" = "b"."move") INNER JOIN                                                                         
"company_company" AS "d" ON ("d"."id" = "c"."company") WHERE ("b"."reconciliation" =                                                                                      
"account_move_reconciliation"."id") GROUP BY "d"."timezone")'
where args:
>>> args                                                                                                                                                                  
('UTC', <sql.Column object at 0x7f1603483e80>)                                                                                                                            
>>> str(args[1])                                                                                                                                                          
'"timezone"'                                                                                                                                                              

I get the following exception:
...
File "/tmp/trytond-test/trytond/backend/postgresql/database.py", line 61, in execute 
  cursor.execute(self, sql, args)
psycopg2.ProgrammingError: can't adapt type 'Column'                                                                          │                     
But I if I execute the generated SQL directly in psql after creating the column and manually
replacing the parameters, it seems to work just fine.

Is there something esoteric I'm missing or is this perhaps an anomalie in the database layers?
History
Date User Action Args
2018-05-13 14:10:17risto3setmessageid: <1526213417.33.0.651916163286.issue7407@tryton.org>
2018-05-13 14:10:17risto3setrecipients: + ced, Timitos
2018-05-13 14:10:17risto3linkissue7407 messages
2018-05-13 14:10:16risto3create

Showing 10 items. Show all history (warning: this could be VERY long)