"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getJsonColumnType = getJsonColumnType;
exports.isUniqueConstraintViolation = isUniqueConstraintViolation;
function getJsonColumnType(dataSource) {
    const driver = dataSource.driver;
    return driver.options.type === 'sqlite' ? 'simple-json' : 'jsonb';
}
function isUniqueConstraintViolation(err) {
    if (!err || typeof err !== 'object')
        return false;
    const e = err;
    const code = e.code ?? e.driverError?.code;
    const errno = e.driverError?.errno;
    if (code === '23505' || code === 'ER_DUP_ENTRY' || Number(errno) === 1062)
        return true;
    const msg = String(e.message ?? '').toLowerCase();
    return msg.includes('unique constraint') || msg.includes('duplicate key');
}
//# sourceMappingURL=database.utils.js.map