001/*
002 *  Copyright (c) 2022-2023, 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.dialect;
017
018import com.mybatisflex.core.query.QueryWrapper;
019import com.mybatisflex.core.row.Row;
020import com.mybatisflex.core.table.TableInfo;
021import com.mybatisflex.core.table.TableManager;
022
023import java.util.List;
024
025/**
026 * @author michael
027 */
028public interface IDialect {
029
030    String wrap(String keyword);
031
032    default String getRealTable(String table) {
033        return TableManager.getRealTable(table);
034    }
035
036    default String getRealSchema(String schema) {
037        return TableManager.getRealSchema(schema);
038    }
039
040    String forHint(String hintString);
041
042    String forInsertRow(String schema, String tableName, Row row);
043
044    String forInsertBatchWithFirstRowColumns(String schema, String tableName, List<Row> rows);
045
046    String forDeleteById(String schema, String tableName, String[] primaryKeys);
047
048    String forDeleteBatchByIds(String schema, String tableName, String[] primaryKeys, Object[] ids);
049
050    String forDeleteByQuery(QueryWrapper queryWrapper);
051
052    String forUpdateById(String schema, String tableName, Row row);
053
054    String forUpdateByQuery(QueryWrapper queryWrapper, Row data);
055
056    String forUpdateBatchById(String schema, String tableName, List<Row> rows);
057
058    String forSelectOneById(String schema, String tableName, String[] primaryKeys, Object[] primaryValues);
059
060    String forSelectByQuery(QueryWrapper queryWrapper);
061
062    String buildSelectSql(QueryWrapper queryWrapper);
063
064    String buildNoSelectSql(QueryWrapper queryWrapper);
065
066    String buildDeleteSql(QueryWrapper queryWrapper);
067
068    String buildWhereConditionSql(QueryWrapper queryWrapper);
069
070
071    //////for entity /////
072    String forInsertEntity(TableInfo tableInfo, Object entity, boolean ignoreNulls);
073
074    String forInsertEntityWithPk(TableInfo tableInfo, Object entity, boolean ignoreNulls);
075
076    String forInsertEntityBatch(TableInfo tableInfo, List<?> entities);
077
078    String forDeleteEntityById(TableInfo tableInfo);
079
080    String forDeleteEntityBatchByIds(TableInfo tableInfo, Object[] primaryValues);
081
082    String forDeleteEntityBatchByQuery(TableInfo tableInfo, QueryWrapper queryWrapper);
083
084    String forUpdateEntity(TableInfo tableInfo, Object entity, boolean ignoreNulls);
085
086    String forUpdateEntityByQuery(TableInfo tableInfo, Object entity, boolean ignoreNulls, QueryWrapper queryWrapper);
087
088    String forSelectOneEntityById(TableInfo tableInfo);
089
090    String forSelectEntityListByIds(TableInfo tableInfo, Object[] primaryValues);
091
092}