A 'driven' software engineer with a passion for cars and tabletop games. Get it, driven? Because cars and... Okay, I'll stick to writing code instead of puns. 🏁
I think you're able to use the BIT type in MySQL, which also has the boolean type. Didn't take long to find on a Google search. Stack Overflow has several threads on it over the years.
When reading your value back from the database, cast it into whatever your UI needs. Usually there's a layer of logic between the crunchy data stuff and fancy interactive UI stuff.
In something like Sqlite which has very limited types available, I go with the text option 'true' and 'false'.
A 'driven' software engineer with a passion for cars and tabletop games. Get it, driven? Because cars and... Okay, I'll stick to writing code instead of puns. 🏁
So you've developed a validation on frontend and backend as well that filters out every typo and other words than true/false? Not being mean here, but that's essential if you choose that road.
A 'driven' software engineer with a passion for cars and tabletop games. Get it, driven? Because cars and... Okay, I'll stick to writing code instead of puns. 🏁
There's no need to do that if you're checking on a situation like whether a checkbox is checked.
If your process involves a user manually entering the words true/false/0/1/etc and you're not validating it before using it on the backend.... That's a big problem for introducing weird issues.
Flipping whatever the checkbox state is into the words true/false to save somewhere should be one line in most languages.
I think you're able to use the BIT type in MySQL, which also has the boolean type. Didn't take long to find on a Google search. Stack Overflow has several threads on it over the years.
dev.mysql.com/doc/refman/8.0/en/bi...
When reading your value back from the database, cast it into whatever your UI needs. Usually there's a layer of logic between the crunchy data stuff and fancy interactive UI stuff.
In something like Sqlite which has very limited types available, I go with the text option 'true' and 'false'.
storing string "true" or "false" takes more time to return and slower running in a large app, I assume?
Not really, no.
So you've developed a validation on frontend and backend as well that filters out every typo and other words than true/false? Not being mean here, but that's essential if you choose that road.
There's no need to do that if you're checking on a situation like whether a checkbox is checked.
If your process involves a user manually entering the words true/false/0/1/etc and you're not validating it before using it on the backend.... That's a big problem for introducing weird issues.
Flipping whatever the checkbox state is into the words true/false to save somewhere should be one line in most languages.
That's perfectly true. Was overthinking it. :)