001/*
002 *  Copyright (c) 2022-2025, Mybatis-Flex (fuhai999@gmail.com).
003 *  <p>
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *  <p>
008 *  http://www.apache.org/licenses/LICENSE-2.0
009 *  <p>
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package com.mybatisflex.core.query;
017
018
019import com.mybatisflex.core.dialect.IDialect;
020import com.mybatisflex.core.util.SqlUtil;
021
022import java.util.List;
023
024/**
025 * 原生排序字段。
026 *
027 * @author michael
028 * @author 王帅
029 */
030public class RawQueryOrderBy extends QueryOrderBy {
031
032    protected String content;
033
034    public RawQueryOrderBy(String content) {
035        this(content, true);
036    }
037
038    public RawQueryOrderBy(String content, boolean checkSafe) {
039        if (checkSafe) {
040            SqlUtil.keepOrderBySqlSafely(content);
041        }
042        this.content = content;
043    }
044
045    @Override
046    public String toSql(List<QueryTable> queryTables, IDialect dialect) {
047        return content;
048    }
049
050    @Override
051    public String toString() {
052        return "RawQueryOrderBy{" +
053            "content='" + content + '\'' +
054            '}';
055    }
056
057    public String getContent() {
058        return content;
059    }
060
061    @Override
062    public RawQueryOrderBy clone() {
063        return (RawQueryOrderBy) super.clone();
064    }
065
066}