Was there a change with databaseManager.hasRecords() ?

Hello,

I wondered if there was a change in the behavior of databaseManager.hasRecords() somewhere between 3.5 RC4 and the RC7 (also in the final release)

I have the following code:

arguments[1] has a value 777 which is a valid articlecode in the database.

globals.article_code = '%' + arguments[1] + '%'

if(databaseManager.hasRecords(_to_article$article_code ) && _to_article$article_code.getSize() == 1)
{
	article_id = _to_article$article_code.article_id

}

If I remember well in the earlier versions the databaseManager.hasRecords(_to_article$article_code ) returned true in this case. And if there were several records in the relation, then using the getSize() I could check if there was a single result.

Now I’ve seen that

globals.article_code =  arguments[1] 

if(databaseManager.hasRecords(_to_article$article_code ) && _to_article$article_code.getSize() == 1)
{
	article_id = _to_article$article_code.article_id

}

without the % (which should react as LIKE), that databaseManager.hasRecords(_to_article$article_code ) returns true.

I want to know of there was a change in one of the RC releases, which caused that the databaseManager.hasRecords(_to_article$article_code ) doesn’t return anymore results when using %. Looks like in the database formerly there was used a LIKE statement and now it uses a = condition.

Anybody knows about this situation and more important is what should be the correct behavior, because not my application is not working anymore as it should be. The database I’m using is SQL Server 2005; maybe that is important also.

databasemanager.hasRecords() doesn’t look what your relation looks like. It doesn’t see that you use like or =.

That isn’t tested in that method, the only thing that is tested is if the foundset exists and if the size() of the foundset > 0

so if it returns true. Then the foundset has data. So what records do you find in the foundset? Are they really not what you expect?

The following is the case.

the relation ‘_to_article$article_code’ is a relation from globals.article_code to article.article_code where article is a database table.

globals.article_code = '%' + arguments[1] + '%' 

if(databaseManager.hasRecords(_to_article$article_code ) && _to_article$article_code.getSize() == 1) 
{ 
   article_id = _to_article$article_code.article_id 

}
else
{
     // Show form to select an article
}

My database has an articlecode 007038.
When I get ‘007038’ as argument[1], you can see that the global.article_code was assigned to ‘%007038%’

In that case in a prevous version (RC3/RC4) , the relation had a valid foundset, so that databaseManager.hasRecords() returned true.
Now with RC7 and final version it returns false.

The objective is this situation was that when a user enters a part of an article_code and there is only 1 record that contains this part (therefore the test on getSize() ), then the article_id is filled with the found record.
If there are more results, then a form is shown where the user has to select 1 record.

What I see now, is that the first test is giving false, the form is shown where the user has to select an article, but immediately there is only 1 record visible. That is why I noticed that something has been changed. That code was written by Sanneke, so I guess she also thought/knew that it worked like I expected.

When I remove the ‘%’, then it works when I enter a complete article_code, but not when I enter just a part of an article_code

globals.article_code = arguments[1] 

I hope I made this clear

is the relation build like a like relation then?

so is this in the relation dialog defined as a like operator:
globals.article_code to article.article_code?

(and of course article_code is a string)

or are you really saying that this doesn’t print out 0?

if (!databaseManager.hasRecords(_to_article$article_code ) )
{
application.output(_to_article$article_code.getSize());
}

so has records does return false but the size is still more then 0?

ok

I didn’t know you could make a relation a like relation. I’ve seen it now in the relationform.

So as I understand, a relation

%1234% = article.article_code

is not equal to

1234 like article.article_code

Can you confirm that above is not the same relation

Maybe in some earlier release both situations were equal, but perhaps that was fixed because it shouldn’t work like that.

no you have to specify it as a like relation.

maybe in the past we stripped the % out of the variable and then it was just xxx = 1002002. And it just matched…

But if you want to use % in the value you have to specify it as a like

OK it works.