namespace ThingsGateway.SqlSugar
{
    public class MySqlBuilder : SqlBuilderProvider
    {
        public override string SqlTranslationLeft { get { return "`"; } }
        public override string SqlTranslationRight { get { return "`"; } }
        public override string SqlDateNow
        {
            get
            {
                return "NOW(6)";
            }
        }
        public override string FullSqlDateNow
        {
            get
            {
                return "select NOW(6)";
            }
        }
        public override string GetUnionFomatSql(string sql)
        {
            return " ( " + sql + " )  ";
        }

        public override string RemoveParentheses(string sql)
        {
            if (sql.Contains(" ORDER BY") && sql.StartsWith('(') && sql.EndsWith(')') && !sql.Contains("limit", StringComparison.CurrentCultureIgnoreCase))
            {
                sql = $" {sql.TrimEnd(')')} limit 0,{int.MaxValue}) ";
            }
            return sql;
        }
    }
}
