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
025public interface IDialect {
026
027    String wrap(String keyword);
028
029    default String getRealTable(String table) {
030        return TableManager.getRealTable(table);
031    }
032
033    default String getRealSchema(String schema) {
034        return TableManager.getRealSchema(schema);
035    }
036
037    String forHint(String hintString);
038
039    String forInsertRow(String schema, String tableName, Row row);
040
041    String forInsertBatchWithFirstRowColumns(String schema, String tableName, List<Row> rows);
042
043    String forDeleteById(String schema, String tableName, String[] primaryKeys);
044
045    String forDeleteBatchByIds(String schema, String tableName, String[] primaryKeys, Object[] ids);
046
047    String forDeleteByQuery(QueryWrapper queryWrapper);
048
049    String forUpdateById(String schema, String tableName, Row row);
050
051    String forUpdateByQuery(QueryWrapper queryWrapper, Row data);
052
053    String forUpdateBatchById(String schema, String tableName, List<Row> rows);
054
055    String forSelectOneById(String schema, String tableName, String[] primaryKeys, Object[] primaryValues);
056
057    String forSelectByQuery(QueryWrapper queryWrapper);
058
059    String buildSelectSql(QueryWrapper queryWrapper);
060
061    String buildDeleteSql(QueryWrapper queryWrapper);
062
063    String buildWhereConditionSql(QueryWrapper queryWrapper);
064
065
066    //////for entity /////
067    String forInsertEntity(TableInfo tableInfo, Object entity, boolean ignoreNulls);
068
069    String forInsertEntityBatch(TableInfo tableInfo, List<?> entities);
070
071    String forDeleteEntityById(TableInfo tableInfo);
072
073    String forDeleteEntityBatchByIds(TableInfo tableInfo, Object[] primaryValues);
074
075    String forDeleteEntityBatchByQuery(TableInfo tableInfo, QueryWrapper queryWrapper);
076
077    String forUpdateEntity(TableInfo tableInfo, Object entity, boolean ignoreNulls);
078
079    String forUpdateEntityByQuery(TableInfo tableInfo, Object entity, boolean ignoreNulls, QueryWrapper queryWrapper);
080
081    String forUpdateNumberAddByQuery(String schema, String tableName, String fieldName, Number value, QueryWrapper queryWrapper);
082
083    String forSelectOneEntityById(TableInfo tableInfo);
084
085    String forSelectEntityListByIds(TableInfo tableInfo, Object[] primaryValues);
086
087}