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 » PostgreSql does not handle BOOL correctly
Re: PostgreSql does not handle BOOL correctly [BUG+PATCH] [message #60222 is a reply to message #60221] Sat, 21 October 2023 17:22 Go to previous message
mirek is currently offline  mirek
Messages: 14267
Registered: November 2005
Ultimate Member
omari wrote on Sat, 21 October 2023 01:14
This test case (attached) FAIL without the patch, and PASS with the patch.

	
	if(!OpenDB()) return;
	
	Sql sql(session);
	sql * Insert(TEST1) (ID, 1) (B, true);
	sql * Insert(TEST1) (ID, 2) (B, false);
	
	sql*Select(SqlAll()).From(TEST1).Where(B == true);
	LOG(sql.ToString());
	if (sql.Fetch()) {
		ASSERT(sql[ID] == 1);
	}
	else {
		ASSERT(false); // Failed : 'Select' should return one row
	}
	
	sql*Select(SqlAll()).From(TEST1).Where(B == false);
	LOG(sql.ToString());
	if (sql.Fetch()) {
		ASSERT(sql[ID] == 2);
	}
	else {
		ASSERT(false); // Failed : 'Select' should return one row
	}


the schema file:
TABLE_(TEST1)
	INT_   (ID) PRIMARY_KEY
	BOOL_  (B)
END_TABLE



That is all good and fine, just not the way it was intended to work. (And I do not claim that the intended way is the best but it worked fine for 20+ years.)

sql*Select(SqlAll()).From(TEST1).Where(B == '1')

is not all that harder to do and IMO it is more "honest" (we do not pretend that B is not char).

Frankly, the only differense between BOOL and STRING(1) apart from documentation purposes is that gets converted to bool in S_ structures. If you do not like that, do not use BOOL.

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: SqlPerformScript bug: Not doing anything if script starts with "BEGIN;" and ends with "END;"
Next Topic: Sqlite3 update
Goto Forum:
  


Current Time: Thu Aug 21 16:26:49 CEST 2025

Total time taken to generate the page: 0.03953 seconds