TypeError: client.unsafe is not a function
I was attempting to run tests in a different monorepo folder (my trpc folder) than my core folder where drizzle is and ran into this . I am spinning up temp docker containers.
It works in my core folder just fine but I can't figure out why i am getting this issue. Perhaps a drizzle bug?
![No description](https://cdn.answeroverflow.com/1155000689068609596/image.png)
5 Replies
Ah @a_sherman the error came from mocking the database in the schema folder as described in your blog post
![No description](https://cdn.answeroverflow.com/1155004742968291378/image.png)
You cannot run queries against a mocked database 🤦♂️
I’m not importing ‘mDb’ anywhere in my project. But once removing it the error goes away. It felt like from the post this was a way of testing your queries but seems perhaps the drizzle function is being executed when your schema file is imported elsewhere in the project and erroring since no no client is passed to it
no, in the post I was explaning how to get typed database instance, just to prototype your database calls and decide on a schema design before testing it on a real database with a real client connection
I thought I explained it there, maybe I need to edit my post, so it will be more clear
Yeah it could be more clear that the typed instance needs to be deleted when the file is being used by real connections or else it will error out. Although I assume you could just have the mock instance in a separate file and leave it there