Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » BOOL in SQLite
BOOL in SQLite [message #52086] Wed, 17 July 2019 14:00 Go to next message
borbek is currently offline  borbek
Messages: 31
Registered: November 2010
Location: Russia
Member
Hi!

In Sqlite3Schema.h BOOL replaces by TEXT:

#define BOOL(x) COLUMN("text", bool, x, 0, 0)
#define BOOL_ARRAY(x, items) COLUMN_ARRAY("text", bool, x, 0, 0, items)
#define BOOL_(x) COLUMN_("text", bool, x, 0, 0)
#define BOOL_ARRAY_(x, items) COLUMN_ARRAY_("text", bool, x, 0, 0, items)

but in sqlite, the boolean is an integer 0 or 1, so, IMHO, it is right:

#define BOOL(x) COLUMN("integer", bool, x, 0, 0)
#define BOOL_ARRAY(x, items) COLUMN_ARRAY("integer", bool, x, 0, 0, items)
#define BOOL_(x) COLUMN_("integer", bool, x, 0, 0)
#define BOOL_ARRAY_(x, items) COLUMN_ARRAY_("integer", bool, x, 0, 0, items)

"
3.1. No Separate BOOLEAN Datatype
Unlike most other SQL implementations, SQLite does not have a separate BOOLEAN data type. Instead, TRUE and FALSE are (normally) represented as integers 1 and 0, respectively.
"
Re: BOOL in SQLite [message #52208 is a reply to message #52086] Fri, 09 August 2019 09:32 Go to previous message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
borbek wrote on Wed, 17 July 2019 14:00
Hi!

In Sqlite3Schema.h BOOL replaces by TEXT:

#define BOOL(x) COLUMN("text", bool, x, 0, 0)
#define BOOL_ARRAY(x, items) COLUMN_ARRAY("text", bool, x, 0, 0, items)
#define BOOL_(x) COLUMN_("text", bool, x, 0, 0)
#define BOOL_ARRAY_(x, items) COLUMN_ARRAY_("text", bool, x, 0, 0, items)

but in sqlite, the boolean is an integer 0 or 1, so, IMHO, it is right:

#define BOOL(x) COLUMN("integer", bool, x, 0, 0)
#define BOOL_ARRAY(x, items) COLUMN_ARRAY("integer", bool, x, 0, 0, items)
#define BOOL_(x) COLUMN_("integer", bool, x, 0, 0)
#define BOOL_ARRAY_(x, items) COLUMN_ARRAY_("integer", bool, x, 0, 0, items)

"
3.1. No Separate BOOLEAN Datatype
Unlike most other SQL implementations, SQLite does not have a separate BOOLEAN data type. Instead, TRUE and FALSE are (normally) represented as integers 1 and 0, respectively.
"


Well, this is more about cross-db compatibility. SQLs often lack(ed) BOOL type, but often it can be represented by single character, which can often be stored as single byte.

As it is better to have single model for all databases, we had to choose between numerical and character. Choosed character.

Note: The reason why it is better to have single model is that at some point, you want to have uniform way how to deal with it in widgets.
Previous Topic: Multiple DUAL_UNIQUE generate conflicting statements
Next Topic: How to share a schema .sch with multiple header and source files
Goto Forum:
  


Current Time: Sat Jun 15 03:07:57 CEST 2024

Total time taken to generate the page: 0.01737 seconds