Skip to content

Commit

Permalink
Fix failed to parse pgsql version (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
lecaillon committed Feb 21, 2019
1 parent db6667e commit cbdd1ff
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/Evolve/Dialect/PostgreSQL/PostgreSQLSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ public class PostgreSQLSchema : Schema
{
public PostgreSQLSchema(string schemaName, WrappedConnection wrappedConnection) : base(schemaName, wrappedConnection)
{
var version = _wrappedConnection.QueryForString("SHOW server_version;").Split('.');
MajorVersion = int.Parse(version[0]);
MinorVersion = int.Parse(version[1]);
Version = _wrappedConnection.QueryForLong("SHOW server_version_num;");
}

public int MajorVersion { get; }

public int MinorVersion { get; }
public long Version { get; }

public override bool IsExists()
{
Expand Down Expand Up @@ -61,7 +57,7 @@ public override bool Erase()

protected void DropMaterializedViews()
{
if (MajorVersion < 9 || (MajorVersion == 9 && MinorVersion < 3))
if (Version < 90300)
{
return;
}
Expand Down Expand Up @@ -110,7 +106,7 @@ protected void DropBaseTypes(bool recreate)

protected void DropBaseAggregates()
{
if (MajorVersion >= 11)
if (Version >= 110000)
{
return;
}
Expand All @@ -127,7 +123,7 @@ protected void DropBaseAggregates()

protected void DropRoutines()
{
if (MajorVersion < 11)
if (Version < 110000)
{
string sql = "SELECT proname, oidvectortypes(proargtypes) AS args " +
"FROM pg_proc INNER JOIN pg_namespace ns ON (pg_proc.pronamespace = ns.oid) " +
Expand Down

0 comments on commit cbdd1ff

Please sign in to comment.