Ross Cooperman
07/08/2022, 8:23 PMRoss Cooperman
07/08/2022, 8:24 PMRoss Cooperman
07/08/2022, 8:25 PM__resolveType()
on a Prisma objectRoss Cooperman
07/08/2022, 8:26 PMRoss Cooperman
07/08/2022, 8:26 PMRoss Cooperman
07/08/2022, 8:27 PMRoss Cooperman
07/08/2022, 8:27 PMRogerio Orioli
07/10/2022, 11:48 AMRogerio Orioli
07/10/2022, 11:50 AMconst prisma = new PrismaClient()
const posts = await prisma.post.findMany({
include : {
user : true
},
orderBy: {
created_at: 'desc',
},
})
Kay Khan
07/11/2022, 10:01 AMMischa
07/12/2022, 5:16 AM__dirname
to find it because it doesn't exist in ESM)Kay Khan
07/12/2022, 10:10 AMgenerator client {
provider = "prisma-client-js"
binaryTargets = ["native", "rhel-openssl-1.0.x"]
}
serverless.ts
package: {
individually: true,
patterns: [
"!node_modules/.prisma/client/libquery_engine-*",
"node_modules/.prisma/client/libquery_engine-rhel-*",
"!node_modules/prisma/libquery_engine-*",
"!node_modules/@prisma/engines/**",
],
},
npx prisma generate && npm install
sls invoke local -f main
✖️ Error: ENOENT: no such file or directory, open ''/.esbuild/.build/node_modules/.prisma/client/schema.prisma'What am i doing wrong here? attempting to follow this example: https://github.com/prisma/prisma-examples/tree/latest/deployment-platforms/aws-lambda • note: i am using the serverless
aws-nodejs-typescirpt
template which uses serverless-esbuild and not serverless-webpackSalvador Lopez Mendoza
07/13/2022, 10:04 PMViktor Demčák
07/14/2022, 9:51 AMYaakov
07/14/2022, 9:08 PMteam_id
in data.team_id for type PersonUpdateInput. Did you mean team
?`
model Person {
id Int @id
first_name String
last_name String
team_id Int?
personData PersonData?
team Team? @relation(fields: [team_id], references: [id])
}
model PersonData {
person_id Int @id
favorite_color String
person Person @relation(fields: [person_id], references: [id])
}
model Team {
id Int @id
name String
people Person[]
}
await prisma.person.update({
where: {
id: 1,
},
data: {
team_id: null,
personData: {
update: {
favorite_color: 'Purple',
},
},
},
});
Ridhwaan Shakeel
07/16/2022, 5:52 PMPrismaClientKnownRequestError:
[0] Invalid `prisma.product.findMany()` invocation in
[0] /app/server/data/index.js:148:37
[0]
[0] 145 }
[0] 146
[0] 147 const getTopProducts = async () => {
[0] → 148 const result = await prisma.product.findMany(
[0] Inconsistent column data: Conversion failed: Value 2847246203 does not fit in an INT column, try migrating the 'revenue' column type to BIGINT
[0] at RequestHandler.handleRequestError (/server/node_modules/@prisma/client/runtime/index.js:49670:13)
[0] at RequestHandler.request (/server/node_modules/@prisma/client/runtime/index.js:49652:12)
[0] at async PrismaClient._request (/server/node_modules/@prisma/client/runtime/index.js:50572:18)
[0] at async getTopProducts (/server/data/index.js:148:18)
[0] at async /server/routes/index.js:142:12 {
[0] code: 'P2023',
[0] clientVersion: '4.0.0',
[0] meta: {
[0] message: "Conversion failed: Value 2847246203 does not fit in an INT column, try migrating the 'revenue' column type to BIGINT"
[0] }
[0] }
always used the Prisma SQLite connector, didn't have this problem before upgrading to version 4.0.0
here is the model
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
previewFeatures = []
}
model Product {
...
revenue Int
...
}
Dhaval Vira
07/17/2022, 2:34 AMSELECT * FROM tableName WHERE id NOT IN (SELECT columnName FROM tableName WHERE (startDateInputFromUser between startDate and endDate) or (endDateInputFromUser between startDate and endDate))
here in WHERE clauses the startDateInputFromUser
& endDateInputFromUser
it's from the User Input & other startDate
& endDate
is the Table Column Name... can anyone help me how I can write this query in the Prisma ORM?Roland Sankara
07/19/2022, 5:45 PMschema.prisma
file?
For example:
Given DEVELOPMENT, TEST, PRODUCTION environments, I would maybe create this kind of logic;
const { DEVELOPMENT, PRODUCTION, LOCAL } = require("./envTypes");
let DB_URL;
switch (process.env.NODE_ENV)
{ case DEVELOPMENT:
DB_URL = process.env.DB_URL_DEV;
break;
case PRODUCTION:
DB_URL = process.env.DB_URL_PROD;
break;
case LOCAL:
DB_URL = process.env.DB_URL_LOC;
break;
default:
DB_URL = process.env.DB_URL;
}
Renaud Chaput
07/20/2022, 8:38 AM@prisma/client
? I enabled the previewFeatures
flag and see request
spans, but they dont include any attributesKay Khan
07/20/2022, 3:24 PMimport { PrismaClient } from "@prisma/client";
import { mockDeep, mockReset, DeepMockProxy } from "jest-mock-extended";
import { PrismaService } from "@services/prisma.service";
jest.mock("@services/prisma.service", () => ({
__esModule: true,
PrismaService: mockDeep<PrismaClient>(),
}));
beforeEach(() => {
mockReset(PrismaMock);
});
export const PrismaMock = PrismaService as unknown as DeepMockProxy<PrismaClient>;
and then in my test i am using it... However its still connecting to the live (local) db.
PrismaMock.nft_collection.create.mockResolvedValueOnce({});
const [response, error] = await CreateCollection(payload);
Not sure whats going on, why Prisma is not being mocked?Matt Mueller (Prisma Client PM)
Eric Tsang
07/30/2022, 7:39 AMPair
being a unique pair of Tokens
— so far my schema is:
model Token {
id Int @id @default(autoincrement())
chainId Int
address String
name String
@@unique([chainId, name])
}
model Pair {
id Int @id @default(autoincrement())
chainId Int
name String
token0Id Int
token1Id Int
@@unique([chainId, name])
}
Any hints on how to do this?Eric Tsang
07/30/2022, 7:40 AMLarry Mickie
07/30/2022, 5:21 PMmodel Item {
id String @id @default(uuid())
relatedItemsId String[]
relatedItems Item[] @relation("RelatedItems", fields: [relatedItemsId], references: [id])
}
But it throwing and error in my schema file.Leo
07/30/2022, 8:49 PMMischa
08/01/2022, 6:22 PM[test:*backend] Invalid `prisma.$queryRaw()` invocation:
[test:*backend]
[test:*backend]
[test:*backend] Raw query failed. Code: `22P03`. Message: `db error: ERROR: incorrect binary data format in bind parameter 1`
[test:*backend] ❯ RequestHandler.handleRequestError node_modules/@prisma/client/runtime/index.js:49670:13
[test:*backend] ❯ RequestHandler.request node_modules/@prisma/client/runtime/index.js:49652:12
[test:*backend] ❯ Proxy._request node_modules/@prisma/client/runtime/index.js:50572:18
[test:*backend] ❯ EmailCandidateSentRepository.getUnsentEmails packages/service/src/repo/repository/emailCandidateSent.ts:89:17
[test:*backend] 87| ${userId ? sql` AND "userId"=${userId}::uuid` : Prisma.empty}
[test:*backend] 88| `
[test:*backend] 89| const rows = await prisma.c.$queryRaw<{ id: string }[]>`
[test:*backend] | ^
[test:*backend] 90| SELECT id FROM "EmailCandidateSent"
[test:*backend] 91| WHERE ${whereFilters}
Casey Chow
07/30/2022, 6:29 PMJeremy Hinegardner
08/04/2022, 4:09 PMheroku_ext
namespace, and can only be installed in the heroku_ext
namespace. Our application uses a custom schema mobile
in our datasource definition schema=mobile
in data source url as per Postgresql connection documentation in prisma.
The problem is that because we are using a custom schema, it looks like the Quaint db driver fully clobbers the search_path
to just set search_path = mobile
which makes our migrations fail when looking for installed extensions. A short form of the fully failing migration is:
And then this is our output:
Prisma schema loaded from db/schema.prisma
Datasource "db": PostgreSQL database "d3o13esjuu8i9a", schema "mobile" at "<http://ec2-3-222-74-92.compute-1.amazonaws.com:5432|ec2-3-222-74-92.compute-1.amazonaws.com:5432>"
18 migrations found in prisma/migrations
Applying migration `20220323211357_create_mobile_schema` // this is CREATE SCHEMA IF NOT EXISTS mobile;
Applying migration `20220323223149_enable_extensions` // this contains CREATE EXTENSION IF NOT EXISTS "citext" - and succeeds
Applying migration `20220324172504_create_users`
Error: P3018
A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: <https://pris.ly/d/migrate-resolve>
Migration name: 20220324172504_create_users
Database error code: 42704
Database error:
ERROR: type "citext" does not exist // I'm guess this is because the citext extension is now in the `heroku_ext` namespace which is not in the search_path
Position:
0
1 -- CreateTable
2 CREATE TABLE "users" (
3 "id" UUID NOT NULL DEFAULT gen_random_uuid(),
4 "email" CITEXT NOT NULL,
DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42704), message: "type \"citext\" does not exist", detail: None, hint: None, position: Some(Original(101)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("parse_type.c"), line: Some(270), routine: Some("typenameType") }
I'm pretty sure that is because at the time that the create table is happening, the search path is only mobile
and not mobile, heroku_ext
Is this the right forum to post this or should I be posting this to the GitHub Issues for prisma, or to the prisma-engines repos?Kay Khan
08/05/2022, 2:03 PMJames A
08/08/2022, 1:40 PMError: Not Found <https://binaries.prisma.sh/all_commits/369b3694b7edb869fad14827a33ad3f3f49bbc20/debian-openssl-3.0.x/query-engine.gz>
Whenever it tries to run npx prisma generate
as part of my build script. I have tried installing the cli globally on heroku still i get same error. Anyone encountered this before? please how do i resolve it? Thanks