mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	- 解决 表名名称包含点,无法进行 CRUD 的问题,由于测试的复杂性,此类情况仅支持 MySql/Sqlite CodeFirst 自动迁移;
> 注意:尽量不要使用带点的表名,只有 MySql/Sqlite 对此类表名支持 CodeFirst。但是它不影响 CRUD 功能,使用 [Table(Name = "`sys.config`")] 解决
This commit is contained in:
		@@ -1,19 +1,17 @@
 | 
			
		||||
using FreeSql.Internal;
 | 
			
		||||
using FreeSql.Internal.Model;
 | 
			
		||||
using Newtonsoft.Json.Linq;
 | 
			
		||||
using Npgsql;
 | 
			
		||||
using Npgsql.LegacyPostgis;
 | 
			
		||||
using NpgsqlTypes;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Collections.Concurrent;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Data.Common;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Net;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
using FreeSql.Internal.Model;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.PostgreSQL
 | 
			
		||||
{
 | 
			
		||||
@@ -120,12 +118,18 @@ namespace FreeSql.PostgreSQL
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
        public override string FormatSql(string sql, params object[] args) => sql?.FormatPostgreSQL(args);
 | 
			
		||||
        public override string QuoteSqlName(string name)
 | 
			
		||||
        public override string QuoteSqlName(params string[] name)
 | 
			
		||||
        {
 | 
			
		||||
            var nametrim = name.Trim();
 | 
			
		||||
            if (nametrim.StartsWith("(") && nametrim.EndsWith(")"))
 | 
			
		||||
                return nametrim; //原生SQL
 | 
			
		||||
            return $"\"{nametrim.Trim('"').Replace(".", "\".\"")}\"";
 | 
			
		||||
            if (name.Length == 1)
 | 
			
		||||
            {
 | 
			
		||||
                var nametrim = name[0].Trim();
 | 
			
		||||
                if (nametrim.StartsWith("(") && nametrim.EndsWith(")"))
 | 
			
		||||
                    return nametrim; //原生SQL
 | 
			
		||||
                if (nametrim.StartsWith("\"") && nametrim.EndsWith("\""))
 | 
			
		||||
                    return nametrim;
 | 
			
		||||
                return $"\"{nametrim.Replace(".", "\".\"")}\"";
 | 
			
		||||
            }
 | 
			
		||||
            return $"\"{string.Join("\".\"", name)}\"";
 | 
			
		||||
        }
 | 
			
		||||
        public override string TrimQuoteSqlName(string name)
 | 
			
		||||
        {
 | 
			
		||||
@@ -134,6 +138,7 @@ namespace FreeSql.PostgreSQL
 | 
			
		||||
                return nametrim; //原生SQL
 | 
			
		||||
            return $"{nametrim.Trim('"').Replace("\".\"", ".").Replace(".\"", ".")}";
 | 
			
		||||
        }
 | 
			
		||||
        public override string[] SplitTableName(string name) => GetSplitTableNames(name, '"', '"', 2);
 | 
			
		||||
        public override string QuoteParamterName(string name) => $"@{(_orm.CodeFirst.IsSyncStructureToLower ? name.ToLower() : name)}";
 | 
			
		||||
        public override string IsNull(string sql, object value) => $"coalesce({sql}, {value})";
 | 
			
		||||
        public override string StringConcat(string[] objs, Type[] types) => $"{string.Join(" || ", objs)}";
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user