prisma / extension-read-replicas

Prisma Client Extension to add read replica support to your Prisma Client
Apache License 2.0
96 stars 6 forks source link

Throw on empty replica list #13

Closed casey-chow closed 9 months ago

casey-chow commented 9 months ago

In my testing, one of the things I noticed is that an empty list of replicas will lead to an unexpected undefined value. While I believe it would make sense for an empty list could be problematic in other ways, in situations like integration testing it may not make sense to set up a full replica instance.

This PR adds a coalesce to ensure that even when no replicas are instantiated, a valid Prisma instance (the primary) is returned. This way, we don't heave to worry about checking for an empty list and setting up types to condition on whether it is a replica or primary instance throughout the codebase.

casey-chow commented 9 months ago

Sure, that should be fine. I'll go ahead and udpate.

casey-chow commented 9 months ago

@SevInf I've pushed a fix, let me know if you have any further comments.

SevInf commented 8 months ago

Released in 0.3.0