Issue 483: 'Invalid query' problem when use resource.updateItem(Package)DownloadedCount

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9642 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-10-13 14:43:23 +00:00
parent 9f9c6dd9be
commit bddb968dbf
5 changed files with 59 additions and 16 deletions

View file

@ -19,8 +19,12 @@
$this->name = $dbParser->parseColumnName($this->name); $this->name = $dbParser->parseColumnName($this->name);
if($column->attrs->var) if($column->attrs->var)
$this->argument = new QueryArgument($column); $this->argument = new QueryArgument($column);
else else {
$this->default_value = $dbParser->parseColumnName($column->attrs->default); $default_value = new DefaultValue($this->name, $column->attrs->default);
if($default_value->isOperation())
$this->argument = new QueryArgument($column);
else $this->default_value = $dbParser->parseColumnName($column->attrs->default);
}
} }
function getExpressionString(){ function getExpressionString(){

View file

@ -18,18 +18,32 @@
$args->use_mobile = ""; $args->use_mobile = "";
$args->site_srl = 0; $args->site_srl = 0;
$args->module_srl = 47374;'; $args->module_srl = 47374;';
$expected = 'UPDATE "xe_modules" as "modules" $expected = 'update "xe_modules" as "modules"
SET "module" = \'page\' set "module" = \'page\'
, "mid" = \'test\' , "module_category_srl" = 0
, "browser_title" = \'test\' , "layout_srl" = 0
, "description" = \'\' , "mid" = \'test\'
, "is_default" = \'N\' , "browser_title" = \'test\'
, "open_rss" = \'Y\' , "description" = \'\'
, "header_text" = \'\' , "is_default" = \'n\'
, "footer_text" = \'\' , "open_rss" = \'y\'
, "use_mobile" = \'n\' , "header_text" = \'\'
WHERE "site_srl" = 0 , "footer_text" = \'\'
AND "module_srl" = 47374'; , "mlayout_srl" = 0
, "use_mobile" = \'n\'
where "site_srl" = 0 and "module_srl" = 47374';
// $expected = 'UPDATE "xe_modules" as "modules"
// SET "module" = \'page\'
// , "mid" = \'test\'
// , "browser_title" = \'test\'
// , "description" = \'\'
// , "is_default" = \'N\'
// , "open_rss" = \'Y\'
// , "header_text" = \'\'
// , "footer_text" = \'\'
// , "use_mobile" = \'n\'
// WHERE "site_srl" = 0
// AND "module_srl" = 47374';
$this->_test($xml_file, $argsString, $expected); $this->_test($xml_file, $argsString, $expected);
} }
function test_member_updateLastLogin(){ function test_member_updateLastLogin(){
@ -52,7 +66,7 @@
$xml_file = _XE_PATH_ . "modules/counter/queries/updateCounterUnique.xml"; $xml_file = _XE_PATH_ . "modules/counter/queries/updateCounterUnique.xml";
$argsString = '$args->regdate = 20110607; $argsString = '$args->regdate = 20110607;
'; ';
$expected = 'UPDATE "xe_counter_status" SET "unique_visitor" = "unique_visitor" + 1, $expected = 'UPDATE "xe_counter_status" as "counter_status" SET "unique_visitor" = "unique_visitor" + 1,
"pageview" = "pageview" + 1 WHERE "regdate" = 20110607 '; "pageview" = "pageview" + 1 WHERE "regdate" = 20110607 ';
$this->_test($xml_file, $argsString, $expected); $this->_test($xml_file, $argsString, $expected);
} }

View file

@ -10,7 +10,7 @@
function test_counter_updateCounterUnique(){ function test_counter_updateCounterUnique(){
$xml_file = _XE_PATH_ . "modules/counter/queries/updateCounterUnique.xml"; $xml_file = _XE_PATH_ . "modules/counter/queries/updateCounterUnique.xml";
$argsString = '$args->regdate = 25;'; $argsString = '$args->regdate = 25;';
$expected = 'UPDATE [xe_counter_status] SET [unique_visitor] = [unique_visitor] + ?, [pageview] = [pageview] + ? WHERE [regdate] = ?'; $expected = 'UPDATE [xe_counter_status] as [counter_status] SET [unique_visitor] = [unique_visitor] + ?, [pageview] = [pageview] + ? WHERE [regdate] = ?';
$this->_test($xml_file, $argsString, $expected, array("25", 1, 1)); $this->_test($xml_file, $argsString, $expected, array("25", 1, 1));
} }
} }

View file

@ -30,5 +30,17 @@
$this->_test($xml_file, $argsString, $expected); $this->_test($xml_file, $argsString, $expected);
} }
function test_document_updateItemDownloadedCount(){
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/document.updateItemDownloadedCount.xml";
$argsString = '$args->module_srl = 10; $args->package_srl = 11; $args->item_srl = 12;';
$expected = 'update `xe_resource_items` as `resource_items`
set `downloaded` = `downloaded` + 1
where `module_srl` = 10
and `package_srl` = 11
and `item_srl` = 12
';
$this->_test($xml_file, $argsString, $expected);
}
} }

View file

@ -0,0 +1,13 @@
<query id="updateItemDownloadedCount" action="update">
<tables>
<table name="resource_items" />
</tables>
<columns>
<column name="downloaded" default="plus(1)" notnull="notnull" />
</columns>
<conditions>
<condition operation="equal" column="module_srl" var="module_srl" filter="number" notnull="notnull" />
<condition operation="equal" column="package_srl" var="package_srl" filter="number" notnull="notnull" pipe="and" />
<condition operation="equal" column="item_srl" var="item_srl" filter="number" notnull="notnull" pipe="and" />
</conditions>
</query>