all 34 comments

sorted by: hot top controversial new old
[–] 60 points 2 months ago (2 children)
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.

  • source
  • hideshow 4 child comments
  • [–] 49 points 2 months ago (2 children)

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

    Stupid transaction deadlocks...

  • source
  • hideshow 4 child comments
  • [–] [S] 10 points 2 months ago (3 children)

    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.

  • source
  • parent
  • hideshow 6 child comments
  • [–] 14 points 2 months ago (2 children)

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

  • source
  • parent
  • hideshow 4 child comments
  • [–] 7 points 2 months ago (1 child)

    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.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 3 points 2 months ago* (1 child)

    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.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 11 points 2 months ago (4 children)

    What do you use instead of booleans ? floats ?

  • source
  • hideshow 8 child comments
  • [–] 43 points 2 months ago (2 children)

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

  • source
  • parent
  • hideshow 4 child comments
  • [–] 29 points 2 months ago (2 children)

    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!

    😐🫤

  • source
  • parent
  • hideshow 4 child comments
  • [–] 27 points 2 months ago (1 child)
  • [–] 33 points 2 months ago (1 child)

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

  • source
  • parent
  • hideshow 2 child comments
  • [–] 11 points 2 months ago* (1 child)

    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

  • source
  • parent
  • hideshow 2 child comments
  • [–] 4 points 2 months ago

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

  • source
  • [–] 3 points 2 months ago

    But that's IFF.

  • source
  • [–] 3 points 2 months 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.

  • source