prismock icon indicating copy to clipboard operation
prismock copied to clipboard

fix: bug in scalar list push support that would push the push function of arrays onto each array

Open CrystallineCat opened this issue 9 months ago • 1 comments

The current code trips on things like:

this.prisma.someModel.update({
  where: { id },
  data: {
    someList: ["a", "b", "c"],
  },
})

Since the array ["a", "b", "c"] itself has a push function, it would push the push function itself into the array and insert it into the DB.

Sorry for causing this bug. Can you please add a test?

CrystallineCat avatar May 14 '24 12:05 CrystallineCat

I noticed we have a non-scalar list in our codebase that gets pushed. I'm not sure this is supported prisma behaviour (I can't find anything on non-scalar lists at all), but it seems to work, so I removed the === 'scalar' test to make tests work.

CrystallineCat avatar May 15 '24 07:05 CrystallineCat

Hello @CrystallineCat , thanks again! I'll track that inside https://github.com/morintd/prismock/pull/923. If you have another PR, feel free to raise it from a different branch than master. It will allow me to use it directly with my CI (I'm also open if there is a different process)!

Thanks anyway!

morintd avatar May 18 '24 14:05 morintd