Discussion:
[Erp5-dev] using ComplexQuery and choosing proper tables
Łukasz Nowak
2008-11-04 15:52:27 UTC
Permalink
Hello,

Take a look at this snippet:

kw = {}
from Products.ZSQLCatalog.SQLCatalog import Query,ComplexQuery
query = ComplexQuery(
Query(**{'movement.start_date' : '>=2008/10/10'}),
Query(**{'movement.start_date' : '<=2008/10/10'}),
)
kw.update(**query.asSQLExpression())
context.portal_catalog(**kw)

It raises error:

Error Type: OperationalError
Error Value: (1054, "Unknown column 'movement.start_date' in 'where
clause': SELECT DISTINCT\n catalog.path, catalog.uid \nFROM\n catalog AS
catalog \nWHERE \n 1 = 1 \n AND (((catalog.security_uid IN (4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 61, 62,
63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79)) OR
(((((((catalog.viewable_owner = 'ERP5TypeTestCase'))))))))) AND (1) AND
(((((((movement.start_date >= '2008/10/10'))))) AND
(((((movement.start_date <= '2008/10/10')))))))\nLIMIT 1000")

I've dig through SQLCatalog product code, but I wasn't able to convince
portal_catalog to use movement table too in its query. Passing
from_table_list = 'movement' didn't help me.

Question: How to force portal_catalog to use more tables using
Query/ComplexQuery features?

Regards,
Luke
--
?ukasz Nowak IT Specialist email at lnowak.com http://lnowak.com/
Skype: Shufla jid: shufla at jabster.pl
``Use the Source, Luke...''
Romain Courteaud
2008-11-04 16:26:28 UTC
Permalink
Post by Łukasz Nowak
Hello,
Hello,
Post by Łukasz Nowak
kw = {}
from Products.ZSQLCatalog.SQLCatalog import Query,ComplexQuery
query = ComplexQuery(
Query(**{'movement.start_date' : '>=2008/10/10'}),
Query(**{'movement.start_date' : '<=2008/10/10'}),
)
kw.update(**query.asSQLExpression())
context.portal_catalog(**kw)
Did you try ?

context.portal_catalog(query=query)
Post by Łukasz Nowak
Error Type: OperationalError
Error Value: (1054, "Unknown column 'movement.start_date' in 'where
clause': SELECT DISTINCT\n catalog.path, catalog.uid \nFROM\n catalog AS
catalog \nWHERE \n 1 = 1 \n AND (((catalog.security_uid IN (4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 61, 62,
63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79)) OR
(((((((catalog.viewable_owner = 'ERP5TypeTestCase'))))))))) AND (1) AND
(((((((movement.start_date >= '2008/10/10'))))) AND
(((((movement.start_date <= '2008/10/10')))))))\nLIMIT 1000")
I've dig through SQLCatalog product code, but I wasn't able to convince
portal_catalog to use movement table too in its query. Passing
from_table_list = 'movement' didn't help me.
Question: How to force portal_catalog to use more tables using
Query/ComplexQuery features?
Regards,
Luke
--
?ukasz Nowak IT Specialist email at lnowak.com http://lnowak.com/
Skype: Shufla jid: shufla at jabster.pl
``Use the Source, Luke...''
_______________________________________________
Erp5-dev mailing list
Erp5-dev at erp5.org
http://mail.nexedi.com/mailman/listinfo/erp5-dev
Łukasz Nowak
2008-11-05 08:27:19 UTC
Permalink
Hello
Post by Łukasz Nowak
Post by Łukasz Nowak
Hello,
Hello,
Post by Łukasz Nowak
kw = {}
from Products.ZSQLCatalog.SQLCatalog import Query,ComplexQuery
query = ComplexQuery(
Query(**{'movement.start_date' : '>=2008/10/10'}),
Query(**{'movement.start_date' : '<=2008/10/10'}),
)
kw.update(**query.asSQLExpression())
context.portal_catalog(**kw)
Did you try ?
context.portal_catalog(query=query)
No...Count to 5.

Yes! Phew - sometimes I do not see the simplest solution :) Thanks! :)

Regards,
Luke
--
?ukasz Nowak IT Specialist email at lnowak.com http://lnowak.com/
Skype: Shufla jid: shufla at jabster.pl
``Use the Source, Luke...''
Loading...