• TootSweet@lemmy.world
    link
    fedilink
    English
    arrow-up
    36
    ·
    10 hours 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.

  • RustyNova@lemmy.world
    link
    fedilink
    arrow-up
    41
    ·
    11 hours ago

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

    Stupid transaction deadlocks…

    • dan@upvote.au
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      4 hours 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
        link
        fedilink
        arrow-up
        10
        ·
        9 hours ago

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

      • nilloc@discuss.tchncs.de
        link
        fedilink
        English
        arrow-up
        5
        ·
        9 hours 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.

    • deadbeef79000@lemmy.nz
      link
      fedilink
      arrow-up
      11
      ·
      edit-2
      11 hours 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

  • lambisio@feddit.cl
    link
    fedilink
    English
    arrow-up
    1
    ·
    7 hours 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.