Dario
PPrisma
•Created by Dario on 11/11/2024 in #help-and-questions
Issues with raw queries (was working) - Postgres
Hi everyone, I've a very weird issue within my setup, it was working but since the switch from npm to Yarn (but I think is not related) I'm facing this issue with a very simple script:
I'm getting this error:
ORM works fine, wherever I try to use a RAW query, even simplest one, doesn't work, any clue?
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
async function testDatabaseConnection() {
try {
const ormTest = await prisma.pipeline.findFirst();
console.log('ORM query result:', ormTest);
const simpleTest = await prisma.$queryRaw`SELECT 1`;
console.log('Simple query result:', simpleTest);
const parameterizedTest = await prisma.$queryRaw`
SELECT *
FROM "pipeline"
WHERE "experiment_name" = ${'Test'}
LIMIT 1
`;
console.log('Parameterized query result:', parameterizedTest);
} catch (e) {
console.error('Error executing query:', e);
}
}
testDatabaseConnection();
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
async function testDatabaseConnection() {
try {
const ormTest = await prisma.pipeline.findFirst();
console.log('ORM query result:', ormTest);
const simpleTest = await prisma.$queryRaw`SELECT 1`;
console.log('Simple query result:', simpleTest);
const parameterizedTest = await prisma.$queryRaw`
SELECT *
FROM "pipeline"
WHERE "experiment_name" = ${'Test'}
LIMIT 1
`;
console.log('Parameterized query result:', parameterizedTest);
} catch (e) {
console.error('Error executing query:', e);
}
}
testDatabaseConnection();
ORM query result: {
...
}
Error executing query: TypeError: Cannot read properties of undefined (reading 'length')
at xm (/app/node_modules/@prisma/client/runtime/library.js:121:5004)
at _l (/app/node_modules/@prisma/client/runtime/library.js:121:4810)
at $n.unpack (/app/node_modules/@prisma/client/runtime/library.js:121:8042)
at $n.mapQueryEngineResult (/app/node_modules/@prisma/client/runtime/library.js:121:6509)
at Object.singleLoader (/app/node_modules/@prisma/client/runtime/library.js:121:5927)
at async $n.request (/app/node_modules/@prisma/client/runtime/library.js:121:6194)
at async l (/app/node_modules/@prisma/client/runtime/library.js:130:9633)
at async testDatabaseConnection (/app/testDb.js:11:24) {
clientVersion: '5.22.0'
}
ORM query result: {
...
}
Error executing query: TypeError: Cannot read properties of undefined (reading 'length')
at xm (/app/node_modules/@prisma/client/runtime/library.js:121:5004)
at _l (/app/node_modules/@prisma/client/runtime/library.js:121:4810)
at $n.unpack (/app/node_modules/@prisma/client/runtime/library.js:121:8042)
at $n.mapQueryEngineResult (/app/node_modules/@prisma/client/runtime/library.js:121:6509)
at Object.singleLoader (/app/node_modules/@prisma/client/runtime/library.js:121:5927)
at async $n.request (/app/node_modules/@prisma/client/runtime/library.js:121:6194)
at async l (/app/node_modules/@prisma/client/runtime/library.js:130:9633)
at async testDatabaseConnection (/app/testDb.js:11:24) {
clientVersion: '5.22.0'
}
4 replies