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 #60199 is a reply to message #60062] Wed, 04 October 2023 18:50 Go to previous messageGo to previous message
omari is currently offline  omari
Messages: 276
Registered: March 2010
Experienced Member
I managed to resolve this bug,
here is my solution:

Sql/SqlExp.h:
line 67:

enum {
	SQLC_IF = 1,
	SQLC_ELSEIF = 2,
	SQLC_ELSE = 3,
	SQLC_ENDIF = 4,
	SQLC_DATE = 5,
	SQLC_TIME = 6,
	SQLC_STRING = 7,
	SQLC_BINARY = 8,
	SQLC_ID = 9, // '\t'
	SQLC_OF = 10,
	SQLC_AS = 11,
	SQLC_COMMA = 12,
	SQLC_BOOL = 13,         +++
};


Line 99:
String SqlFormat(int x);
String SqlFormat(bool x);          +++
String SqlFormat(double x);
String SqlFormat(int64 x);


Line 212:

class SqlVal : public SqlS, Moveable<SqlVal> {
public:
	...

	SqlVal(int x);
	SqlVal(bool x);       +++
	SqlVal(int64 x);
	SqlVal(double x);
	...
};


Sql/SqlVal.cpp:
line 128: ADD

SqlVal::SqlVal(bool x) {
	if(UPP::IsNull(x))
		SetNull();
	else
		SetHigh(SqlFormat(x));
}



Sql\SqlCode.cpp
Line 146: ADD
		case SQLC_BOOL: {
			LTIMING("SqlCompile BOOL");
			bool x;
			ReadSqlValue(x, s);
			if(!r) break;
			if(IsNull(x)) {
				*r << "NULL";
				break;
			}
			switch(dialect) {
			case PGSQL:
				*r << ( x ? "'1'" : "'0'");
				break;
			default:
				*r << ( x ? "1" : "0");
			}
			break;
		}
		case SQLC_DATE: {


Line 429: ADD
String SqlFormat(bool x)
{
	return MakeSqlValue(SQLC_BOOL, x);
}


and change the next function:
String SqlFormat(const Value& x)
{
	if(x.IsNull()) return "NULL";
	switch(x.GetType()) {
	case BOOL_V:
		return SqlFormat((bool) x);     +++
	case INT_V:
		return SqlFormat((int) x);
	case INT64_V:
		return SqlFormat((int64) x);
	case DOUBLE_V:


regards
omari.

[Updated on: Thu, 19 October 2023 20:57]

Report message to a moderator

 
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:52 CEST 2025

Total time taken to generate the page: 0.04347 seconds