Skip to content
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

NMS-16510: fix assert search #7450

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -389,19 +389,39 @@ public String constructJoinExprForTables(final List<Table> tables) {
*/
public String addColumn(final List<Table> tables, final String column) throws FilterParseException {
getReadLock().lock();
try {
final Table table = findTableByVisibleColumn(column);
if(table == null) {
final String message = "Could not find the column '" + column +"' in filter rule";
throw new FilterParseException(message);
if (doesColumnExist(column)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are bypassing throwing exception and returning empty. Did you ensure this will not cause any issues in other parts of the code ?

try {
final Table table = findTableByVisibleColumn(column);
if (table == null) {
final String message = "Could not find the column '" + column + "' in filter rule";
throw new FilterParseException(message);
}
if (!tables.contains(table)) {
tables.add(table);
}
return table.getName() + "." + column;
} finally {
getReadLock().unlock();
}
if (!tables.contains(table)) {
tables.add(table);
}
return "";
}
/**
* Validate that a column is in the schema.
* @return boolean
*
*/
public boolean doesColumnExist(String colName) {
for (final Table t : getDatabaseSchema().getTables()) {
for (final Column col : t.getColumns()) {
if (col.getVisible() == null || col.getVisible().equalsIgnoreCase("true")) {
if (col.getName().equalsIgnoreCase(colName)) {
return true; // Column found
}
}
}
return table.getName() + "." + column;
} finally {
getReadLock().unlock();
}
return false; // Column not found
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ public String getNodeMappingStatement(final String rule) throws FilterParseExcep
columns.append(m_databaseSchemaConfigFactory.addColumn(tables, "nodeID"));
columns.append(", " + m_databaseSchemaConfigFactory.addColumn(tables, "nodeLabel"));

//added table assets column
columns.append(", " + m_databaseSchemaConfigFactory.addColumn(tables, "city"));
columns.append(", " + m_databaseSchemaConfigFactory.addColumn(tables, "department"));
columns.append(", " + m_databaseSchemaConfigFactory.addColumn(tables, "address1"));

Comment on lines +461 to +465
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can't keep on adding these columns as we desire. Also the search term was used in asset description.

final String where = parseRule(tables, rule);
final String from = m_databaseSchemaConfigFactory.constructJoinExprForTables(tables);

Expand Down Expand Up @@ -708,6 +713,7 @@ private String parseRule(final List<Table> tables, final String rule) throws Fil
}
regex.appendTail(tempStringBuff);
sqlRule = tempStringBuff.toString();
if(!sqlRule.isEmpty())
MusaidAli marked this conversation as resolved.
Show resolved Hide resolved
return "WHERE " + sqlRule;
}
return "";
Expand Down
Loading