Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

zero-length delimited identifier at or near "" #65

Closed
jimsimon opened this issue Oct 18, 2020 · 3 comments
Closed

zero-length delimited identifier at or near "" #65

jimsimon opened this issue Oct 18, 2020 · 3 comments

Comments

@jimsimon
Copy link

jimsimon commented Oct 18, 2020

Hello!

I'm running into an issue actually using the tenant client. I've successfully set up the management database, added a tenant, and verified that I can connect to that tenant directly via the normal PrismaClient. However when I try to use MultiTenant, I get the following error:

zf [Error]: 
Invalid `prisma.tenant.findOne()` invocation:


  Error in connector: Error querying the database: db error: ERROR: zero-length delimited identifier at or near """"
    at $w.request (/usr/src/app/node_modules/.prisma-multi-tenant/management/runtime/index.js:212:257)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  clientVersion: '2.9.0'
}

Here's my test code:

import { MultiTenant } from '@prisma-multi-tenant/client'
import { PrismaClient } from "@prisma/client";

const multiTenant = new MultiTenant<PrismaClient>()

async function main() {
  const prisma = await multiTenant.get('dev')
  const sites = await prisma.site.findMany()

  console.log(sites)
}

main()
  .catch(e => console.error(e))
  .finally(async () => {
    await multiTenant.disconnect()
  })

I'm using the latest version of Prisma (2.9.0) and working with Postgres database. I'm using one database instance but differentiating between tenants via schema in the connection string.

DATABASE_URL=postgresql://postgres@db:5432/app?schema=dev
MANAGEMENT_URL=postgresql://postgres@db:5432/app?schema=public

@jimsimon
Copy link
Author

I believe I found the problem...

I added a console.log(process.env.MANAGEMENT_URL) and it appears the =dev part of the url is being lost. This only seems to be a problem for the management environment variable. Since I'm using the default schema, I'm able to workaround this issue by removing the entire ?schema=public part.

@jimsimon
Copy link
Author

After doing some more research, I suspect this might be related to being unable to use quotes for the management url (#60). It might also be related to how the url is being read or parsed somewhere in the code.

@Errorname
Copy link
Owner

Hi @jimsimon! Thanks for reporting the issue. 🙏 It may indeed come from #60 which has been resolved with the release of prisma-multi-tenant 2.4.1. Don't hesitate to reopen if you still encounter the issue after upgrading!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants