Skip to content

Commit

Permalink
Null point comment
Browse files Browse the repository at this point in the history
  • Loading branch information
jalisson committed Jul 11, 2020
1 parent 67e09cd commit e1e9e03
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private static void parseConstraint(final Parser parser,
final String tableName = parser.parseIdentifier();
final String objectName = ParserUtils.getObjectName(tableName);
final String schemaName =
ParserUtils.getSchemaName(constraintName, database);
ParserUtils.getSchemaName(tableName, database);

final PgConstraint constraint = database.getSchema(schemaName).
getTable(objectName).getConstraint(constraintName);
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/cz/startnet/utils/pgdiff/parsers/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,20 @@ public boolean expect(final String word, final boolean optional) {
* @return true if whole sequence was found, otherwise false
*/
public boolean expectOptional(final String... words) {
final boolean found = expect(words[0], true);
final int oldPosition = position;
boolean found = expect(words[0], true);

if (!found) {
return false;
}

for (int i = 1; i < words.length; i++) {
skipWhitespace();
expect(words[i]);
found = expect(words[i], true);
if (!found) {
position = oldPosition;
return false;
}
}

return true;
Expand Down Expand Up @@ -249,7 +254,7 @@ public int parseInteger() {
*
* @return parsed string, if quoted then including quotes
*/
public String parseString() {
public String parseString() {
final boolean quoted = string.charAt(position) == '\'';

if (quoted) {
Expand All @@ -274,6 +279,11 @@ public String parseString() {
final String result;

try {
if (endPos >= string.length())
{
//try to fix StringIndexOutOfBoundsException
endPos = string.lastIndexOf('\'');
}
result = string.substring(position, endPos + 1);
} catch (final Throwable ex) {
throw new RuntimeException("Failed to get substring: " + string
Expand Down

0 comments on commit e1e9e03

Please sign in to comment.