ExLisper Site
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
irelephant [he/him]@lemmy.dbzer0.com to Programmer Humor@programming.dev · 20 days ago

: (

lemmy.dbzer0.com

message-square
27
link
fedilink
286

: (

lemmy.dbzer0.com

irelephant [he/him]@lemmy.dbzer0.com to Programmer Humor@programming.dev · 20 days ago
message-square
27
link
fedilink
alert-triangle
You must log in or # to comment.
  • TootSweet@lemmy.world
    link
    fedilink
    English
    arrow-up
    59
    ·
    20 days 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.

    • folekaule@lemmy.world
      link
      fedilink
      arrow-up
      43
      ·
      20 days ago

      That on delete cascade is evil. I love it.

    • Baizey@feddit.dk
      link
      fedilink
      arrow-up
      21
      ·
      20 days ago

      Would this make 0 = true and 1 = false?

      • TootSweet@lemmy.world
        link
        fedilink
        English
        arrow-up
        30
        ·
        20 days ago

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

        • Baizey@feddit.dk
          link
          fedilink
          arrow-up
          13
          ·
          19 days ago

          Promote that man

  • RustyNova@lemmy.world
    link
    fedilink
    arrow-up
    46
    ·
    20 days ago

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

    Stupid transaction deadlocks…

    • irelephant [he/him]@lemmy.dbzer0.comOP
      link
      fedilink
      arrow-up
      10
      ·
      20 days 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.

      • RustyNova@lemmy.world
        link
        fedilink
        arrow-up
        14
        ·
        20 days ago

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

        • irelephant [he/him]@lemmy.dbzer0.comOP
          link
          fedilink
          arrow-up
          4
          ·
          20 days ago

          Yeah I should probably open an issue.

        • WhyJiffie@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          1
          ·
          19 days ago

          username checks out

          so it must be a problem with your connector maybe

          or with their programming language

          • RustyNova@lemmy.world
            link
            fedilink
            arrow-up
            2
            ·
            19 days ago

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

      • qevlarr@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        19 days ago

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

  • Hadriscus@jlai.lu
    link
    fedilink
    arrow-up
    11
    ·
    20 days ago

    What do you use instead of booleans ? floats ?

    • MultipleAnimals@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      40
      ·
      20 days ago

      strings “true” and “false” ofc like any sane developer

      • Valmond@lemmy.dbzer0.com
        link
        fedilink
        arrow-up
        27
        ·
        20 days 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!

        😐🫤

        • felbane@lemmy.world
          link
          fedilink
          arrow-up
          5
          ·
          18 days ago

          This is awful and aweful at the same time.

          • Valmond@lemmy.dbzer0.com
            link
            fedilink
            arrow-up
            1
            ·
            edit-2
            14 days ago

            Non affective, non effective.

        • psud@aussie.zone
          link
          fedilink
          English
          arrow-up
          3
          ·
          14 days ago

          The system I work on uses “Y” and “N”.

      • Hadriscus@jlai.lu
        link
        fedilink
        arrow-up
        26
        ·
        20 days ago

        good fucking god

        • kubica@fedia.io
          link
          fedilink
          arrow-up
          30
          ·
          20 days 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
            link
            fedilink
            arrow-up
            21
            ·
            20 days ago

            lord mary joseph make it stop

            • sznowicki@lemmy.world
              link
              fedilink
              arrow-up
              22
              ·
              20 days ago

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

    • deadbeef79000@lemmy.nz
      link
      fedilink
      arrow-up
      12
      ·
      20 days 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
        link
        fedilink
        arrow-up
        4
        ·
        20 days ago

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

    • irelephant [he/him]@lemmy.dbzer0.comOP
      link
      fedilink
      arrow-up
      8
      ·
      20 days ago

      Sometimes it’s 0 and 1

  • dalakkin@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    20 days ago

    If it just supported sorting by random with a seed…

  • altphoto@lemmy.today
    link
    fedilink
    arrow-up
    2
    ·
    19 days ago

    But that’s IFF.

Programmer Humor@programming.dev

programmer_humor@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmer_humor@programming.dev

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

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 492 users / day
  • 4.15K users / week
  • 7.3K users / month
  • 13.7K users / 6 months
  • 1 local subscriber
  • 31.6K subscribers
  • 1.37K Posts
  • 17.7K Comments
  • Modlog
  • mods:
  • adr1an@programming.dev
  • Feyter@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • BE: 0.19.16
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org