Closed tlode closed 9 years ago
Even if it is good practice to define a primary key for each relation, I came across cases when there are none. In this case, it is still life saving to rely on Pomm and its ability to perform basic operations.
Of course, methods like updateOne()
, deleteByPk()
must throw an exception when primary key is empty.
Opinions welcome.
If a
RowStructure
defines an empty primary key, likethen
WriteQueries::updateOne
andWriteQueries::deleteOne
build a query which will update or delete all rows!This is not a bug, but it should not be possible to define an empty primary key in a model.
The above code is the result of using the CLI code generator on a relation which uses a
UNIQUE
key instead of aPRIMARY KEY
. Maybe the CLI code generator could throw a warning in such a case?