Pascal Sthamer
08/19/2022, 3:49 PMError querying the database: Server error: `ERROR 08S01 (1043): Bad handshake'I am unable to write a bug report right now, so just dropping a quick warning here, before you upgrade your mysql server.
Jacob Coker-Dukowitz
08/19/2022, 11:14 PMprisma.$queryRaw`BEGIN`
prisma.$queryRaw`pg_advisory_xact_lock(5)`
// code, processing
prisma.$queryRaw`pg_advisory_xact_unlock(5)`
prisma.$queryRaw`COMMIT`
Yann Buydens
08/23/2022, 6:44 AMprisma.concept.findMany({
where: {
dictionaryId: Number(dictId),
name: {contains: foo}
},
include: {
_count: {
select: {
declarations: true, // including this in the query makes it super slow
},
},
}
})
I have a concept table and a declaration table. Concept and declaration have a many to many relationship. The declaration table has more than 500k rows, same goes for concept table.
longer explanation: https://www.loom.com/share/ff8d3034898e4ad08b8d19f044d500feFlorian Thelliez
08/24/2022, 11:36 AM$queryRaw()
Example query:
const rows = await this.prismaClient.$queryRaw<
{ id: string; location: string }[]
>(Prisma.sql`
SELECT id, ST_AsGeoJSON(location) as location,
FROM something
WHERE id IN (${Prisma.join(ids)})
`);
I get some type errors I didn’t have in previous versions:
ERROR: operator does not exist: uuid = text
I’ve tried various way to cast my list of ids
to uuids, but to no avail so far.
IN (${Prisma.join(ids)}::uuid[]) IN (${Prisma.join(ids)})::uuid[]
I wouldn’t mind some help there since I might be missing something simple 😅Trey Holterman
08/26/2022, 2:54 PMmodel Report {
id String @id @default(auto()) @map("_id") @db.ObjectId
...
team Team @relation(fields: [teamId], references: [id])
teamId String
...
}
Here’s the Team:
model Team {
id String @id @map("_id")
...
reports Report[]
...
}
I’ve tried creating a number of different ways. I thought the right way was as such:
const report = await prisma.report.create({
data: {
id : newId.toString(),
teamId: teamId,
...
},
});
Which gives error:
"Parse errors: [Query parsing/validation error at Mutation.createOneReport.data.ReportCreateInput.team: A value is required but not set"
Which I interpret to mean it’s missing the ‘team’ object.
So I tried:
const report = await prisma.report.create({
data: {
id : newId.toString(),
...
teamId: teamId,
team: {
connect: {
id: teamId,
},
},
...
},
});
Which errors out telling me I shouldn’t be including team Id. (will include error in thread). But if I don’t invlude teamId it errors out telling me I should be using teamId.
Very confusing since I used to be able to just add teamId in these types of situationsMartin Janeček
08/29/2022, 3:52 PMAustin
08/29/2022, 6:09 PMRich Starkie
08/30/2022, 2:08 PM//schema
model activityLog {
activityLogId String @id @map("_id") @default(uuid())
activityLogType activityLogType @relation(fields: [activityLogTypeId], references: [activityLogType])
activityLogTypeId String @db.ObjectId()
activityLogMessage String @db.String
activityCompleted Boolean @default(false)
createdAt DateTime @default(now()) @db.Timestamp
updatedAt DateTime @default(now()) @db.Timestamp
}
model activityLogType {
activityLogType String @id @map("_id") @db.String
createdAt DateTime @default(now()) @db.Timestamp
updatedAt DateTime @default(now()) @db.Timestamp
activityLog activityLog[]
}
when I try to do
await prisma.activityLog.create({
data: {
activityLogType: {
activityLogType: "Start"
},
activityLogMessage: "Start Seeding",
activityCompleted: true
}
})
The Start
document already exists in the activityLogTypes
collection
it complains that the activityLogType
does not exist schema
I'm probably doing something wrong, and its likely a n00b error for Mongo, but any help would be suggested.James Fox
08/30/2022, 5:31 PMCasey Chow
09/01/2022, 7:11 PMKay Khan
09/05/2022, 2:10 PM/core/prisma/schema.prisma
/lambda/prisma/schema.prisma
Core - This folder contains some core logic and is often "shared" code used by folder lambda
. Lambda folder is a serverless function more on that later.
core/prisma/schema.prisma
model Collection {
id String @id @default(auto()) @map("_id") @db.ObjectId
network String
contract_address String @unique
@@map("collections")
}
The convention for declaring a model here is familiar to the docs. https://www.prisma.io/docs/concepts/components/prisma-schema - Singular with a capital first letter.
core/models/collections.ts
Inside of this file im doing some common functionality like finding, inserting etc. Note: the model name that is being used "collection". Generated by the prisma library based on schema.prisma.
export const FindCollections = async () => {
try {
const contracts = await PrismaService.collection.findMany();
return [contracts, null] as const;
} catch (err) {
Logger.error({ kind: "FindCollections", error: err.name, stack_trace: err.stack });
return [null, err] as const;
}
};
Up until now, there are no problems.
Now lets introduce my lambda. I have this lambda folder which has my serverless function im going to deploy and i want to use "FindCollections" function within the core folder which has already been created.
However in my lambda folder, i need to introspect the database and package the engine. but when i introspect the database the model name becomes a problem.
lambda/prisma/prisma.schema
model collections {
id String @id @default(auto()) @map("_id") @db.ObjectId
contract_address String
...
}
You can now see its all lowercase with plural. Now with this introspected schema, my existing "FindCollections" function no longer works, because the model name is different.
InsertCollections","stack_trace":"Error: Could not find mapping for model Collection\nWhat is the suggestion for this usecase? There are 2 solutions i can think of but im wondering what you guys think.
Niv Oppenhaim
09/07/2022, 9:16 AMMike Willbanks
09/07/2022, 7:54 PMinternals
dist
folder 😕Harshit
09/08/2022, 9:14 AMMike Willbanks
09/08/2022, 3:46 PMKay Khan
09/09/2022, 8:03 AM16 try {
17 const response = await PrismaService.$transaction(
18 payload.map((p) =>
→ 19 PrismaService.salesByContractAddress.upsert(
Error parsing GraphQL query: query parse error: Parse error at 23:14
number too large to fit in target type
is there some way i can determine which field in the schema is the problem?Kay Khan
09/09/2022, 9:28 AMDecimal128
?bitsofinfo
09/09/2022, 4:59 PMasync update(updatedBy:Principal, data: Prisma.BlogUpdateInput): Promise<BlogEntry> {
data.updatedBy = updateBy.principalId;
return await this.prisma.blogEntry.update({
where: {
id: data.id
},
data: data
});
}
but this yields me an syntax error stating:
Type 'string | StringFieldUpdateOperationsInput' is not assignable to type 'string'.
Type 'StringFieldUpdateOperationsInput' is not assignable to type 'string'.ts(2322)
index.d.ts(4311, 5): The expected type comes from property 'id' which is declared here on type 'BlogEntryWhereUniqueInput'
BlogUpdateInput.id is just a string... what "generated" type should I be using to on my update()
method that wraps the call to prisma? This is a bit confusingOfir Cohen
09/09/2022, 8:55 PMnpx prisma generate
to Git, or should I run this command as part of my prestart
step in npm
?
Context: I am deploying my web app in an air-gapped system and the npx prisma generate
tried to fetch some files from an online URL and failed miserably. Now I’m debating between:
1. Runing npx prisma generate
as part of the Docker build - to online fetch the auto-generated files
2. Checking-in the prisma client to GitOfir Cohen
09/09/2022, 11:30 PMnpx prisma generate
on npm run dev
?Ofir Cohen
09/10/2022, 12:35 AMnpx prisma generate
as part of the Docker build step and have it cached as a side effect.Mattèo Gauthier
09/13/2022, 10:40 AMAshe Magalhaes
09/14/2022, 11:30 PMprisma.$queryRaw
Something like this, which works fine on my planetscale console:
const query = `select ROW_NUMBER() over() FROM contacts`;
Results in the error:
Code: `1105`. Message: `unknown error: syntax error at position 26`
Anyone know why prisma can't seem to handle ROW_NUMBER()
function?Centux
09/18/2022, 8:13 PMRobert Grimes
09/19/2022, 4:27 AMRox
09/20/2022, 3:20 AMRobert Grimes
09/20/2022, 3:46 AMMike Willbanks
09/20/2022, 8:14 PMRyan Roline
09/21/2022, 10:18 PMVladi Stevanovic
09/23/2022, 10:44 AM