prisma-client-py icon indicating copy to clipboard operation
prisma-client-py copied to clipboard

Namespace client methods

Open RobertCraigie opened this issue 4 years ago • 2 comments

Problem

Model names can clash with methods like connect(), query_first() etc

Suggested solution

We should namespace these methods behind an attribute like prisma and then validate that model names won't clash with that.

For example

await client.connect()

would turn into

await client.prisma.connect()

RobertCraigie avatar Jul 22 '21 14:07 RobertCraigie

In Prisma Client JS we "solved" this problem by prefixing these methods with $: https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#client-methods Ain't pretty, but it works.

janpio avatar Aug 27 '21 18:08 janpio

Yeah I don't think there's anything like that in python though :/

I do think simply namespacing the custom methods is the best solution as the only other alternatives I'm aware of are adding an underscore to the end of custom methods or using a camelCase/PascalCase naming scheme

RobertCraigie avatar Aug 27 '21 20:08 RobertCraigie