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.

Raw query failed. Code: `42704`. Message: `db error: ERROR: type \"geography\" does not exist`

See original GitHub issue

Bug description

I’m using PostgresQL with the PostGIS extension and have the following Query:

const query = `
SELECT
	id
FROM
	my_project_prisma2."JobLocation"
WHERE
	ST_DWithin(ST_MakePoint(lng, lat)::geography, ST_MakePoint($1, $2)::geography, $3)
`

export const queryLocationsWithinAreaIds = (areaCenter: AreaCenter, ctx: Context) => {
	return ctx.pg.query(query, [areaCenter.lng, areaCenter.lat, areaCenter.radius])
}

As you can see I’m using ctx.pg which is a pg Pool instance. This is working as expected.

Yesterday I upgraded from Prisma 2.0.0-preview021 to 2.1.0 and wanted to use the now available prisma.queryRaw. But when changing to prisma.queryRaw I get the following error:

Raw query failed. Code: `42704`. Message: `db error: ERROR: type \"geography\" does not exist`

How to reproduce

See https://github.com/RafaelKr/prisma-repro-2847

Expected behavior

It should give me a result. The pg client works.

Prisma information

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("POSTGRES_URL")
}

model JobLocation {
  id            String   @default(cuid()) @id
  lat           Float?
  lng           Float?
}

POSTGRES_URL=postgresql://my_project:prisma2@127.0.0.1:5432/my_project?schema=my_project_prisma2

Environment & setup

  • OS: Linux Mint 19.2 Cinnamon
  • Database: PostgreSQL + PostGIS extension
  • Node.js version: 13.7.0
  • Prisma version:
@prisma/cli          : 2.1.0
Current platform     : debian-openssl-1.1.x
Query Engine         : query-engine 4440772035795a0424be62040e2295c56e5c6ad0 (at /home/rafael/[...]/node_modules/@prisma/cli/query-engine-debian-openssl-1.1.x)
Migration Engine     : migration-engine-cli 4440772035795a0424be62040e2295c56e5c6ad0 (at /home/rafael/[...]/node_modules/@prisma/cli/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core 4440772035795a0424be62040e2295c56e5c6ad0 (at /home/rafael/[...]/node_modules/@prisma/cli/introspection-engine-debian-openssl-1.1.x)
Format Binary        : prisma-fmt 4440772035795a0424be62040e2295c56e5c6ad0 (at /home/rafael/[...]/node_modules/@prisma/cli/prisma-fmt-debian-openssl-1.1.x)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:7
  • Comments:20 (13 by maintainers)

github_iconTop GitHub Comments

3reactions
pimeyscommented, Sep 15, 2022

I’m anyhow changing the whole SQL backend right now to SQLx, so this needs to wait a bit. Might need some support in SQLx too, let’s see…

2reactions
RafaelKrcommented, Jun 29, 2020

I’ve created a minimal reproduction: https://github.com/RafaelKr/prisma-repro-2847

Instructions can be found in the README. @janpio @pantharshit00

Read more comments on GitHub >

github_iconTop Results From Across the Web

PostGIS Error: type "geography" does not exist - Stack Overflow
I created a database using the template_postgis and the application that I am currently developing was able to connect to the database with...
Read more >
Unable to migrate table using point datatype in postgres ?
While migrating I am getting below error. Illuminate\Database\QueryException : SQLSTATE[42704]: Undefined object: 7 ERROR: type "geography" does not exist ...
Read more >
PostGIS Error: type "geography" does not exist
I created a database using the template_postgis and the application that I am currently developing was able to connect to the database with...
Read more >
type “geography” does not exist" when using psql-postgresql
Coding example for the question "PostGIS Error: type “geography” does not exist" when using psql-postgresql.
Read more >
PostGIS 3.1.5 Manual - Crunchy Data
2.4.2 Tiger Geocoder Enabling your PostGIS database: Not Using Extensions . ... When to use Geography Data type over Geometry data type ....
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