postgresql-embedded icon indicating copy to clipboard operation
postgresql-embedded copied to clipboard

Wrong order of cliArgs in PostgresProcess.restoreFromFile

Open oilid opened this issue 7 years ago • 0 comments

Currently the order from appending the additional optional command line arguments in PostgresProcess.restoreFromFile is wrong. The filepath / -name of the "pg_restore" command must be located as last param (as described for example here: https://www.postgresql.org/docs/9.6/static/app-pgrestore.html#AEN97925).

So the code in PostgresProcess.restoreFromFile must be written like this:

[...]
String[] args = {
   "-U", getConfig().credentials().username(),
   "-d", getConfig().storage().dbName(),
   "-h", getConfig().net().host(),
   "-p", String.valueOf(getConfig().net().port())
};

if (cliArgs != null && cliArgs.length != 0) {
   args = ArrayUtils.addAll(args, cliArgs);
}
args = ArrayUtils.add(args, file.getAbsolutePath());
[...]

I just realized this issue in my fork (backport java 1.6): oilid/postgresql-embedded@604f84c

oilid avatar Nov 14 '17 12:11 oilid