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 and bool
Postgresql and bool [message #22938] Mon, 31 August 2009 09:59 Go to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
Hi,

In revision 1531 of upp, returned value in PostgreSQLConnection::GetColumn was changed from bool to string:
void PostgreSQLConnection::GetColumn(int i, Ref f) const
[...]
1530:
		case BOOL_V:
			f.SetValue(*s == 't' ? true : false);
1531:
		case BOOL_V:
			f.SetValue(*s == 't' ? "1" : "0");


So now when I want to check if returned value is true, an assert is triggered.

	sql * Select(ROLCREATEROLE).From(PG_ROLES).Where(ROLNAME == current_user);
	if (sql.Fetch()){
		if (sql[ROLCREATEROLE]){// <-- ASSERT
		[...]
		}
	}


Correct me if I am wrong, but this change should be done in PostgreSQLConnection::SetParam, because postgres expects '0' and '1' instead of 0 and 1 in case of boolean values.

Re: Postgresql and bool [message #22956 is a reply to message #22938] Wed, 02 September 2009 17:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Please check:

http://www.ultimatepp.org/forum/index.php?t=msg&th=1284& amp;start=0&

I am sorry for the trouble, but there seems to be no really correct solution...

Mirek
Re: Postgresql and bool [message #22963 is a reply to message #22956] Thu, 03 September 2009 09:27 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
luzr wrote on Wed, 02 September 2009 17:57

I am sorry for the trouble, but there seems to be no really correct solution...


It is ok. I just don't like idea of testing bools as strings:

if (sql[ROLCREATEROLE] == "1")


but there is SqlToBool that solves my problem.
Re: Postgresql and bool [message #22984 is a reply to message #22963] Fri, 04 September 2009 14:28 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
[quote title=Zbych wrote on Thu, 03 September 2009 03:27]
luzr wrote on Wed, 02 September 2009 17:57

I am sorry for the trouble, but there seems to be no really correct solution...


It is ok. I just don't like idea of testing bools as strings:

if (sql[ROLCREATEROLE] == "1")


Neither do I. But they had that great idea to make them incompatible with C/C++...

Mirek
Previous Topic: Postgresql - execpt vs minus
Next Topic: Postgres library improvements
Goto Forum:
  


Current Time: Fri Mar 29 12:26:19 CET 2024

Total time taken to generate the page: 0.01694 seconds