question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The problem about use Prisma with Heroku Connect.

See original GitHub issue

Description

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
  • 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:open
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cfloacommented, Apr 18, 2022

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.

1reaction
takuma-katanosaka-flectcommented, Jun 28, 2021

@janpio Sorry to be late my reply. I added schema.prisma files and .env. But DDL is sample because includes business information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deploy a Prisma app to Heroku
Learn how to deploy a Node.js server that uses Prisma to Heroku. ... This has several benefits due to the connection limits of...
Read more >
can not access Heroku Postgres's data using herokuCli
I have setted up a Heroku Postgres app and did connect it (via docker) using prisma init. All is fine, i can connect...
Read more >
Prisma and Heroku - YouTube
I discuss some of the problems when deploying Prisma to Heroku. Heroku cli: https://devcenter. heroku.com/articles/ heroku -cli----Patreon: ...
Read more >
Deploying a PlanetScale, Next.js & Prisma App to Vercel
In this article, we'll go over how to create a brand new Next.js Prisma application, connect it to PlanetScale using their newly released ......
Read more >
SQLite on Heroku
A guide to SQLite on Heroku - explaining why using SQLite on Heroku's ... covers how to connect to it through the Ruby...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found