Commit 660203c8 authored by Yusei Tahara's avatar Yusei Tahara

Use order by and limit in inner query.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19799 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d89a815b
......@@ -635,15 +635,17 @@ destination_section_where_expression</string> </value>
<dtml-elif count>\n
SELECT COUNT(DISTINCT uid) AS count FROM (\n
<dtml-else>\n
SELECT catalog.*,\n
SELECT main.*,\n
<dtml-let portal="portal_url.getPortalObject()"\n
substring_position="len(\'/\'.join(portal.getPhysicalPath()))+1"\n
portal_absolute_url="portal.absolute_url(relative=1)">\n
( SELECT CONCAT(<dtml-sqlvar portal_absolute_url type=string>, SUBSTRING(path, <dtml-var substring_position>)) FROM catalog as mirror_catalog WHERE mirror_catalog.uid=catalog.delivery_mirror_section_uid ) AS delivery_mirror_section_url,\n
( SELECT CONCAT(<dtml-sqlvar portal_absolute_url type=string>, SUBSTRING(path, <dtml-var substring_position>)) FROM catalog as mirror_catalog WHERE mirror_catalog.uid=main.delivery_mirror_section_uid ) AS delivery_mirror_section_url,\n
</dtml-let>\n
( SELECT title FROM catalog as mirror_catalog WHERE mirror_catalog.uid=catalog.delivery_mirror_section_uid ) AS delivery_mirror_section_title,\n
( SELECT IFNULL(SUM(stock.total_price), 0) FROM stock, catalog AS child WHERE child.uid = stock.uid AND child.parent_uid = catalog.uid AND stock.section_uid=catalog.category_uid AND stock.total_price > 0 AND <dtml-sqltest accounting_movement_list type=string column=child.portal_type op=eq multiple>) AS debit,\n
( SELECT IFNULL(-SUM(stock.total_price), 0) FROM stock, catalog AS child WHERE child.uid = stock.uid AND child.parent_uid = catalog.uid AND stock.section_uid=catalog.category_uid AND stock.total_price < 0 AND <dtml-sqltest accounting_movement_list type=string column=child.portal_type op=eq multiple>) AS credit\n
( SELECT title FROM catalog as mirror_catalog WHERE mirror_catalog.uid=main.delivery_mirror_section_uid ) AS delivery_mirror_section_title,\n
( SELECT IFNULL(SUM(stock.total_price), 0) FROM stock, catalog AS child WHERE child.uid = stock.uid AND child.parent_uid = main.uid AND stock.section_uid=main.category_uid AND stock.total_price > 0 AND <dtml-sqltest accounting_movement_list type=string column=child.portal_type op=eq multiple>) AS debit,\n
( SELECT IFNULL(-SUM(stock.total_price), 0) FROM stock, catalog AS child WHERE child.uid = stock.uid AND child.parent_uid = main.uid AND stock.section_uid=main.category_uid AND stock.total_price < 0 AND <dtml-sqltest accounting_movement_list type=string column=child.portal_type op=eq multiple>) AS credit\n
FROM (\n
SELECT *\n
FROM (\n
</dtml-if>\n
\n
......@@ -1047,6 +1049,7 @@ UNION\n
<dtml-else>\n
<dtml-unless no_limit>LIMIT 1000</dtml-unless>\n
</dtml-if>\n
) as main\n
</dtml-if>\n
\n
</dtml-if>\n
......@@ -1296,15 +1299,17 @@ UNION\n
<dtml-elif count>\n
SELECT COUNT(DISTINCT uid) AS count FROM (\n
<dtml-else>\n
SELECT catalog.*,\n
SELECT main.*,\n
<dtml-let portal="portal_url.getPortalObject()"\n
substring_position="len(\'/\'.join(portal.getPhysicalPath()))+1"\n
portal_absolute_url="portal.absolute_url(relative=1)">\n
( SELECT CONCAT(<dtml-sqlvar portal_absolute_url type=string>, SUBSTRING(path, <dtml-var substring_position>)) FROM catalog as mirror_catalog WHERE mirror_catalog.uid=catalog.delivery_mirror_section_uid ) AS delivery_mirror_section_url,\n
( SELECT CONCAT(<dtml-sqlvar portal_absolute_url type=string>, SUBSTRING(path, <dtml-var substring_position>)) FROM catalog as mirror_catalog WHERE mirror_catalog.uid=main.delivery_mirror_section_uid ) AS delivery_mirror_section_url,\n
</dtml-let>\n
( SELECT title FROM catalog as mirror_catalog WHERE mirror_catalog.uid=catalog.delivery_mirror_section_uid ) AS delivery_mirror_section_title,\n
( SELECT IFNULL(SUM(stock.total_price), 0) FROM stock, catalog AS child WHERE child.uid = stock.uid AND child.parent_uid = catalog.uid AND stock.section_uid=catalog.category_uid AND stock.total_price > 0 AND <dtml-sqltest accounting_movement_list type=string column=child.portal_type op=eq multiple>) AS debit,\n
( SELECT IFNULL(-SUM(stock.total_price), 0) FROM stock, catalog AS child WHERE child.uid = stock.uid AND child.parent_uid = catalog.uid AND stock.section_uid=catalog.category_uid AND stock.total_price < 0 AND <dtml-sqltest accounting_movement_list type=string column=child.portal_type op=eq multiple>) AS credit\n
( SELECT title FROM catalog as mirror_catalog WHERE mirror_catalog.uid=main.delivery_mirror_section_uid ) AS delivery_mirror_section_title,\n
( SELECT IFNULL(SUM(stock.total_price), 0) FROM stock, catalog AS child WHERE child.uid = stock.uid AND child.parent_uid = main.uid AND stock.section_uid=main.category_uid AND stock.total_price > 0 AND <dtml-sqltest accounting_movement_list type=string column=child.portal_type op=eq multiple>) AS debit,\n
( SELECT IFNULL(-SUM(stock.total_price), 0) FROM stock, catalog AS child WHERE child.uid = stock.uid AND child.parent_uid = main.uid AND stock.section_uid=main.category_uid AND stock.total_price < 0 AND <dtml-sqltest accounting_movement_list type=string column=child.portal_type op=eq multiple>) AS credit\n
FROM (\n
SELECT *\n
FROM (\n
</dtml-if>\n
\n
......@@ -1708,6 +1713,7 @@ UNION\n
<dtml-else>\n
<dtml-unless no_limit>LIMIT 1000</dtml-unless>\n
</dtml-if>\n
) as main\n
</dtml-if>\n
\n
</dtml-if>\n
......
637
\ No newline at end of file
639
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment