• 62 Posts
  • 327 Comments
Joined 7 months ago
cake
Cake day: June 12th, 2025

help-circle












  • TL;DR; Some bit of Go (or at least a Go lib they’re using) coerces NULL time values to 0, so they added logic later down the data pipeline to check for 0s and convert them back to NULLs.

    The full context of the problem definitely sounds tricky, like I doubt I would have realized it during development, but that little bit of data coersion logic is a HUGE code smell, for me. Never would have passed review, in my book.

    The author’s takeaway seems to be “just cause you’ve fixed a bug doesn’t mean that’s the end of the story,” which is valid, but the far more important takeaway for me is “don’t compromise on best practices in data management.” Like, in this case, they had a data model that leverages NULL (to indicate a “don’t overwrite this field” scenario, and they fed it into something that doesn’t support NULLs. They KNEW about this, and papered over it with a lossy data conversion, instead of actually implementing proper NULL handling for this conversion, or changing the data model to not require use of NULLs.







  • How should I know or figure out things like this?? When there’s no error and I don’t know why it doesn’t working other than trying different syntax until it works!

    A) MDN. Never use any JS API you’ve never used before without reading the docs on MDN first. JS is kind of a massive pain in the ass to work in, but dear lord, the MDN docs are just the absolute gold standard.

    B) Set yourself up with a rudimentary TypeScript build process. Not like a full managed project under npm or bun or whatever the latest fad is (unless you’ve already got a project setup like this, I guess). Just write your source files in TypeScript instead of JavaScript, setup a .tsconfig file, and run a copy of the TypeScript compiler tsc to convert 'em all to JavaScript. That’ll eliminate entire classes of errors from your code, like your attempts to write to a non-existent .width property, for example.

    If you’re not familiar with TypeScript, it’s built to be exclusively a superset of JavaScript. I.E. it’s just JavaScript with some type annotations. Really, the compiler is less of a compiler, and more of just a static analyzer that trims out the type annotations.

    C) You should probably also look for a JS/TS autocompletion tool, of some kind. I’m not sure what’s out there in that regard, except for Intellisense within Visual Studio, since VS is what we’re given at work. But for someone new to an API, having it be discoverable right in your editor is a DX that can’t be beat.