"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DialectAdapter = void 0;
const core_1 = require("@midwayjs/core");
const MySQLDialect_1 = require("./MySQLDialect");
const SqliteDialect_1 = require("./SqliteDialect");
class DialectAdapter {
    static add(dialect) {
        DialectAdapter.dialectList.push(dialect);
    }
    static getDialectFromDataSource(dataSource) {
        const logger = (0, core_1.getCurrentMainApp)().getLogger('magic');
        for (const dialect of this.dialectList) {
            try {
                if (dialect.match(dataSource)) {
                    return dialect;
                }
            }
            catch (e) {
                logger.debug('方言{}匹配失败', dialect, e);
            }
        }
        logger.warn('magic-node在{}中无法获取dialect', dataSource);
        return null;
    }
}
exports.DialectAdapter = DialectAdapter;
DialectAdapter.dialectList = [
    new MySQLDialect_1.MySQLDialect(),
    new SqliteDialect_1.SqliteDialect(),
];
//# sourceMappingURL=DialectAdapter.js.map