16

I saw a self called "senior developer" store a boolean as a "t" or "f" in a character varying with a max of one character in our postgres database. wtf

Comments
  • 5
    The longer I work in the industry the more I come to expect that "senior developer/engineer" often means little more than "someone who's managed to stick along long enough to no longer really warrant JUST a 'developer' tag"
  • 0
    @angryJavaDev Exactly! What's funny about this guy, he's been at this gig for three years, and it's his first job as a developer.
  • 1
    I just cringed reading that
  • 1
    I might have just has a seizure.
  • 1
    Probably this kind of Senior: https://en.m.wikipedia.org/wiki/...
  • 0
    We have several of those in ours rofl, Y/N fields being saved as char(1).
  • 0
    So I just found out that you are supposed to do that, because databases don't support bools
  • 0
    is the column type boolean?
  • 1
    @tomcentrate no, he set it as character varying but treats it as a boolean in his code. My best guess as to why is because the pgdb driver for php returns booleans as a string of "t" or "f".
  • 2
    @bryansrhodes I actually just talked to someone who works with databases. He said that in a very large portion of databases, there are no Booleans, so they need to use a char
  • 0
    @ds1239 that's about right in a lot of databases, for MySQL, I usually use tinyint, and use 0 and 1.

    SQL Server uses a BIT Field for 0, 1

    in Postgres' documentation online, there is a database column type of boolean, that translates 't', 'TRUE', 'y' and 1 as a true state.
  • 0
    @ds1239 Yeah, I figured that when I saw your reply but I still had to go look it up. Even then my OCDs say to use the boolean so I can look at it and know how to interact with it, haha.
  • 0
    @ds1239 btw, thanks for that info. Pretty cool!
Add Comment