Kanav Raina
02/24/2022, 11:34 AMAlex Masinde
02/24/2022, 11:45 AMhj yuiyui
02/24/2022, 1:03 PMexport async function getUserEventsQuery(website_id, start_at, end_at, day, monthClean, weekClean, yearClean) {
return runQuery(
prisma.$queryRaw`
SELECT g.groupevent_id, g.groupevent_name, g.objectif, g.periode_objectif, g.event_type, g.event_value, COUNT(e.groupevent_id) AS resultat,
CASE g.periode_objectif
WHEN 'Jour' THEN ((COUNT(e.groupevent_id) / ${day}) * 100 /g.objectif)
WHEN 'Mois' THEN ((COUNT(e.groupevent_id) /${monthClean}) *100/g.objectif)
WHEN 'Semaine' THEN ((COUNT(e.groupevent_id) /${weekClean}) *100/g.objectif)
WHEN 'Année' THEN ((COUNT(e.groupevent_id) /${yearClean}) *100/g.objectif)
END as rate
FROM groupevent as g
LEFT JOIN event e
ON g.groupevent_id = e.groupevent_id
AND e.created_at between ${start_at} AND ${end_at}
WHERE g.website_id=${website_id}
GROUP by g.groupevent_id
ORDER BY resultat DESC ;
`,
);
and it returns me Invalid prisma.queryRaw()
invocation: Raw query failed. Code: 22P03
. Message: db error: ERROR: incorrect binary data format in bind parameter 2
what does it means ? dayClean, monthClean are defined h`ere const numberOfDays = endDate - startDate`
const day = Math.ceil(numberOfDays / 86400000)
const week = numberOfDays / 604800000
const weekClean = parseFloat(week.toFixed(3))
const month = numberOfDays / 2592000000
const monthClean = parseFloat(month.toFixed(3))
const year = numberOfDays / 31556952000
const yearClean = parseFloat(year.toFixed(3))
const events = await getUserEventsQuery(parseInt(website_id), startDate, endDate, day, weekClean, monthClean, yearClean);
I'm stuck hard for like 2h on this shit, i dont see why its incorrect data (monthClean etc are type number)Torrino
02/24/2022, 1:47 PMdeleteMany()
Alfred Noland
02/24/2022, 3:15 PMAlfred Noland
02/24/2022, 4:15 PMdevon lo
02/24/2022, 4:30 PMJonas Rothmann
02/24/2022, 4:46 PMEthan Cohen
02/24/2022, 7:43 PMTyler Clendenin
02/24/2022, 7:51 PMPanMan
02/24/2022, 10:02 PMConversion from collation utf8_general_ci into utf8mb4_general_ci impossible for parameter
- I imported and exported the db (migrated to a new host). I’m not explicitly setting the charset anywhere, nor can I in Prisma, right?PanMan
02/24/2022, 10:05 PMVyrek XD
02/24/2022, 10:14 PMPanMan
02/24/2022, 11:28 PMBoo
02/25/2022, 1:38 AMtrue
first and then false
lastStephen Jensen
02/25/2022, 2:05 AM@@map(users)
from the model User
which will change the database table from users
to User
. When I run the migration it is saying that it will drop the user's database which I don't want to do 🙂Marvin
02/25/2022, 11:52 AMhj yuiyui
02/25/2022, 12:38 PMhj yuiyui
02/25/2022, 12:39 PMexport async function getUserEventsQuery(
website_id,
start_at,
end_at,
day,
monthClean,
weekClean,
yearClean,
) {
console.log(typeof monthClean);
return runQuery(
prisma.$queryRaw`
SELECT g.groupevent_id, g.groupevent_name, g.objectif, g.periode_objectif, g.event_type, g.event_value, COUNT(e.groupevent_id) AS resultat,
CASE g.periode_objectif
WHEN 'Jour' THEN((COUNT(e.groupevent_id) / ${day}) * 100 / g.objectif)
WHEN 'Mois' THEN((COUNT(e.groupevent_id) / ${monthClean}) * 100 / g.objectif)
WHEN 'Semaine' THEN((COUNT(e.groupevent_id) / ${weekClean}) * 100 / g.objectif)
WHEN 'Année' THEN((COUNT(e.groupevent_id) / ${yearClean}) * 100 / g.objectif)
END as rate
FROM groupevent as g
LEFT JOIN event e
ON g.groupevent_id = e.groupevent_id
AND e.created_at between ${start_at} AND ${end_at}
WHERE g.website_id=${website_id}
GROUP by g.groupevent_id
ORDER BY resultat DESC ;
`,
);
It doesnt work on prisma.queryRaw because of monthClean, weekClean, yearClean being a float number, i checked on internet and they say it doesnt work on queryRaw, so i need to "the normal way" to see if it works like that tooA. Sauder
02/25/2022, 3:47 PMDev__
02/25/2022, 3:47 PMupsert
a record in the database where the orderId
must not have a value.
.upsert({
create: {
...
},
update: {
...
},
where: {
id,
orderId: undefined
}
})
orderId
is possible undefined
because its an optional relation. how can I say in the where
that is must match an id
and where `orderId`'s value is empty. afaik undefined
means do nothing, but I need it to do somethingCelestine
02/25/2022, 7:06 PMconst result = await this.prisma.$queryRaw<
Prisma.categorySelect[]
>`CALL catalog_get_categories_for_product(${productId})`;
return result;
The returned result looks like this:
[
{
"f0": 1,
"f1": 1,
"f2": "French"
}
]
What I am expecting:
[
{
"category_id": 1,
"department_id": 1,
"name": "French"
}
]
Does anyone have an idea why the column names are not being returned correctly?Jonathan Marbutt
02/25/2022, 8:32 PMconst users = await prisma.user.findMany({
where: {
posts: {
none: {
views: {
gt: 100,
},
},
every: {
likes: {
lte: 50,
},
},
},
},
})
It generated a pretty bad sql statement that looked something like this (not exact because I using a combination of examples)
SELECT "public"."contact"."id", "public"."contact"."uuid", "public"."contact"."contact_id" "public"."contact"."login_id" FROM "public"."contact" WHERE "public"."contact"."contact_id" IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$40,$41,$42,$43,$44,$45,$46,$47,$48,$49,$50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$60,$61,$62,$63,$64,$65,$66,$67,$68,$69,$70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$80,$81,$82,$83,$84,$85,$86,$87,$88,$89,$90,$91,$92,$93,$94,$95,$96,$97,$98,$99,$100,$101,$102,$103,$104,$105,$106,$107,$108,$109,$110,$111,$112,$113,$114,$115,$116,$117,$118,$119,$120,$121,$122,$123,$124,$125,$126,$127,$128,$129,$130,$131,$132,$133,$134,$135,$136,$137,$138,$139,$140,$141,$142,$143,$144,$145,$146,$147,$148,$149,$150,$151,$152,$153,$154,$155,$156,$157,$158,$159,$160,$161,$162,$163,$164,$165) OFFSET $166
This seems like it would not work for larger applications using Postgres since we have many queries that may have 10k or 50k items that are in the IN
array. Is it recommended to just go straight sql for those type of queries?Marcin Cebula
02/26/2022, 1:30 AMPinkiePie
02/26/2022, 3:49 PMError during invocation: Error: ENOENT: no such file or directory, open '/schema.prisma'
and can see many issues on the GitHub about similar problems.Kelly Copley
02/26/2022, 8:50 PMTrenton K
02/27/2022, 12:07 AMTrenton K
02/27/2022, 12:08 AMIan Ray
02/27/2022, 2:14 AMKelly Copley
02/27/2022, 3:05 PM_count
? Something like _count: { posts: { where: { published: true }}}