Brendonovich / prisma-client-rust

Type-safe database access for Rust
https://prisma.brendonovich.dev
Apache License 2.0
1.84k stars 108 forks source link

raw query letter casing issue #213

Closed kkharji closed 1 year ago

kkharji commented 1 year ago

Hello,

I've been trying to execute raw query.

insert
  into "UserAuth"
  (id, email, phone, passwordHash)
  values({}, {}, {}, {}) ON CONFLICT (id) DO NOTHING;

Error: "column "passwordhash" of relation "UserAuth" does not exist"._execute_raw seems to change the casing.

I'm using 0.6.2

~~additionally, does execute_raw works with multiple statements? without any params passed? I want to execute multiple sql statement from a sql file~~ db error: ERROR: cannot insert multiple commands into a prepared statement

Thanks

Brendonovich commented 1 year ago

Depending on what database you are using, you may need to put passwordHash in quotes like "UserAuth". Not a prisma thing, just a SQL thing.

As for multiple statements, I'm not entirely sure but I don't think so. You may need to split up each statement and then batch them.

kkharji commented 1 year ago

I managed to somehow to execute the file using docker and postgres cli.

Brendonovich commented 1 year ago

@kkharji is this issue still relevant? Not exactly clear whether the suggestion to use quotes fixed the problem or not, but I'm pretty sure postgres ignores capitalisation unless you use quotes.

kkharji commented 1 year ago

@Brendonovich I'm not sure, haven't tried it after managed to pull of a hack to execute a sql file into postgres docker container. It would be great if this are kept open till multiple sql statement or sql file can be executed.

Brendonovich commented 1 year ago

It would be great if this are kept open till multiple sql statement or sql file can be executed.

Sending multiple SQL statements isn't something I'm going to cater towards and atm neither is Prisma. Sending a whole file is entirely out of scope too, just load it in and execute it yourself. If you need to execute multiple raw queries then construct them individually and batch them.

kkharji commented 1 year ago

Okay, indeed it's out of the scope of this issue. Closing ..