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 » Prefix to prevent name clash in SQL: SqlId, variables, tables, ...
Re: Prefix to prevent name clash in SQL: SqlId, variables, tables, ... [message #28361 is a reply to message #17171] Mon, 30 August 2010 15:45 Go to previous message
sevenjay is currently offline  sevenjay
Messages: 30
Registered: October 2008
Location: Taiwan
Member
I have another opinion on this.
When you create tables/columns with lower-case names, set SqlID like
SqlId TITLE("Title");

It will not match the table/column name "Title" because it will be "TITLE" in cn->info[i].name.
That is not convenient to force user to set SqlID all upper case.
SqlId TITLE("TITLE");


I think it could be case insensitive equality comparison.

if(cn->info[i].name == s) 

could be
if( 0 == s.CompareInsensitive(~(cn->info[i].name))) 

The method CompareInsensitive maybe like this
template <class B>
int AString<B>::CompareInsensitive(const tchar *b) const
{
	const tchar *a = B::Begin();
	const tchar *ae = End();
	for(;;) {
		if(a >= ae)
			return *b == 0 ? 0 : -1;
		if(*b == 0)
			return 1;
		int q = cmpval__(*a) - cmpval__(*b);
		if( (cmpval__('a') < cmpval__(*a) && cmpval__(*a) < cmpval__('z')) || 
		    (cmpval__('A') < cmpval__(*a) && cmpval__(*a) < cmpval__('Z')) )
			if(q == cmpval__('a') - cmpval__('A') || q == cmpval__('A') - cmpval__('a'))
				q = 0;
		if(q)
			return q;
		
		*a++;
		*b++;
	}
}

I tried it's OK.
But I am not sure if it is faster than ToUpper.
 
Read Message icon3.gif
Read Message
Read Message
Read Message
Read Message
Previous Topic: transactions and sql
Next Topic: Some questions around SQlite3
Goto Forum:
  


Current Time: Mon May 13 15:38:11 CEST 2024

Total time taken to generate the page: 0.02556 seconds