Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoDB does not log queries with binary Engine #15084

Closed
janpio opened this issue Aug 30, 2022 · 1 comment · Fixed by prisma/prisma-engines#3310
Closed

MongoDB does not log queries with binary Engine #15084

janpio opened this issue Aug 30, 2022 · 1 comment · Fixed by prisma/prisma-engines#3310
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: binary topic: engine topic: logging topic: mongodb
Milestone

Comments

@janpio
Copy link
Member

janpio commented Aug 30, 2022

import { PrismaClient } from '@prisma/client'

const client = new PrismaClient({
  log: ['query', 'info', 'warn', 'error'],
})

// A `main` function so that we can use async/await
async function main() {
  console.log("deleteMany")
  await client.user.deleteMany({})

  const objectId = '6d795f757365725f69643030'

  console.log("create")
  await client.user.create({
    data: {
      id: objectId,
      email: 'alice@prisma.io',
      name: 'Alice',
    },
  })

  console.log("findUnique")
  const user = await client.user.findUnique({
    where: {
      id: objectId,
    },
  })

  const expect = JSON.stringify({
    id: objectId,
    email: 'alice@prisma.io',
    name: 'Alice',
  })

  if (JSON.stringify(user) !== expect) {
    console.error('expected', expect, 'got', user)
    process.exit(1)
  }

  console.log('success')

  await client.$disconnect()
}

main()
  .catch(async (e) => {
    console.error(e)
    process.exit(1)
  })
  .finally(async () => {
    await client.$disconnect()
  })

Logging via library:

yarn run v1.22.19
warning ../../package.json: No license field
$ ts-node ./script.ts
deleteMany
prisma:query db.User.aggregate([ { $match: { $expr: { }, }, }, { $project: { _id: 1, }, }, ])
prisma:query db.User.aggregate([ { $match: { $expr: { }, }, }, { $project: { _id: 1, }, }, ])
prisma:query db.User.deleteMany({ _id: { $in: [ ObjectId("6d795f757365725f69643030"), ], }, })
create
prisma:query db.User.insertOne({ _id: ObjectId("6d795f757365725f69643030"), email: "alice@prisma.io", name: "Alice", })
prisma:query db.User.aggregate([ { $match: { $expr: { $and: [ { $and: [ { $eq: [ "$_id", ObjectId("6d795f757365725f69643030"), ], }, { $ne: [ "$_id", "$$REMOVE", ], }, ], }, ], }, }, }, { $project: { _id: 1, email: 1, name: 1, }, }, ])
findUnique
prisma:query db.User.aggregate([ { $match: { $expr: { $and: [ { $and: [ { $eq: [ "$_id", ObjectId("6d795f757365725f69643030"), ], }, { $ne: [ "$_id", "$$REMOVE", ], }, ], }, ], }, }, }, { $project: { _id: 1, email: 1, name: 1, }, }, ])
success
Done in 4.25s.

Logging via binary:

$ ts-node ./script.ts
deleteMany
prisma:info Started query engine http server on http://127.0.0.1:40585/
create
findUnique
success
Done in 4.34s.

4.3.0-dev.84

@janpio janpio changed the title MongoDB does not log with binary Engine MongoDB does not log queries with binary Engine Aug 30, 2022
@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. topic: logging labels Aug 30, 2022
@Jolg42 Jolg42 added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Aug 30, 2022
@Jolg42
Copy link
Member

Jolg42 commented Aug 30, 2022

Can reproduce the same with that version as well

@Jolg42 Jolg42 added the team/client Issue for team Client. label Aug 30, 2022
@miguelff miguelff self-assigned this Oct 18, 2022
miguelff added a commit to prisma/prisma-engines that referenced this issue Oct 20, 2022
Fixes prisma/prisma#15084

The logging logic should be consolidated and abstracted away
miguelff added a commit to prisma/prisma-engines that referenced this issue Oct 20, 2022
Fixes prisma/prisma#15084

The logging logic should be consolidated and abstracted away
miguelff added a commit to prisma/prisma-engines that referenced this issue Oct 20, 2022
Fixes prisma/prisma#15084

The logging logic should be consolidated and abstracted away
miguelff added a commit to prisma/prisma-engines that referenced this issue Oct 21, 2022
Fixes prisma/prisma#15084

The logging logic should be consolidated and abstracted away
miguelff added a commit to prisma/prisma-engines that referenced this issue Oct 21, 2022
Fixes prisma/prisma#15084

The logging logic should be consolidated and abstracted away
miguelff added a commit to prisma/prisma-engines that referenced this issue Oct 28, 2022
Fixes prisma/prisma#15084

The logging logic should be consolidated and abstracted away
@Jolg42 Jolg42 added this to the 4.6.0 milestone Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: binary topic: engine topic: logging topic: mongodb
Projects
None yet
3 participants