forked from github/dataease
Merge pull request #11912 from dataease/pr@dev-v2@fixDS
Pr@dev v2@fix ds
This commit is contained in:
commit
73286cebfb
@ -66,6 +66,7 @@ public class SqlparserUtils {
|
||||
}
|
||||
|
||||
if (select.getSelectBody() instanceof PlainSelect) {
|
||||
|
||||
return handlePlainSelect((PlainSelect) select.getSelectBody(), select, dsType);
|
||||
} else {
|
||||
StringBuilder result = new StringBuilder();
|
||||
@ -84,6 +85,7 @@ public class SqlparserUtils {
|
||||
handleSelectItems(plainSelect, dsType);
|
||||
handleFromItems(plainSelect, dsType);
|
||||
handleJoins(plainSelect, dsType);
|
||||
handleHaving(plainSelect);
|
||||
return handleWhere(plainSelect, statementSelect, dsType);
|
||||
}
|
||||
|
||||
@ -175,6 +177,29 @@ public class SqlparserUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static String handleHaving(PlainSelect plainSelect) throws Exception {
|
||||
Expression expr = plainSelect.getHaving();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
BinaryExpression binaryExpression = null;
|
||||
try {
|
||||
binaryExpression = (BinaryExpression) expr;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (binaryExpression != null) {
|
||||
boolean hasSubBinaryExpression = binaryExpression instanceof AndExpression || binaryExpression instanceof OrExpression;
|
||||
if (!hasSubBinaryExpression && !(binaryExpression.getLeftExpression() instanceof BinaryExpression) && !(binaryExpression.getLeftExpression() instanceof InExpression) && (hasVariable(binaryExpression.getLeftExpression().toString()) || hasVariable(binaryExpression.getRightExpression().toString()))) {
|
||||
stringBuilder.append(SubstitutedSql);
|
||||
} else {
|
||||
expr.accept(getExpressionDeParser(stringBuilder));
|
||||
}
|
||||
|
||||
} else {
|
||||
expr.accept(getExpressionDeParser(stringBuilder));
|
||||
}
|
||||
plainSelect.setHaving(CCJSqlParserUtil.parseCondExpression(stringBuilder.toString()));
|
||||
return plainSelect.toString();
|
||||
}
|
||||
|
||||
private static String handleWhere(PlainSelect plainSelect, Select statementSelect, String dsType) throws Exception {
|
||||
Expression expr = plainSelect.getWhere();
|
||||
if (expr == null) {
|
||||
|
@ -55,6 +55,7 @@ const state = reactive({
|
||||
})
|
||||
|
||||
const schemas = ref([])
|
||||
const loading = ref(false)
|
||||
const dsForm = ref<FormInstance>()
|
||||
|
||||
const cronEdit = ref(true)
|
||||
@ -502,7 +503,9 @@ const getDsSchema = () => {
|
||||
if (val) {
|
||||
const request = JSON.parse(JSON.stringify(form.value))
|
||||
request.configuration = Base64.encode(JSON.stringify(request.configuration))
|
||||
loading.value = true
|
||||
getSchema(request).then(res => {
|
||||
loading.value = false
|
||||
schemas.value = res.data
|
||||
ElMessage.success(t('commons.success'))
|
||||
})
|
||||
@ -722,6 +725,7 @@ defineExpose({
|
||||
label-width="180px"
|
||||
label-position="top"
|
||||
require-asterisk-position="right"
|
||||
v-loading="loading"
|
||||
>
|
||||
<el-form-item
|
||||
:label="t('auth.datasource') + t('chart.name')"
|
||||
|
@ -361,7 +361,9 @@ const validateDS = () => {
|
||||
}
|
||||
|
||||
const doValidateDs = request => {
|
||||
dsLoading.value = true
|
||||
validate(request).then(res => {
|
||||
dsLoading.value = false
|
||||
if (res.data.type === 'API') {
|
||||
let error = 0
|
||||
const status = JSON.parse(res.data.status) as Array<{ status: string; name: string }>
|
||||
|
Loading…
Reference in New Issue
Block a user