Update to condition tag - column name should also be accepted in the "var" attribute and not just "default" attribute.

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8617 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-07-21 13:25:30 +00:00
parent e7fe19db1f
commit 8f04aa5d63
4 changed files with 38 additions and 7 deletions

View file

@ -24,19 +24,23 @@
$this->column_name = $dbParser->parseColumnName($condition->attrs->column);
$isColumnName = strpos($condition->attrs->default, '.');
$isColumnName = $isColumnName || strpos($condition->attrs->var, '.');
if($condition->node_name == 'query'){
$this->query = new QueryTag($condition, true);
$this->default_column = $this->query->toString();
}
else if($condition->attrs->var || $isColumnName === false){
else if(($condition->attrs->var && !$isColumnName) || $isColumnName === false){
require_once(_XE_PATH_.'classes/xml/xmlquery/queryargument/QueryArgument.class.php');
$this->argument = new QueryArgument($condition);
$this->argument_name = $this->argument->getArgumentName();
}
else {
if($condition->attrs->default)
$this->default_column = "'" . $dbParser->parseColumnName($condition->attrs->default) . "'" ;
else
$this->default_column = "'" . $dbParser->parseColumnName($condition->attrs->var) . "'" ;
}
}

View file

@ -61,7 +61,24 @@ class ConditionTagTest extends CubridTest {
$arguments = $tag->getArguments();
$this->assertEquals(1, count($arguments));
}
}
/**
* Tests that even if the column name is given in the var attribute, it knows it's just a name and not an argument
* <condition operation="equal" column="modules.module_srl" var="documents.module_srl" pipe="and" />
*/
function testConditionStringWithoutArgumentAndDefaultValueInsideVar(){
$xml_file = $this->xmlPath . "condition4.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new ConditionTag($xml_obj->condition);
$expected = "new Condition('\"modules\".\"module_srl\"','\"documents\".\"module_srl\"',\"equal\", 'and')";
$actual = $tag->getConditionString();
$this->assertEquals($expected, $actual);
$arguments = $tag->getArguments();
$this->assertEquals(0, count($arguments));
}
}

View file

@ -0,0 +1 @@
<condition operation="equal" column="modules.module_srl" var="documents.module_srl" pipe="and" />

View file

@ -184,10 +184,19 @@
where "session_key" = \'session_key\'';
$this->_test($xml_file, $argsString, $expected, $columnList);
//$columnList = array('session_key', 'cur_mid', 'val');
//$output = executeQuery('session.getSession', $args, $columnList);
}
function test_module_getModuleInfoByDocument(){
$xml_file = _XE_PATH_ . "modules/module/queries/getModuleInfoByDocument.xml";
$argsString = '$args->document_srl = 10;';
$expected = 'SELECT "modules".*
FROM "xe_modules" as "modules"
, "xe_documents" as "documents"
WHERE "documents"."document_srl" = 10
and "modules"."module_srl" = "documents"."module_srl"';
$this->_test($xml_file, $argsString, $expected);
}
}