OldGrumpyBitWrangler,
@OldGrumpyBitWrangler@mastodon.social avatar

An instance of a popular CMS is used for a website. While analyzing I'm coming across a a table in it's MySQL database where a column called "deleted" is defined as such:

deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'A boolean indicating whether this data item has been deleted‘

🤦‍♂️

There should be a license allowing allowed to write software used by someone else. Like with drivers licenses it needs a points system for violations and license revocation.

Crell,
@Crell@phpc.social avatar

@OldGrumpyBitWrangler I have theories as to which CMS you're talking about... But I'll ask, what would you do instead? Isn't that the only way to do a boolean flag in MySQL, or have they fixed that more recently?

OldGrumpyBitWrangler,
@OldGrumpyBitWrangler@mastodon.social avatar

@Crell What I would do? Use PostgresSQL. According to documentation MariaDB has BOOLEAN as an alias for TINYINT(1). MySQL might as well, but their documentation is as crappy as ever.

Crell,
@Crell@phpc.social avatar

@OldGrumpyBitWrangler OK, so your objection isn't to what the CMS is doing, just with their choice of database. Got it.

(I agree Postgres is the more robust option, but wasn't sure what issue you had with "deleted" flags. That's a common technique for that use case.)

OldGrumpyBitWrangler,
@OldGrumpyBitWrangler@mastodon.social avatar

@Crell it's both. Well actually more than that. I object the use of MySQL for many reasons, including the sloppy way it's been developed over its lifetime, the BOOLEAN type being a quiet minor example of that. I also object MySQL b/c said sloppyness encourages bad practices with many, less experienced developers and normalizes that. Which leads to my 3rd objection: The definition of the ‚deleted' column by the CMS/module developers. TINYINT(4) for a boolean that by definition is either 0 or 1.

Crell,
@Crell@phpc.social avatar

@OldGrumpyBitWrangler Yeah, using 4 there is an odd choice.

OldGrumpyBitWrangler,
@OldGrumpyBitWrangler@mastodon.social avatar

@Crell To me "odd choice" would apply some thinking behind it. I don't know what that was, but the same part of the code does do even more silly things: https://mastodon.social/@OldGrumpyBitWrangler/112407018128767799

Crell,
@Crell@phpc.social avatar

@OldGrumpyBitWrangler In fairness, 95% of developers in my experience don't know what SQL is, other than "that thing backing my over-engineered ORM." The vast majority of implementations use SQL as a glorified card catalog or CSV file with indexes, for hydrating overly complex objects in the language of choice.

That's hardly specific to one ORM, language, or database.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • php
  • GTA5RPClips
  • DreamBathrooms
  • InstantRegret
  • magazineikmin
  • thenastyranch
  • ngwrru68w68
  • Youngstown
  • everett
  • slotface
  • rosin
  • ethstaker
  • Durango
  • kavyap
  • cubers
  • provamag3
  • modclub
  • mdbf
  • khanakhh
  • vwfavf
  • osvaldo12
  • cisconetworking
  • tester
  • Leos
  • tacticalgear
  • anitta
  • normalnudes
  • megavids
  • JUstTest
  • All magazines