vapor / fluent-postgres-driver

🐘 PostgreSQL driver for Fluent.
MIT License
146 stars 53 forks source link

Join missing from generated SQL #130

Closed tonyarnold closed 4 years ago

tonyarnold commented 4 years ago

I'm currently composing a query using the following code:

DeviceActivation.query(on: connectable)
    .join(\License.id, to: \DeviceActivation.licenseID)
    .filter(\License.key == key)
    .delete()

Unfortunately, when it is run, the SQL query that is generated is logged as:

[psql] [2019-12-10 09:37:43 +0000] DELETE FROM "DeviceActivation" WHERE "License"."key" = ($1) ["SOME_VALUE_I_NEED" (TEXT)]

It's completely missing the join. Am I doing something wrong?

tanner0101 commented 4 years ago

Joins aren't currently supported on delete(). As a workaround you can select all the IDs then do a delete without joining. Or raw sql of course.

tonyarnold commented 4 years ago

Ah, right, yep - that makes sense. Thanks, @tanner0101!