vapor / fluent

Vapor ORM (queries, models, and relations) for NoSQL and SQL databases
https://docs.vapor.codes/4.0/fluent/overview/
MIT License
1.3k stars 171 forks source link

receive different sql statements, for equal valid fluent ones #768

Closed wibed closed 11 months ago

wibed commented 11 months ago

i update the field as follows:

try await database.schema(Contract.schema)
.foreignKey("author_id", references: Account.schema, "id", onDelete: .cascade)
.update()

the sql command is wrong though

ALTER TABLE "contract" ADD CONSTRAINT "fk:contract.author_id+contract.id" FOREIGN KEY ("author_id") REFERENCES "contract" ("id") ON DELETE CASCADE ON UPDATE NO ACTION

it does return correctly on:

try await database.schema(Contract.schema)
  .foreignKey("author_id", references: Account.schema, .id, onDelete: .cascade)
  .update()
execute <unnamed>: ALTER TABLE "contract" ADD CONSTRAINT "fk:contract.author_id+contract.id" FOREIGN KEY ("author_id") REFERENCES "account" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
wibed commented 11 months ago

even though the wrong sql query is sent the foreign keys table shows it to be correct though link to image

wibed commented 11 months ago

nope must have mistaken one of the queries for the other