Open alessiodebernardi opened 5 years ago
Hmm, indeed doesn't seem "nice" for developers. I see two immediate options but also challenges:
PDOException
and check for error code specifically, re-throw if it's not a unique violationBoth AFAICS have the same challenge: not cross-database compatible (error codes vary between database as does the upsert syntax; the latter may not even be supported by all databases).
Given this, I think I can understand why the code is written that way it is: not ideal, but works for 99.9% ; you happen to be the unlucky 0.1% :-/
Why the method
put
declared inside the classIlluminate/Cache/DatabaseStore
catches a generalException
and immediately assumes that is a "duplicate key" case and do anupdate
query? What happen if the exception refers to other? In my case, for example, using a MySQL database, i found out a "String data, right truncated: 1406 Data too long for column..." exception but it was very difficult to debug this, because the method don't report/log/throw anything.(Sorry for my bad english)