diff --git a/lib/relational.js b/lib/relational.js index e5b9f2ce..443420de 100644 --- a/lib/relational.js +++ b/lib/relational.js @@ -42,7 +42,7 @@ if (process.env.NODE_ENV !== 'production') { export { prisma }; export function getDateQuery(field, unit, timezone) { - const db = getDatabase(process.env.DATABASE_URL); + const db = getDatabase(process.env.DATABASE_URL, process.env.DATABASE_TYPE); if (db === POSTGRESQL) { if (timezone) { @@ -63,7 +63,7 @@ export function getDateQuery(field, unit, timezone) { } export function getTimestampInterval(field) { - const db = getDatabase(process.env.DATABASE_URL); + const db = getDatabase(process.env.DATABASE_URL, process.env.DATABASE_TYPE); if (db === POSTGRESQL) { return `floor(extract(epoch from max(${field}) - min(${field})))`; @@ -164,7 +164,7 @@ export async function runQuery(query) { } export async function rawQuery(query, params = []) { - const db = getDatabase(process.env.DATABASE_URL); + const db = getDatabase(process.env.DATABASE_URL, process.env.DATABASE_TYPE); if (db !== POSTGRESQL && db !== MYSQL) { return Promise.reject(new Error('Unknown database.'));