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

Failed to parse PostgreSQL version on Debian based PostgreSQL containers #100

Closed
lejsekt opened this issue Feb 21, 2019 · 3 comments
Closed
Assignees
Labels
Milestone

Comments

@lejsekt
Copy link

lejsekt commented Feb 21, 2019

Hi,
I've got the following issue when using Evolve 2.0 and PostgreSQL 10.5 that is run inside a docker container.
Migration fails with the following exception:
Database migration failed.System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at Evolve.Dialect.PostgreSQL.PostgreSQLSchema..ctor(String schemaName, WrappedConnection wrappedConnection)
at Evolve.Dialect.PostgreSQL.PostgreSQLDatabase.GetSchema(String schemaName)
at Evolve.Evolve.ManageSchemas(DatabaseHelper db)
at Evolve.Evolve.InternalExecuteCommand(Action`1 commandAction)

The problem is that "SHOW server_version;" returns:
10.5 (Debian 10.5-2.pgdg90+1)

and the code in the constructor of PostgreSQLSchema:
var version = _wrappedConnection.QueryForString("SHOW server_version;").Split('.');
MajorVersion = int.Parse(version[0]);
MinorVersion = int.Parse(version[1]);

obviously fails on parsing such a version string.

I'm running x64 version of Windows 10, using .NET Framework 4.7.2, Docker 18.09.2 and postgres:10.5 image.

@lecaillon lecaillon self-assigned this Feb 21, 2019
@lecaillon
Copy link
Owner

Thanks for your feedback @Teddy108
Your issue is really clear. You've done half the work for me. Appreciate it.

Obviously on all version of PostgreSQL I test this request returns something like 9.6.12

Can you please tell me what return this statement on your database ?

SHOW server_version_num;

@lecaillon lecaillon added the bug label Feb 21, 2019
@lecaillon lecaillon added this to the Evolve 2.1.0 milestone Feb 21, 2019
@lecaillon lecaillon added this to To do in Evolve 2.1.0 Feb 21, 2019
@lejsekt
Copy link
Author

lejsekt commented Feb 21, 2019

It gives 100005.

server_version_num is an integer according to the docs, whereas server_version is a string, so server_version_num might be more suitable for extracting the major and minor version.

And it seems the issue only affects the Debian based PostgreSQL containers. In case of the Alpine based counterparts, server_version returns just the major and minor version and not any addition string.

Thank you for the great software!

@lecaillon lecaillon moved this from To do to In progress in Evolve 2.1.0 Feb 21, 2019
@lecaillon lecaillon moved this from In progress to Done in Evolve 2.1.0 Feb 21, 2019
@lecaillon
Copy link
Owner

The fix will be included in Evolve 2.1.0, released by the end of the week

@lecaillon lecaillon changed the title Failed to parse PostgreSQL version Failed to parse PostgreSQL version on Debian based PostgreSQL containers Feb 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Evolve 2.1.0
  
Done
Development

No branches or pull requests

2 participants