mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	v3.2.687-preview20230119 pgsql15.0 Version 处理
This commit is contained in:
		@@ -89,8 +89,8 @@ namespace FreeSql.Custom.PostgreSQL
 | 
			
		||||
            var isPg10 = (_orm.DbFirst as CustomPostgreSQLDbFirst).IsPg10;
 | 
			
		||||
            using (var conn = _orm.Ado.MasterPool.Get(TimeSpan.FromSeconds(5)))
 | 
			
		||||
            {
 | 
			
		||||
                isPg95 = CustomPostgreSQLDbFirst.PgVersionIs(conn.Value.ServerVersion, 9, 5);
 | 
			
		||||
                isPg96 = CustomPostgreSQLDbFirst.PgVersionIs(conn.Value.ServerVersion, 9, 6);
 | 
			
		||||
                isPg95 = CustomPostgreSQLDbFirst.ParsePgVersion(conn.Value.ServerVersion, 9, 5).Item1;
 | 
			
		||||
                isPg96 = CustomPostgreSQLDbFirst.ParsePgVersion(conn.Value.ServerVersion, 9, 6).Item1;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (var obj in objects)
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,7 @@ namespace FreeSql.Custom.PostgreSQL
 | 
			
		||||
                    {
 | 
			
		||||
                        try
 | 
			
		||||
                        {
 | 
			
		||||
                            _ServerVersionValue = int.Parse(conn.Value.ServerVersion.Split('.')[0]);
 | 
			
		||||
                            _ServerVersionValue = ParsePgVersion(conn.Value.ServerVersion, 10, 0).Item2;
 | 
			
		||||
                        }
 | 
			
		||||
                        catch
 | 
			
		||||
                        {
 | 
			
		||||
@@ -148,7 +148,7 @@ namespace FreeSql.Custom.PostgreSQL
 | 
			
		||||
            using (var conn = _orm.Ado.MasterPool.Get(TimeSpan.FromSeconds(5)))
 | 
			
		||||
            {
 | 
			
		||||
                olddatabase = conn.Value.Database;
 | 
			
		||||
                is96 = PgVersionIs(conn.Value.ServerVersion, 9, 6);
 | 
			
		||||
                is96 = ParsePgVersion(conn.Value.ServerVersion, 9, 6).Item1;
 | 
			
		||||
            }
 | 
			
		||||
            string[] tbname = null;
 | 
			
		||||
            string[] dbs = database == null || database.Any() == false ? new[] { olddatabase } : database;
 | 
			
		||||
@@ -542,13 +542,23 @@ where a.typtype = 'e' and ns.nspname in (SELECT ""schema_name"" FROM information
 | 
			
		||||
            return ret.Select(a => new DbEnumInfo { Name = a.Key, Labels = a.Value }).ToList();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static bool PgVersionIs(string serverVersion, int version1, int version2 = 0)
 | 
			
		||||
        public static NativeTuple<bool, int, int> ParsePgVersion(string versionString, int v1, int v2)
 | 
			
		||||
        {
 | 
			
		||||
            int[] version = serverVersion.Split('.').Select(a => int.TryParse(a, out var tryint) ? tryint : 0).ToArray();
 | 
			
		||||
            if (version?.Any() != true) return true;
 | 
			
		||||
            if (version[0] > version1) return true;
 | 
			
		||||
            if (version[0] == version1 && version.Length > 1 && version[1] >= version2) return true;
 | 
			
		||||
            return false;
 | 
			
		||||
            int[] version = new int[] { 0, 0 };
 | 
			
		||||
            var vmatch = Regex.Match(versionString, @"(\d+)\.(\d+)");
 | 
			
		||||
            if (vmatch.Success)
 | 
			
		||||
            {
 | 
			
		||||
                version[0] = int.Parse(vmatch.Groups[1].Value);
 | 
			
		||||
                version[1] = int.Parse(vmatch.Groups[2].Value);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                vmatch = Regex.Match(versionString, @"(\d+)");
 | 
			
		||||
                version[0] = int.Parse(vmatch.Groups[1].Value);
 | 
			
		||||
            }
 | 
			
		||||
            if (version[0] > v1) return NativeTuple.Create(true, version[0], version[1]);
 | 
			
		||||
            if (version[0] == v1 && version[1] >= v2) return NativeTuple.Create(true, version[0], version[1]);
 | 
			
		||||
            return NativeTuple.Create(false, version[0], version[1]);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user