-
Notifications
You must be signed in to change notification settings - Fork 34
Database-based Argument Setter #77
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
Database-based Argument Setter #77
Conversation
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.
A few comments.
|
||
@Override | ||
public void configurePipeline(PipelineConfigurer pipelineConfigurer) | ||
throws IllegalArgumentException { |
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.
nit: misallignment
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.
@CuriousVini fixed
} catch (Exception e) { | ||
collector.addFailure(e.getMessage(), null).withStacktrace(e.getStackTrace()); | ||
} | ||
config.validate(collector); |
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.
why do we need to call config.validate(collector)
2 times?
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.
@CuriousVini removed redundant call
collector.addFailure("Invalid connection string", "Connection string cannot be empty"); | ||
} | ||
if (!containsMacro(ConnectionConfig.USER) && Strings.isNullOrEmpty(this.user)) { | ||
collector.addFailure("Invalid username", "Username cannot be empty"); |
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.
please add period at the end of every failure message and its cause
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.
@CuriousVini updated all messages
|
||
collector.getOrThrowException(); | ||
} | ||
|
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.
nit: extra line
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.
@CuriousVini fixed
} | ||
if (resultSet.next()) { | ||
failureCollector | ||
.addFailure("More than one record found", |
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.
More than one records found.
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.
@CuriousVini fixed
if (resultSet.next()) { | ||
failureCollector | ||
.addFailure("More than one record found", | ||
"The argument selection conditions return multiple rows"); |
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.
what is the expected corrective action that needs to be taken from user?
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.
@CuriousVini updated
ResultSet resultSet = statement.executeQuery(config.getQuery()); | ||
boolean hasRecord = resultSet.next(); | ||
if (!hasRecord) { | ||
failureCollector.addFailure("Ne record found", |
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.
Typo: No records found.
Please add period to every failure message and corresponding corrective action
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.
@CuriousVini updated messages to have corrective action.
boolean hasRecord = resultSet.next(); | ||
if (!hasRecord) { | ||
failureCollector.addFailure("Ne record found", | ||
"No data is returned for the argument selection conditions"); |
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 there are no records should we return from here and not do any further processing?
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.
@CuriousVini fixed to return and not do further processing.
.getConnection(config.getConnectionString(), connectionProperties); | ||
Statement statement = connection.createStatement(); | ||
ResultSet resultSet = statement.executeQuery(config.getQuery()); | ||
boolean hasRecord = resultSet.next(); |
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.
does resultset has - hasNext()
method? we should use that method.
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.
@CuriousVini resulset does not have hasNext() instead it has next() which moves the cursor to next record and returns true/false based on whether record is available or not.
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.
a few comments. Fix and squash the commits
"The argument selection conditions must match only one record."); | ||
} | ||
} catch (SQLException e) { | ||
throw new SQLException(e.getMessage(), e.getSQLState(), e.getErrorCode()); |
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.
why do we catch the sqlexception and throw the same exception? It should throw same SQLException
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.
a few comments. Fix and squash the commits
@CuriousVini done.
collector.addFailure("Invalid password.", "Password cannot be empty."); | ||
} | ||
if (!containsMacro(DATABASE_NAME) && Strings.isNullOrEmpty(this.getDatabaseName())) { | ||
collector.addFailure("Invalid database.", "Invalid database is specified."); |
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.
Invalid database is specified.
-> Invalid database must be specified.
collector.addFailure("Invalid database.", "Invalid database is specified."); | ||
} | ||
if (!containsMacro(TABLE_NAME) && Strings.isNullOrEmpty(this.getTableName())) { | ||
collector.addFailure("Invalid table.", "Invalid table is specified."); |
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.
same here
a6d75ad
to
4d1eff1
Compare
added: Database-based Argument Setter support
JIRA: https://issues.cask.co/browse/PLUGIN-173