-
Notifications
You must be signed in to change notification settings - Fork 54
#163 В запросе отсутствует проверка на NULL для поля, которое может потенциально содержать NULL. #1153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
#163 В запросе отсутствует проверка на NULL для поля, которое может потенциально содержать NULL. #1153
Conversation
Обновление от мастера
Kudos, SonarCloud Quality Gate passed! |
#### Запросы | ||
- В запросе отсутствует проверка на NULL для поля, которое может потенциально содержать NULL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нужно пустую строку после подзаголовка
ORDER BY | ||
QuantityBalance; | ||
|
||
SELECT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут надо разбить на 2 примера - это же не один запрос ведь...
УПОРЯДОЧИТЬ ПО | ||
КоличествоОстаток; | ||
|
||
ВЫБРАТЬ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут надо разбить на 2 примера - это же не один запрос ведь...
List<CommonExpression> commonExpressions = | ||
EcoreUtil2.getAllContentsOfType(orderExpression, CommonExpression.class); | ||
orderFields.addAll(commonExpressions); | ||
for (CommonExpression commonExpression : commonExpressions) | ||
{ | ||
if (commonExpression instanceof MultiPartCommonExpression) | ||
{ | ||
orderFields.remove(((MultiPartCommonExpression)commonExpression).getSourceTable()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а тут разве не более правильно сделать? вроде других вариантов нет, но при этом удаляешь 2 лишних цикла.
if (orderExpression.getItem().getExpression() instanceof CommonExpression)
{
orderFields.add(orderExpression.getItem().getExpression())
}
@@ -50,6 +50,12 @@ JoinToSubQuery_description = Query join with sub query | |||
|
|||
JoinToSubQuery_title = Query join with sub query | |||
|
|||
QueryFieldIsNullCheck_description = The query is missing a NULL check for a field that could potentially contain NULL | |||
|
|||
QueryFieldIsNullCheck_Query_missing_NULL_check_for_field_potentially_contain_NULL = The query is missing a NULL check for a field that could potentially contain NULL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут нужно вставить имя поля, иначе в тексте его не найти.
private List<String> getIsNullMethods() | ||
{ | ||
List<String> isNullMethods = Arrays.asList(ISNULL_METHODS.split(METHOD_DELIMITER)); | ||
isNullMethods.replaceAll(String::trim); | ||
return isNullMethods; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это видимо код который хотел делать через параметры но забыл? надо переделать на две константы
if (monitor.isCanceled()) | ||
{ | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
монитор нужно проверять в циклах и после выполнения тяжелых действий - см. код ниже
return; | ||
} | ||
|
||
List<CommonExpression> orderFields = getOrderFields(sourceTable); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
если тут вернули пустую коллекцию - то дальше можно не продолжать.
} | ||
|
||
List<CommonExpression> orderFields = getOrderFields(sourceTable); | ||
List<QuerySchemaOperator> operators = sourceTable.getOperators(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если оператор выборки 1 единственный - дальше можно не продолжать
List<QuerySchemaOperator> operators = sourceTable.getOperators(); | ||
for (QuerySchemaOperator operator : operators) | ||
{ | ||
List<QuerySchemaExpression> fields = operator.getSelectFields(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
наверное нужно проверять только операторы с левым/правым соединением, или полным. Внутренние соединение как раз не может давать null в полях
Что сделано
Чек-лист
Общее:
master
и нет конфликтовЕсли применимо:
Закрываемые задачи
Closes #163