Skip to content

Disallow passing a string as a path in Postgres #7136

Closed

Description

@matthewmueller

Bug description

From @Weakky

One of the reason why I think we shouldn’t allow a string to be passed is that it can be misinterpreted as a support for JSON path. The reason postgres does not accept a string is because it does NOT support JSON path.
With Postgres, if you want to target a “deep” property, you need to do: path: ["a", "b"]. The equivalent on MySQL is "path": "$.a.b" (because MySQL does support JSON path)

How to reproduce

Follow the example in the release notes for 2.23.0 and then write

const posts = await prisma.post.findMany({
    where: {
      content: {
        path: "type",
      },
    },
  })

Expected behavior

  • Postgres: path: string[]
  • MySQL: path: string

Prisma information

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

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

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["filterJson"]
}

model Log {
  id      Int    @id @default(autoincrement())
  level   Level
  message String
  meta    Json
}

enum Level {
  INFO
  WARN
  ERROR
}

Environment & setup

  • OS: OSX
  • Database: Postgres

Prisma Version

prisma               : 2.23.0-dev.41
@prisma/client       : 2.23.0-dev.41
Current platform     : darwin
Query Engine         : query-engine adf5e8cba3daf12d456d911d72b6e9418681b28b (at node_modules/@prisma/engines/query-engine-darwin)
Migration Engine     : migration-engine-cli adf5e8cba3daf12d456d911d72b6e9418681b28b (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core adf5e8cba3daf12d456d911d72b6e9418681b28b (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary        : prisma-fmt adf5e8cba3daf12d456d911d72b6e9418681b28b (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : adf5e8cba3daf12d456d911d72b6e9418681b28b
Studio               : 0.393.0
Preview Features     : filterJson

Activity

  1. added
    kind/bug
    topic: previewFeatures
    bug/1-unconfirmed
    bug/2-confirmed
    and removed
    bug/1-unconfirmed
    on May 18, 2021
  2. added this to the 2.24.0 milestone on May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug/2-confirmedkind/bugtopic: filterJsontopic: previewFeatures

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions