mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 12:02:24 +09:00
Fixed insert bug - nextSequnce was not properly retrieved.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8608 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
0c63c32b10
commit
98a85cdaa9
5 changed files with 49 additions and 19 deletions
|
|
@ -3,19 +3,25 @@
|
||||||
class DefaultValue {
|
class DefaultValue {
|
||||||
var $column_name;
|
var $column_name;
|
||||||
var $value;
|
var $value;
|
||||||
|
var $is_sequence = false;
|
||||||
|
|
||||||
function DefaultValue($column_name, $value){
|
function DefaultValue($column_name, $value){
|
||||||
$this->column_name = $column_name;
|
$this->column_name = $column_name;
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
|
$this->value = $this->_setValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
function isString(){
|
function isString(){
|
||||||
$str_pos = strpos($this->value, '(');
|
$str_pos = strpos($this->value, '(');
|
||||||
if($str_pos===false) return true;
|
if($str_pos===false) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toString(){
|
function isSequence(){
|
||||||
|
return $this->is_sequence;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _setValue(){
|
||||||
if(!isset($this->value)) return;
|
if(!isset($this->value)) return;
|
||||||
|
|
||||||
// If value contains comma separated values and does not contain paranthesis
|
// If value contains comma separated values and does not contain paranthesis
|
||||||
|
|
@ -24,13 +30,13 @@
|
||||||
return sprintf('array(%s)', $this->value);
|
return sprintf('array(%s)', $this->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$str_pos = strpos($this->value, '(');
|
$str_pos = strpos($this->value, '(');
|
||||||
// // TODO Replace this with parseExpression
|
// // TODO Replace this with parseExpression
|
||||||
if($str_pos===false) return '\''.$this->value.'\'';
|
if($str_pos===false) return '\''.$this->value.'\'';
|
||||||
//if($str_pos===false) return $this->value;
|
//if($str_pos===false) return $this->value;
|
||||||
|
|
||||||
$func_name = substr($this->value, 0, $str_pos);
|
$func_name = substr($this->value, 0, $str_pos);
|
||||||
$args = substr($this->value, $str_pos+1, strlen($value)-1);
|
$args = substr($this->value, $str_pos+1, strlen($value)-1);
|
||||||
|
|
||||||
switch($func_name) {
|
switch($func_name) {
|
||||||
case 'ipaddress' :
|
case 'ipaddress' :
|
||||||
|
|
@ -43,7 +49,8 @@
|
||||||
$val = 'date("YmdHis")';
|
$val = 'date("YmdHis")';
|
||||||
break;
|
break;
|
||||||
case 'sequence' :
|
case 'sequence' :
|
||||||
$val = '$this->getNextSequence()';
|
$this->is_sequence = true;
|
||||||
|
$val = '$sequence';
|
||||||
break;
|
break;
|
||||||
case 'plus' :
|
case 'plus' :
|
||||||
$args = abs($args);
|
$args = abs($args);
|
||||||
|
|
@ -64,6 +71,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return $val;
|
return $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toString(){
|
||||||
|
return $this->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
$validator = '';
|
$validator = '';
|
||||||
if(isset($this->default_value)){
|
if(isset($this->default_value)){
|
||||||
$this->default_value = new DefaultValue($this->argument_name, $this->default_value);
|
$this->default_value = new DefaultValue($this->argument_name, $this->default_value);
|
||||||
|
if($this->default_value->isSequence())
|
||||||
|
$validator .= '$db = &DB::getInstance(); $sequence = $db->getNextSequence(); ';
|
||||||
$validator .= sprintf("$%s_argument->ensureDefaultValue(%s);\n"
|
$validator .= sprintf("$%s_argument->ensureDefaultValue(%s);\n"
|
||||||
, $this->argument_name
|
, $this->argument_name
|
||||||
, $this->default_value->toString()
|
, $this->default_value->toString()
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,14 @@
|
||||||
$db_info->db_table_prefix = 'xe';
|
$db_info->db_table_prefix = 'xe';
|
||||||
|
|
||||||
$oContext->setDbInfo($db_info);
|
$oContext->setDbInfo($db_info);
|
||||||
|
|
||||||
|
// remove cache dir
|
||||||
|
$tmp_cache_list = FileHandler::readDir('./files','/(^cache_[0-9]+)/');
|
||||||
|
if($tmp_cache_list){
|
||||||
|
foreach($tmp_cache_list as $tmp_dir){
|
||||||
|
if($tmp_dir) FileHandler::removeDir('./files/'.$tmp_dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -48,22 +48,31 @@
|
||||||
$args->lang_code;
|
$args->lang_code;
|
||||||
$output = executeQuery('document.insertDocument', $args);
|
$output = executeQuery('document.insertDocument', $args);
|
||||||
|
|
||||||
$this->assertNotEquals(-225, $args->error);
|
$this->assertNotEquals(-225, $output->error);
|
||||||
$this->assertNotEquals('Missing value for attribute "homepage" with the NOT NULL constraint.', $output->message);
|
$this->assertNotEquals('Missing value for attribute "homepage" with the NOT NULL constraint.', $output->message);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_communication_addFriendGroup(){
|
||||||
|
$args->member_srl = 202;
|
||||||
|
$args->title = "Grup";
|
||||||
|
|
||||||
|
$output = executeQuery("communication.addFriendGroup", $args);
|
||||||
|
$this->assertEquals(0, $output->error, $output->message);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected function tearDown() {
|
protected function tearDown() {
|
||||||
|
|
||||||
|
|
||||||
$db = &DB::getInstance();
|
$db = &DB::getInstance();
|
||||||
$db->_query("DELETE FROM xe_modules WHERE module_srl = 47374");
|
$db->_query("DELETE FROM xe_modules WHERE module_srl = 47374");
|
||||||
$db->_query("DELETE FROM xe_documents WHERE document_srl = 9200");
|
$db->_query("DELETE FROM xe_documents WHERE document_srl = 9200");
|
||||||
|
$db->_query("DELETE FROM xe_member_friend_group WHERE member_srl = 202");
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
// TODO Delete inserted value
|
// TODO Delete inserted value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue