8
JS-Guy
316d

Even seniors make mistakes. In case you were ever doubting yourself - just remember that.

I just had a very senior level programmer on my staff add a function to a production system that issues an SQL UPDATE query without a WHERE clause. Fortunately, only the 1st entry succeeded and the rest failed due to "duplicate record" errors. Clearly he had intended to do a SELECT to check if an entry was present. If it was present, do an UPDATE, otherwise do an INSERT (think UPSERT - but done manually). However instead in the insert part they were both UPDATE's. The first update was normal looking but the second UPDATE was just this weird malformed-looking thing where he tried to do an UPDATE but to every field including the key fields. Clearly he was thinking about an insert but actually writing it as an update. Every now and then I need to remind myself that these things happen. The guy's not dumb - just made a mistake.

I'm just happy it "failed unsuccessfully".

Comments
  • 4
    and there was no code review?
  • 0
    @iceb They got laxed apparently.
  • 0
    This is why you have code reviews. Duh.
  • 2
    Mistakes will happen regularly

    Ideally there are multiple layers of security (it has to pass a code review and a test suite, then merge to master, auto deploy to multiple test envs like stage and preprod where some simple smoke tests run to see if common site pages still work - and alert devs if errors are logged)

    But I understand some teams work with setups so complex they can’t test all paths in the entire chain.

    And sometimes odd exeptions are made, like when some api is being updated and testing in certain envs is made impossible temporarily
Add Comment