Skip to content

Commit

Permalink
test(driver-adapters) search-path in tests for neon and pg (#4352)
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Fernández authored Oct 12, 2023
1 parent 7c57bf8 commit 8cae889
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,17 @@ async function adapterFromEnv(url: string): Promise<DriverAdapter> {
return await SUPPORTED_ADAPTERS[adapter](url)
}

function postgres_options(url: string): any {
let args: any = {connectionString: url}
const schemaName = new URL(url).searchParams.get('schema')
if (schemaName != null) {
args.options = `--search_path="${schemaName}"`
}
return args;
}

async function pgAdapter(url: string): Promise<DriverAdapter> {
const pool = new pgDriver.Pool({connectionString: url})
const pool = new pgDriver.Pool(postgres_options(url))
return new prismaPg.PrismaPg(pool)
}

Expand All @@ -251,7 +260,7 @@ async function neonWsAdapter(url: string): Promise<DriverAdapter> {
neonConfig.useSecureWebSocket = false
neonConfig.pipelineConnect = false

const pool = new NeonPool({ connectionString: url })
const pool = new NeonPool(postgres_options(url))
return new prismaNeon.PrismaNeon(pool)
}

Expand Down

0 comments on commit 8cae889

Please sign in to comment.