Skip to content

Commit

Permalink
Avoid schema duplication. Similar to fordfrog#265 from jschaf
Browse files Browse the repository at this point in the history
  • Loading branch information
jalisson committed Aug 21, 2020
1 parent f40b387 commit 40698e2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/cz/startnet/utils/pgdiff/schema/PgDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*/
package cz.startnet.utils.pgdiff.schema;

import cz.startnet.utils.pgdiff.parsers.ParserException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
* Stores database information.
Expand Down Expand Up @@ -135,9 +137,16 @@ public List<PgSchema> getSchemas() {
* Adds {@code schema} to the lists of schemas.
*
* @param schema schema
* @throws ParserException Thrown if schema was already added to the database.
*/
public void addSchema(final PgSchema schema) {
schemas.add(schema);
if (Objects.nonNull(schemas) && !schemas.isEmpty()) {
if (!schemas.contains(schema)) {
schemas.add(schema);
}
} else {
schemas.add(schema);
}
}

/**
Expand Down

0 comments on commit 40698e2

Please sign in to comment.