293
: ( (lemmy.dbzer0.com)
top 32 comments
sorted by: hot top controversial new old
[-] lambisio@feddit.cl 3 points 6 days ago

I can live without Booleans I think... what saddens me more than nothing else is the lack of more proper treatment for Decimal-like types.

[-] TootSweet@lemmy.world 58 points 1 week ago
create table boolean (
  id integer primary key,
  name text not null unique
)
insert into boolean (name) values ('true');
insert into boolean (name) values ('false');
create table document (
  id integer primary key,
  name text not null unique,
  body text not null,
  is_archived not null integer,
  foreign key (is_archived) references boolean (id)
    on delete cascade
    on update no action
);

Solved.

Bonus: DBAs hate this one weird trick that can free up incredible amounts of disk space by deleting just two rows.

[-] Baizey@feddit.dk 22 points 6 days ago

Would this make 0 = true and 1 = false?

[-] TootSweet@lemmy.world 32 points 6 days ago

You're right, that's way too simple. Definitely need to rotate the booleans daily. For... security. Yeah, security.

[-] folekaule@lemmy.world 42 points 1 week ago

That on delete cascade is evil. I love it.

[-] RustyNova@lemmy.world 45 points 1 week ago

I think you got the wrong caption. It's the world if SQLite supported multiple concurent writes.

Stupid transaction deadlocks...

[-] dan@upvote.au 3 points 6 days ago* (last edited 6 days ago)

WAL mode makes writes a lot faster, which is sufficient for a bunch of use cases. Writers do still need to wait, but they have to wait for a shorter duration. It's still not the right choice for write-heavy use cases, of course.

[-] RustyNova@lemmy.world 2 points 6 days ago

I'm not actually looking for the speed most of the time, but more about preventing partial writes, so I'm still using it

[-] irelephant@lemmy.dbzer0.com 7 points 1 week ago

In my case, I want to use sqlite locally, for development, but I don't want to add a load of jank to handle booleans for sqlite.

[-] qevlarr@lemmy.world 1 points 6 days ago

This is sqlite's intended use case. To replace configure files and local data

[-] RustyNova@lemmy.world 13 points 1 week ago

I use rust's SQLx which map bools to numbers so it must be a problem with your connector maybe

[-] WhyJiffie@sh.itjust.works 1 points 6 days ago

username checks out

so it must be a problem with your connector maybe

or with their programming language

[-] RustyNova@lemmy.world 2 points 6 days ago

I actually started using rust well after picking this username :P

[-] irelephant@lemmy.dbzer0.com 4 points 1 week ago

Yeah I should probably open an issue.

[-] nilloc@discuss.tchncs.de 6 points 1 week ago

That’s what I like about Ruby ORMs. They did all the conversion for you, and you could have SQLite on your dev box, Postgres on the test server and MySQL on the annoying production host that wouldn’t run anything else.

This was 18 years ago though.

[-] HK65@sopuli.xyz 1 points 4 days ago* (last edited 4 days ago)

Are not all ORMs like that? I only used ActiveRecord before fucking off from backend 10 years ago

[-] Hadriscus@jlai.lu 10 points 1 week ago

What do you use instead of booleans ? floats ?

[-] lord_ryvan@ttrpg.network 4 points 6 days ago

Smallest INT it can support and only ever use 0 and 1.

[-] MultipleAnimals@sopuli.xyz 44 points 1 week ago

strings "true" and "false" ofc like any sane developer

[-] Valmond@lemmy.dbzer0.com 27 points 1 week ago

I got a better one: O for true and N for false.

Seen in production for quite important stuff (payment requests).

O is from Oui, N from Non, of course!

😐🫤

[-] psud@aussie.zone 2 points 1 day ago

The system I work on uses "Y" and "N".

[-] felbane@lemmy.world 4 points 5 days ago

This is awful and aweful at the same time.

[-] Valmond@lemmy.dbzer0.com 1 points 4 days ago* (last edited 1 day ago)

Non affective, non effective.

[-] Hadriscus@jlai.lu 26 points 1 week ago
[-] kubica@fedia.io 31 points 1 week ago

it allows for mood changes, some parts of the code can check charAt(0) == 't'others can do val != 'false' just let it flow.

[-] Hadriscus@jlai.lu 22 points 1 week ago

lord mary joseph make it stop

[-] sznowicki@lemmy.world 22 points 1 week ago

And for double fun if the output doesn’t matter you can make if endsWith(“e”).

[-] deadbeef79000@lemmy.nz 12 points 1 week ago* (last edited 1 week ago)

Use a CHAR(1) you can then use it as an enumeration.

Don't use T/F for true/false use it for the actual sematic meaning for the thing that the Boolean is toggling. E g. S for subscribed, U for unsubscribed, or whatever.

It also means when you inevitably grow to needing a tri-state it makes sense.

Unless SQLite actually supports enumerations, then just use them

[-] SpaceNoodle@lemmy.world 5 points 1 week ago

I think you could use a CHECK constraint to effectively create en enum

[-] irelephant@lemmy.dbzer0.com 9 points 1 week ago

Sometimes it's 0 and 1

[-] dalakkin@lemmy.world 5 points 1 week ago

If it just supported sorting by random with a seed..

this post was submitted on 10 May 2026
293 points (100.0% liked)

Programmer Humor

31455 readers
1581 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS