The problem about use Prisma with Heroku Connect.
See original GitHub issueDescription
We cannot update rows when we use Heroku Connect.
Because Prisma sets a search_path
only salesforce
.
When we update tables are controlled by Heroku Connect in salesforce schema, a search_path
should be set salesforce
and public
.
How to reproduce
Expected behavior
When we update tables are controlled by Heroku Connect in salesforce schema, a search_path
is set salesforce
and public
. For example, if we set up a search_path
from a DB client, Prisma doesn’t rewrite search_path
and give priority to settings by a DB client. Or we can define a search_path
in schema.prisma
.
Prisma information
We have schema.prisma
file each DB schemas.
schema.prisma
is ordinary.
public
// Prisma Schema API Reference
// https://www.prisma.io/docs/reference/api_reference/prisma-schema-reference
generator client {
provider = "prisma-client-js"
output = "../src/models/public"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL_WITH_PUBLIC")
}
/// Sample
model PageConfig {
id Int @id @default(autoincrement())
title String @unique
memo String?
@@map(name: "page_config")
}
salesforce
// Prisma Schema API Reference
// https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference
generator client {
provider = "prisma-client-js"
output = "../../src/models/salesforce"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL_WITH_SALESFORCE")
}
/// Sample
model Example {
id Int @id @default(autoincrement())
name String @unique @db.VarChar(80)
url String?
created_at DateTime @default(now()) @db.Timestamp(6)
last_modified_at DateTime @default(now()) @db.Timestamp(6)
@@map(name: "example")
}
.env
NODE_ENV=development
DATABASE_URL=YOUR HEROKU POSTGRES'S URL
DATABASE_SCHEMA_PUBLIC=?schema=public
DATABASE_SCHEMA_SALESFORCE=?schema=salesforce
DATABASE_URL_WITH_PUBLIC=${DATABASE_URL}${DATABASE_SCHEMA_PUBLIC}
DATABASE_URL_WITH_SALESFORCE=${DATABASE_URL}${DATABASE_SCHEMA_SALESFORCE}
Environment & setup
- Heroku
- Dyno
- Standard-1X
- Stack
- heroku-20
- Buildpack
- heroku/nodejs
- Dyno
- Postgre SQL
- Version 13.3
If you want to create Heroku App with Heroku Connect, please try this Salesforce Trailhead.
We designed two schemas, public and salesforce.
Tables synced Salesforce objects by Heroku Connect are involved in salesforce schema.
We create schema.prisma
and prisma client in unit of a schema.
Prisma Version
~ $ yarn prisma --version
yarn run v1.22.10
$ /app/node_modules/.bin/prisma --version
prisma : 2.21.2
@prisma/client : 2.21.2
Current platform : debian-openssl-1.1.x
Query Engine : query-engine e421996c87d5f3c8f7eeadd502d4ad402c89464d (at node_modules/@prisma/engines/query-engine-debian-openssl-1.1.x)
Migration Engine : migration-engine-cli e421996c87d5f3c8f7eeadd502d4ad402c89464d (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core e421996c87d5f3c8f7eeadd502d4ad402c89464d (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary : prisma-fmt e421996c87d5f3c8f7eeadd502d4ad402c89464d (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash : e421996c87d5f3c8f7eeadd502d4ad402c89464d
Studio : 0.371.0
Done in 0.70s.
Discussed in https://github.com/prisma/prisma/discussions/7709
<div type='discussions-op-text'>Originally posted by takuma-katanosaka-flect June 17, 2021 Hello there,
I have used prisma since a month ago. My environment is Heroku and I attach Heroku Postgres and Heroku Connect Add-on.
Today, I executed update function to a table in salesforce schema. I expected it succeeded because I got success in my local environment. But it failed. The error log is the line below.
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db,
cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("42883"),
message: "function get_xmlbinary() does not exist", detail: None,
hint: Some("No function matches the given name and argument types. You might need to add explicit type casts."),
position: Some(Internal { position: 9, query: "SELECT (get_xmlbinary() = \'base64\')" }),
where_: Some("PL/pgSQL function hc_my_table__c_status() line 3 at IF"),
schema: None, table: None, column: None, datatype: None, constraint: None,
file: Some("parse_func.c"), line: Some(620), routine: Some("ParseFuncOrColumn") }) }) })
It seems the reason error happen is using Heroku Connect. How do I resolve “function get_xmlbinary() does not exist” errors in Heroku Connect?
I have doubts about it. I’ve already configured “public” and “salesforce” about “search_path” with DB client. I executed $queryRaw in order to check about “search_path” after instantiate Prisma Client. The result is the line below.
[ { search_path: 'salesforce' } ]
I would like to ask a question for there. As Prisma, how do I set up the “search_path” for Prisma Client?
</div>Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Just wanted to chime in on this because I’m currently working on a similar setup. When adding Heroku Connect you can specify the schema. I personally set it to public after reading this thread and I’m able to do CRUD on my database using Prisma. Not sure what the implications of this setup are yet but so far it’s working for me.
@janpio Sorry to be late my reply. I added
schema.prisma
files and.env
. But DDL is sample because includes business information.