package tech.easyflow.datacenter.connector.dialect;

import cn.hutool.core.util.StrUtil;
import tech.easyflow.datacenter.connector.SqlDialect;

public class OracleSqlDialect implements SqlDialect {
    @Override
    public String quoteIdentifier(String identifier) {
        return '"' + identifier + '"';
    }

    @Override
    public String qualifyTable(String namespace, String tableName) {
        if (StrUtil.isBlank(namespace)) {
            return quoteIdentifier(tableName);
        }
        return quoteIdentifier(namespace) + "." + quoteIdentifier(tableName);
    }

    @Override
    public String buildPageSql(String baseSql, long pageNumber, long pageSize) {
        return baseSql + " OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
    }
}
