* Add sql check and modify zentao sql.

This commit is contained in:
songchenxuan
2023-06-20 10:16:26 +08:00
parent e76f50a3f0
commit fa3a7dc79e
8 changed files with 65 additions and 8 deletions
+17
View File
@@ -21,3 +21,20 @@ UPDATE `zt_chart` SET `settings` = '{\"value\": {\"type\": \"agg\", \"field\": \
WHERE id = 10112;
UPDATE `zt_priv` SET `edition`=',biz,max,ipd,' where `module`='feedback' and `method`='toUserStory';
UPDATE `zt_pivot` SET `sql` = 'select t1.id,t3.name as project,IF(t3.multiple=\"1\",t1.name,\"\") as execution,t2.id as bugID,t2.type from zt_project as t1 \r\nleft join zt_bug as t2 on t1.id=t2.execution\r\nleft join zt_project as t3 on t3.id=t1.project\r\nwhere t1.deleted=\'0\' and t2.deleted=\'0\' and if($project=\'\',1,t3.id=$project) and if($execution=\'\',1,t1.id=$execution)'
WHERE `sql` = 'select t1.id,t3.name as project,t3.id,IF(t3.multiple=\"1\",t1.name,\"\") as execution,t2.id as bugID,t2.type from zt_project as t1 \r\nleft join zt_bug as t2 on t1.id=t2.execution\r\nleft join zt_project as t3 on t3.id=t1.project\r\nwhere t1.deleted=\'0\' and t2.deleted=\'0\' and if($project=\'\',1,t3.id=$project) and if($execution=\'\',1,t1.id=$execution)'
UPDATE `zt_pivot` SET `sql` = 'select t1.id,t4.name as project,IF(t4.multiple=\"1\",t1.name,\"\") as execution,t1.status,t2.number as tasks,round(t2.consumed,2) as consumed,round(t2.`left`,2) as `left`,t3.stories,t2.undone as undoneTask,t3.undone as undoneStory,t2.totalReal from zt_project as t1 \r\nleft join ztv_executionsummary as t2 on t1.id=t2.execution\r\nleft join ztv_projectstories as t3 on t1.id=t3.execution\r\nleft join zt_project as t4 on t4.id=t1.project\r\nwhere t1.deleted=\'0\' and t1.type in (\'sprint\',\'stage\') and if($project=\'\',1,t4.id=$project) and if($execution=\'\',1,t1.id=$execution) and if($status=\'\',1,t1.status=$status)'
WHERE `sql` = 'select t1.id,t4.name as project,t4.id,IF(t4.multiple=\"1\",t1.name,\"\") as execution,t1.status,t2.number as tasks,round(t2.consumed,2) as consumed,round(t2.`left`,2) as `left`,t3.stories,t2.undone as undoneTask,t3.undone as undoneStory,t2.totalReal from zt_project as t1 \r\nleft join ztv_executionsummary as t2 on t1.id=t2.execution\r\nleft join ztv_projectstories as t3 on t1.id=t3.execution\r\nleft join zt_project as t4 on t4.id=t1.project\r\nwhere t1.deleted=\'0\' and t1.type in (\'sprint\',\'stage\') and if($project=\'\',1,t4.id=$project) and if($execution=\'\',1,t1.id=$execution) and if($status=\'\',1,t1.status=$status)'
UPDATE `zt_pivot` SET `sql` = 'select t1.id, t5.name as project,IF(t5.multiple=\"1\",t1.name,\"\") as execution,t2.stories,(t2.stories-t2.undone) as doneStory,t3.number,(t3.number-t3.undone) as doneTask,t4.bugs,t4.resolutions, round(t4.bugs/(t2.stories-t2.undone),2) as bugthanstory,round(t4.bugs/(t3.number-t3.undone),2) as bugthantask,t4.seriousBugs from zt_project as t1 \r\nleft join ztv_projectstories as t2 on t1.id=t2.execution\r\nleft join ztv_executionsummary as t3 on t1.id=t3.execution\r\nleft join ztv_projectbugs as t4 on t1.id=t4.execution\r\nleft join zt_project as t5 on t5.id=t1.project\r\nwhere t1.deleted=\'0\' and t1.type in (\'sprint\',\'stage\') and t1.grade=\'1\' and if($project=\'\',1,t5.id=$project) and if($execution=\'\',1,t1.id=$execution)'
WHERE `sql` = 'select t1.id, t5.name as project,t5.id,IF(t5.multiple=\"1\",t1.name,\"\") as execution,t2.stories,(t2.stories-t2.undone) as doneStory,t3.number,(t3.number-t3.undone) as doneTask,t4.bugs,t4.resolutions, round(t4.bugs/(t2.stories-t2.undone),2) as bugthanstory,round(t4.bugs/(t3.number-t3.undone),2) as bugthantask,t4.seriousBugs from zt_project as t1 \r\nleft join ztv_projectstories as t2 on t1.id=t2.execution\r\nleft join ztv_executionsummary as t3 on t1.id=t3.execution\r\nleft join ztv_projectbugs as t4 on t1.id=t4.execution\r\nleft join zt_project as t5 on t5.id=t1.project\r\nwhere t1.deleted=\'0\' and t1.type in (\'sprint\',\'stage\') and t1.grade=\'1\' and if($project=\'\',1,t5.id=$project) and if($execution=\'\',1,t1.id=$execution)'
UPDATE `zt_pivot` SET `sql` = 'select t1.id,t3.name as project,t3.id as projectID,IF(t3.multiple=\"1\",t1.name,\"\") as execution,t1.id as bugID,t2.assignedTo from zt_project as t1 \r\nleft join zt_bug as t2 on t1.id=t2.execution \r\nleft join zt_project as t3 on t3.id=t1.project\r\nwhere t1.deleted=\'0\' and t2.deleted=\'0\' having bugID!=\'\' and if($project=\'\',1,t3.id=$project) and if($execution=\'\',1,t1.id=$execution)'
WHERE `sql` = 'select t1.id,t3.name as project,t3.id,IF(t3.multiple=\"1\",t1.name,\"\") as execution,t1.id as bugID,t2.assignedTo from zt_project as t1 \r\nleft join zt_bug as t2 on t1.id=t2.execution \r\nleft join zt_project as t3 on t3.id=t1.project\r\nwhere t1.deleted=\'0\' and t2.deleted=\'0\' having bugID!=\'\' and if($project=\'\',1,t3.id=$project) and if($execution=\'\',1,t1.id=$execution)'
UPDATE `zt_pivot` SET `sql` = 'select t1.id,t3.name as project,t3.id as projectID,IF(t3.multiple=\"1\",t1.name,\"\") as execution,t1.id as bugID,t2.resolvedBy from zt_project as t1 \r\nleft join zt_bug as t2 on t1.id=t2.execution\r\nleft join zt_project as t3 on t3.id=t1.project\r\nwhere t1.deleted=\'0\' and t2.deleted=\'0\' and t2.status!=\'active\' and t2.resolvedBy!=\'\' having bugID!=\'\' and if($project=\'\',1,t3.id=$project) and if($execution=\'\',1,t1.id=$execution)'
WHERE `sql` = 'select t1.id,t3.name as project,t3.id,IF(t3.multiple=\"1\",t1.name,\"\") as execution,t1.id as bugID,t2.resolvedBy from zt_project as t1 \r\nleft join zt_bug as t2 on t1.id=t2.execution\r\nleft join zt_project as t3 on t3.id=t1.project\r\nwhere t1.deleted=\'0\' and t2.deleted=\'0\' and t2.status!=\'active\' and t2.resolvedBy!=\'\' having bugID!=\'\' and if($project=\'\',1,t3.id=$project) and if($execution=\'\',1,t1.id=$execution)'
UPDATE `zt_pivot` SET `sql` = 'select t1.id,t3.name as project,t3.id as projectID,IF(t3.multiple=\"1\",t1.name,\"\") as execution,t1.id as bugID,t2.openedBy from zt_project as t1 \r\nleft join zt_bug as t2 on t1.id=t2.execution\r\nleft join zt_project as t3 on t3.id=t1.project\r\nwhere t1.deleted=\'0\' and t2.deleted=\'0\' having bugID!=\'\' and if($project=\'\',1,t3.id=$project) and if($execution=\'\',1,t1.id=$execution)'
WHERE `sql` = 'select t1.id,t3.name as project,t3.id,IF(t3.multiple=\"1\",t1.name,\"\") as execution,t1.id as bugID,t2.openedBy from zt_project as t1 \r\nleft join zt_bug as t2 on t1.id=t2.execution\r\nleft join zt_project as t3 on t3.id=t1.project\r\nwhere t1.deleted=\'0\' and t2.deleted=\'0\' having bugID!=\'\' and if($project=\'\',1,t3.id=$project) and if($execution=\'\',1,t1.id=$execution)'
UPDATE `zt_pivot` SET `sql` = 'select t1.id,t3.name as project,t3.id as projectID,IF(t3.multiple=\"1\",t1.name,\"\") as execution,t1.id as bugID,t2.status from zt_project as t1 \r\nleft join zt_bug as t2 on t1.id=t2.execution\r\nleft join zt_project as t3 on t3.id=t1.project\r\nwhere t1.deleted=\'0\' and t2.deleted=\'0\' having bugID!=\' \' and if($project=\'\',1,t3.id=$project) and if($execution=\'\',1,t1.id=$execution)'
WHERE `sql` = 'select t1.id,t3.name as project,t3.id,IF(t3.multiple=\"1\",t1.name,\"\") as execution,t1.id as bugID,t2.status from zt_project as t1 \r\nleft join zt_bug as t2 on t1.id=t2.execution\r\nleft join zt_project as t3 on t3.id=t1.project\r\nwhere t1.deleted=\'0\' and t2.deleted=\'0\' having bugID!=\' \' and if($project=\'\',1,t3.id=$project) and if($execution=\'\',1,t1.id=$execution)'
UPDATE `zt_pivot` SET `sql` = 'select t1.id,t3.name as project,t3.id as projectID,IF(t3.multiple=\"1\",t1.name,\"\") as execution,t1.id as bugID,t2.resolution from zt_project as t1 \r\nleft join zt_bug as t2 on t1.id=t2.execution\r\nleft join zt_project as t3 on t3.id=t1.project\r\n where t1.deleted=\'0\' and t2.deleted=\'0\' and t2.resolution!=\'\' having bugID!=\'\' and if($project=\'\',1,t3.id=$project) and if($execution=\'\',1,t1.id=$execution)'
WHERE `sql` = 'select t1.id,t3.name as project,t3.id,IF(t3.multiple=\"1\",t1.name,\"\") as execution,t1.id as bugID,t2.resolution from zt_project as t1 \r\nleft join zt_bug as t2 on t1.id=t2.execution\r\nleft join zt_project as t3 on t3.id=t1.project\r\n where t1.deleted=\'0\' and t2.deleted=\'0\' and t2.resolution!=\'\' having bugID!=\'\' and if($project=\'\',1,t3.id=$project) and if($execution=\'\',1,t1.id=$execution)'
+8 -8
View File
File diff suppressed because one or more lines are too long
+1
View File
@@ -56,6 +56,7 @@ $lang->dataview->default = 'Default Group';
$lang->dataview->relatedTable = 'Table';
$lang->dataview->relatedField = 'Field';
$lang->dataview->multilingual = 'After switching the system language, the corresponding name will be displayed';
$lang->dataview->duplicateField = 'Duplicate field names exist: <strong>%s</strong>. You are advised to: (1) Modify the <strong>*</strong> query to a specific field. (2) Use <strong>as</strong> to alias the field.';
$lang->dataview->varFilter = new stdclass();
$lang->dataview->varFilter->varCode = 'Var Code';
+1
View File
@@ -56,6 +56,7 @@ $lang->dataview->default = 'Default Group';
$lang->dataview->relatedTable = 'Table';
$lang->dataview->relatedField = 'Field';
$lang->dataview->multilingual = 'After switching the system language, the corresponding name will be displayed';
$lang->dataview->duplicateField = 'Duplicate field names exist: <strong>%s</strong>. You are advised to: (1) Modify the <strong>*</strong> query to a specific field. (2) Use <strong>as</strong> to alias the field.';
$lang->dataview->varFilter = new stdclass();
$lang->dataview->varFilter->varCode = 'Var Code';
+1
View File
@@ -56,6 +56,7 @@ $lang->dataview->default = 'Default Group';
$lang->dataview->relatedTable = 'Table';
$lang->dataview->relatedField = 'Field';
$lang->dataview->multilingual = 'After switching the system language, the corresponding name will be displayed';
$lang->dataview->duplicateField = 'Duplicate field names exist: <strong>%s</strong>. You are advised to: (1) Modify the <strong>*</strong> query to a specific field. (2) Use <strong>as</strong> to alias the field.';
$lang->dataview->varFilter = new stdclass();
$lang->dataview->varFilter->varCode = 'Var Code';
+1
View File
@@ -56,6 +56,7 @@ $lang->dataview->default = '默认分组';
$lang->dataview->relatedTable = '所属表';
$lang->dataview->relatedField = '对应字段';
$lang->dataview->multilingual = '切换系统语言项后,将显示对应名称';
$lang->dataview->duplicateField = '存在重复的字段名: <strong>%s</strong>。建议您:(1)修改 <strong>*</strong> 查询为具体的字段。(2)使用 <strong>as</strong> 为字段设置别名。';
$lang->dataview->varFilter = new stdclass();
$lang->dataview->varFilter->varCode = '变量代号';
+31
View File
@@ -168,6 +168,37 @@ class dataviewModel extends model
return $columnTypes;
}
/**
* Check that the column of an sql query is unique.
*
* @param string $sql
* @param bool $repeat
* @access public
* @return bool
*/
public function checkUniColumn($sql, $repeat = false)
{
$columns = $this->dao->getColumns($sql);
$isUnique = true;
$columnList = array();
$repeatColumn = array();
foreach($columns as $column)
{
$field = $column['name'];
if(isset($columnTypes[$field]))
{
$isUnique = false;
$repeatColumn[$field] = $field;
}
$columnTypes[$field] = $field;
}
if($repeat) return array($isUnique, $repeatColumn);
return $isUnique;
}
/**
* Get type options
*
+5
View File
@@ -9181,6 +9181,11 @@ class upgradeModel extends model
$data->stage = 'draft';
$fieldSettings = array();
}
elseif(!$this->dataview->checkUniColumn($querySQL))
{
$data->stage = 'draft';
$fieldSettings = array();
}
else
{
$fieldSettings = $this->getFieldSettings($sql);