Discussion:
canGetRow mystery
(too old to reply)
Rich Assaf
2008-10-30 02:48:17 UTC
Permalink
I thought I understood this, but having an issue with canGetRow not
seeming to filter out any records.

Try this, from the command window:

q = new query('select * from :dBaseSamples:Fish')
q.rowset.cangetRow = {||this.fields['Name'].value == 'Blue'}
? q.rowset.count() // 10 = not filtered at all! Should be 2

I'm having the exact same problem with a production table, the canGetRow
doesn't throw any errors, it just doesn't seem to work.

Am I overlooking something obvious???

Thanks, Rich

version: dBase 2.6.1.4 b2075, XP Pro
Geoff Wass [dBVIPS]
2008-10-30 04:52:51 UTC
Permalink
Post by Rich Assaf
I thought I understood this, but having an issue with canGetRow not
seeming to filter out any records.
q = new query('select * from :dBaseSamples:Fish')
q.rowset.cangetRow = {||this.fields['Name'].value == 'Blue'}
? q.rowset.count() // 10 = not filtered at all! Should be 2
I'm having the exact same problem with a production table, the canGetRow
doesn't throw any errors, it just doesn't seem to work.
Am I overlooking something obvious???
Thanks, Rich
version: dBase 2.6.1.4 b2075, XP Pro
Rich,

This is quite likel WAD. This is from the on-line help:

Returns the number of rows in a rowset, respecting any filter conditions
and events.

canGetRow is not mentioned as on of the things ROWSET.count() respects.
Perhaps dBI should be asked to clarify the documentation.
--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
.|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
Rich Assaf
2008-10-30 23:28:27 UTC
Permalink
Post by Geoff Wass [dBVIPS]
Rich,
Returns the number of rows in a rowset, respecting any filter conditions
and events.
canGetRow is not mentioned as on of the things ROWSET.count() respects.
Perhaps dBI should be asked to clarify the documentation.
I checked some other places, and I have (successfully) used the
rowset.count() method to correctly return the number of records meeting
a condition. I interpreted from the OLH that canGetRow is a "filter
condition and event", even though canGetRow is not specifically
mentioned.

Nonetheless, this quick example form demonstrates that what didn't work
in the command window works in a form .... either hard-coded or as the
macro-substituted variable....

Thanks, Rich

-----------------------------------------------------------------
/* This didn't work in command window:
q = new query('select * from :dBaseSamples:Fish')
q.rowset.cangetRow = {||this.fields['Name'].value == 'Blue'}
? q.rowset.count() // 10 = not filtered at all! Should be 2
*/

** END HEADER -- do not remove this line
//
// Generated on 10/30/2008
//
parameter bModal
local f
f = new bugcangetrowForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif

class bugcangetrowForm of FORM
with (this)
height = 16.0
left = 68.7143
top = 0.7273
width = 80.2857
text = "CanGetRow Behavior"
endwith

this.DBASESAMPLES1 = new DATABASE()
this.DBASESAMPLES1.parent = this
with (this.DBASESAMPLES1)
left = 74.7143
top = 14.7727
databaseName = "DBASESAMPLES"
active = true
endwith

this.FISH1 = new QUERY()
this.FISH1.parent = this
with (this.FISH1)
left = 74.7143
top = 14.7727
database = form.dbasesamples1
sql = "select * from fish.dbf"
active = true
endwith

this.GRID1 = new GRID(this)
with (this.GRID1)
dataLink = form.fish1.rowset
height = 8.1818
left = 3.8571
top = 1.3636
width = 72.1429
endwith

this.TEXTLABEL1 = new TEXTLABEL(this)
with (this.TEXTLABEL1)
height = 1.0
left = 7.4286
top = 10.4545
width = 22.5714
text = "CanGetRow to Fish Name:"
endwith

this.ENTRYFIELD1 = new ENTRYFIELD(this)
with (this.ENTRYFIELD1)
height = 1.0
left = 32.7143
top = 10.2273
width = 15.5714
value = ""
endwith

this.TEXTLABEL2 = new TEXTLABEL(this)
with (this.TEXTLABEL2)
height = 1.0
left = 51.7143
top = 10.2273
width = 20.2857
text = "Matching Fish:"
endwith

this.PUSHBUTTON1 = new PUSHBUTTON(this)
with (this.PUSHBUTTON1)
onClick = class::PUSHBUTTON1_ONCLICK
height = 1.0909
left = 11.1429
top = 12.2727
width = 19.2857
text = "Set canGetRow"
endwith

this.PUSHBUTTON2 = new PUSHBUTTON(this)
with (this.PUSHBUTTON2)
onClick = {;form.rowset.canGetRow = {||.t.}}
height = 1.0909
left = 39.2857
top = 12.2727
width = 20.8571
text = "Clear canGetRow"
endwith

this.rowset = this.fish1.rowset

function PUSHBUTTON1_onClick
private cFishName
cFishName = trim(form.entryfield1.value)
// >>> hard coded or not, both lines work <<<<<<<<
*form.rowset.canGetRow = ;
{||this.fields['Name'].value = "&cFishName."}
form.rowset.canGetRow = ;
{||this.fields['Name'].value = "Blue"}
nRecs = form.rowset.count()
form.textLabel2.text := ;
'Matching Fish: '+nRecs
return

endclass
Geoff Wass [dBVIPS]
2008-10-31 05:18:34 UTC
Permalink
Post by Rich Assaf
I checked some other places, and I have (successfully) used the
rowset.count() method to correctly return the number of records meeting
a condition. I interpreted from the OLH that canGetRow is a "filter
condition and event", even though canGetRow is not specifically
mentioned.
Nonetheless, this quick example form demonstrates that what didn't work
in the command window works in a form .... either hard-coded or as the
macro-substituted variable....
Thanks, Rich
Rich,

You are right. It looks like it is a bug in the Command Window. Can you
post your sample program with a explanation in dbase.bug-reports?
Thanks.
--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
.|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
Jan Hoelterling
2008-10-30 03:17:26 UTC
Permalink
Hi Rich,

I am not sure why, but Count does not seem to work correctly here - seems to
be a bug.

Also, not sure if you meant to do this, but your CanGetRow returns nothing,
as you can check with
?q.rowset.endofset -> TRUE

I changed your CanGetRow to :
q.rowset.cangetRow = {|| at("Blue",this.fields['Name'].value)>0}
which is probably more what you want to accomplish. A quick test with:
q.rowset.first();i=0;do while not
q.rowset.endofset;i++;?i,q.rowset.fields["name"].value;q.rowset.next();enddo
returns:
1 Blue Angelfish
2 Bluehead Wrasse
which is what I would expect.

However,
?q.rowset.count()
still returns "10", which is wrong.

Hope this helps...

Jan
Rich Assaf
2008-10-30 23:15:56 UTC
Permalink
Post by Jan Hoelterling
Hi Rich,
I am not sure why, but Count does not seem to work correctly here - seems to
be a bug.
Also, not sure if you meant to do this, but your CanGetRow returns nothing,
as you can check with
?q.rowset.endofset -> TRUE
q.rowset.cangetRow = {|| at("Blue",this.fields['Name'].value)>0}
q.rowset.first();i=0;do while not
q.rowset.endofset;i++;?i,q.rowset.fields["name"].value;q.rowset.next();enddo
1 Blue Angelfish
2 Bluehead Wrasse
which is what I would expect.
However,
?q.rowset.count()
still returns "10", which is wrong.
Hope this helps...
Jan
Thanks for looking at this Jan, helps convince me I'm not crazy
(yet...).

For whatever reason, it seems to work OK in a form, see the example I
posted in reply to Geoff....

Rich
Bruce Beacham
2008-10-31 17:30:15 UTC
Permalink
Post by Rich Assaf
I thought I understood this, but having an issue with canGetRow not
seeming to filter out any records.
Am I overlooking something obvious???
No, it's a bug, QAID 2336.

Here's a report dating from 2000:
********
count() does not necessarily respect a cangetrow.

d = new database("dbasesamples")
q = new query([select * from :dbasesamples:fish])
q.rowset.cangetrow = {|| this.fields["name"].value == "" }
? q.rowset.first() // correctly returns false
? q.rowset.count() // should be 0 but returns 10.

q.active = false
********


Here's an exchange:
************
Post by Rich Assaf
If I set canGetRow I find count() ignores the condition.
Moreover, rowcount() then gives -1, even when count() returns
an (incorrect) positive number.
RowCount() is only useful with non-local tables (i.e., SQL Server
tables).
Why should that be so? Any overhead is worth saving, which is what
an existing rowCount() provides.
I don't know why it was designed that way, all I know is that this is
how it was designed.

*** Then me:
Well, I'd rather you talked to R&D again! I can see that navigation
events would slow down a count() (although so must sql filters and index
aspects), but how else should we count a rowset when we have to (and
_want_ to) use canGetRow to use the powerful expression features of
dBASE which are not available to us in SQL expressions?

I'd see altering the OLH as introducing an inconsistency in the way
dBASE works which will erode its power, not enhance it.

I'm eager this row should end as a CanGet, not a Can'tGet. <g>
Post by Rich Assaf
I wouldn't expect the count() method to check the canGetRow
condition. It checks filters, but canGetRow is evaluated
differently.
You can use count() while a filter is active—with the filter property or
the canGetRow event—to count the number of rows that match the filter
condition. This may be time-consuming with large rowsets.

**************

Romain jumped in:
**************
Post by Rich Assaf
Backend servers usually work with snapshots, so you won't see any
additions/deletions/mods the other users are doing, in most of
them you won't even see your own, so the number isn't going to
change, but has nothing to do with reality.
OK, that's fair comment, but in an environment where one _does_ know the
likely variablility of the result (eg an essentially single-user
environment) then it remains a useful indicator.
Post by Rich Assaf
Count() counts all the recs sequentially, but same problem as above
since the other users can change/delete already counted rows, so
the result is more or less useless as well.
Or more or less useful by the same token. I'd rather have it than not!

***********

Finally Marty responded:
**********
Post by Rich Assaf
I have run some tests using your supplied form and table and so
In form_canClose(), when r.count() is executed, if there are
NO rows for which your canGetRow codeblock returns True,
r.count() returns 260 (the total # of rows in the rowset).
If I edit the table, so that 2 rows are missing data and so
will return a True when evaluated by canGetRow, r.count()
returns 2 (the correct # of rows that need editing).
OK, you're seeing the same that I saw when I had cleared out my other
errors (!) and rebooted (seemingly always a good idea with Win98) for
the n'th time.
Post by Rich Assaf
I want to do a few more tests, but I suspect the BDE is returning
an incorrect row count to dB2K.
***************




Bruce
unknown
2008-10-31 18:28:28 UTC
Permalink
On Fri, 31 Oct 2008 17:30:15 +0000 Bruce Beacham
Sender: Bruce Beacham <***@beacham.no-spam.co.uk>
wrote the following in:
Newsgroup: dbase.programming
Post by Bruce Beacham
Post by Rich Assaf
I thought I understood this, but having an issue with canGetRow not
seeming to filter out any records.
Am I overlooking something obvious???
No, it's a bug, QAID 2336.
********
count() does not necessarily respect a cangetrow.
d = new database("dbasesamples")
q = new query([select * from :dbasesamples:fish])
q.rowset.cangetrow = {|| this.fields["name"].value == "" }
? q.rowset.first() // correctly returns false
? q.rowset.count() // should be 0 but returns 10.
q.active = false
********
Bruce,

This is odd. I tried the code above and confirmed the results 'false' and '10'.

I then tried the code below my signature and got 'false' and '0'. So where is the bug?

All done with XP Pro/Plus 2.21


Ivar B. Jessen


//-----
d = new database("dbasesamples")
q = new query()
q.database = d
q.sql = 'select * from fish'
q.active = true
q.rowset.cangetrow = {|| this.fields["name"].value == ""}
? q.rowset.first() // correctly returns false
? q.rowset.count() // correctly returns 0
q.active = false
//-----
Geoff Wass [dBVIPS]
2008-11-01 06:03:35 UTC
Permalink
In article <***@4ax.com>, Ivar B. Jessen
<> says...
Post by unknown
On Fri, 31 Oct 2008 17:30:15 +0000 Bruce Beacham
Newsgroup: dbase.programming
Post by Bruce Beacham
Post by Rich Assaf
I thought I understood this, but having an issue with canGetRow not
seeming to filter out any records.
Am I overlooking something obvious???
No, it's a bug, QAID 2336.
********
count() does not necessarily respect a cangetrow.
d = new database("dbasesamples")
q = new query([select * from :dbasesamples:fish])
q.rowset.cangetrow = {|| this.fields["name"].value == "" }
? q.rowset.first() // correctly returns false
? q.rowset.count() // should be 0 but returns 10.
q.active = false
********
Bruce,
This is odd. I tried the code above and confirmed the results 'false' and '10'.
I then tried the code below my signature and got 'false' and '0'. So where is the bug?
All done with XP Pro/Plus 2.21
Ivar B. Jessen
//-----
d = new database("dbasesamples")
q = new query()
q.database = d
q.sql = 'select * from fish'
q.active = true
q.rowset.cangetrow = {|| this.fields["name"].value == ""}
? q.rowset.first() // correctly returns false
? q.rowset.count() // correctly returns 0
q.active = false
//-----
Ivar,

As I understand it,

? q.rowset.first() // *IN*correctly returns false

It should always return TRUE regardless of whether there are rows in the
rowset or not which meet the criteria. That's how I understand it and
how the on-line help describes it. It should only return FALSE if
something serious fails (ex: Windows screws up or the table is corrupt).


? q.rowset.count() // correctly returns 0

You may be experiencing a "false positive" or just lucky you particular
canGetRow is allowed to work.
--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
.|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
Bruce Beacham
2008-11-01 09:19:47 UTC
Permalink
Hi Geoff
Post by Geoff Wass [dBVIPS]
As I understand it,
? q.rowset.first() // *IN*correctly returns false
It should always return TRUE regardless of whether there are rows in the
rowset or not which meet the criteria. That's how I understand it and
how the on-line help describes it. It should only return FALSE if
something serious fails (ex: Windows screws up or the table is corrupt).
I don't agree with that. If a rowset is set so no rows can be
produced, then first() should return false. Normally it does just
that for me. That's why a scan equivalent is

if r.first()
do
until not r.next()
endif

instead of:

r.first()
do
until not r.next()


If it didn't return false, then code in the do loop which relies on the
presence of a row to get valid field values would be in trouble.


Bruce
Geoff Wass [dBVIPS]
2008-11-02 05:43:53 UTC
Permalink
In article <ST$***@news-server>, ***@beacham.no-
spam.co.uk says...
Post by Bruce Beacham
Hi Geoff
Post by Geoff Wass [dBVIPS]
As I understand it,
? q.rowset.first() // *IN*correctly returns false
It should always return TRUE regardless of whether there are rows in the
rowset or not which meet the criteria. That's how I understand it and
how the on-line help describes it. It should only return FALSE if
something serious fails (ex: Windows screws up or the table is corrupt).
I don't agree with that. If a rowset is set so no rows can be
produced, then first() should return false. Normally it does just
that for me. That's why a scan equivalent is
if r.first()
do
until not r.next()
endif
r.first()
do
until not r.next()
If it didn't return false, then code in the do loop which relies on the
presence of a row to get valid field values would be in trouble.
Bruce
Bruce,

Boy, did I miss the mark on that one. Talk about shooting first and
counting toes later. <sigh> You are right on all counts. I rarely use
DO...UNTIL. I normally do

if r.first( )
do while <condition> and not r.endOfSet
// stuff

r.next( )
enddo
endif


Now, what is interesting to you and Ivar, is that your example:

d = new database("dbasesamples")
q = new query([select * from :dbasesamples:fish])
q.rowset.cangetrow = {|| this.fields["name"].value == "" }
? q.rowset.first() // correctly returns false
? q.rowset.count() // should be 0 but returns 10.

will work correctly like this:

d = new database("dbasesamples")
q = new query([select * from :dbasesamples:fish])
q.rowset.cangetrow = {|| this.fields["name"].value = "" } // <<< one =
? q.rowset.first() // correctly returns false
? q.rowset.count() // should be 0 but returns 10.

As Ivar showed, it also works like this:

d = new database("dbasesamples")
q = new query()
q.database = d
q.sql = 'select * from fish'
q.active = true
q.rowset.cangetrow = {|| this.fields["name"].value == ""}
? q.rowset.first() // correctly returns false
? q.rowset.count() // correctly returns 0
q.active = false

In other words, the bug is specific to the way the query is created.
--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
.|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
Bruce Beacham
2008-11-03 17:18:14 UTC
Permalink
Post by Geoff Wass [dBVIPS]
In other words, the bug is specific to the way the query is created.
Curious, eh?!

And the difference is the database object - in the one case (Ivar's)
it's a specific database object, in the other case (mine) it's
_app.databases[1] - my instancing of a database is purely to open that
database.

Which may bear on another bug affecting _app.databases[1] recently
refreshed.


Bruce
Lysander
2008-11-03 18:22:08 UTC
Permalink
Post by Bruce Beacham
And the difference is the database object - in the one case (Ivar's)
it's a specific database object, in the other case (mine) it's
_app.databases[1] - my instancing of a database is purely to open that
database.
Where is "your" case with using _app.databases[1]? I did not find it in
this newstopic tree.
Since I still have some old dBase code to maintain this could be an
interesting problem for me.
Post by Bruce Beacham
Which may bear on another bug affecting _app.databases[1] recently
refreshed.
Can you help me out to which bug you are referring or maybe even quote
details here? I don't subscribe to the bugs-list (turned out to be
useless somewhere around A.D. 2000) and don't want to re-start that now.
Geoff Wass [dBVIPS]
2008-11-04 05:58:29 UTC
Permalink
In article <***@news-server>, ***@beacham.no-
spam.co.uk says...
Post by Bruce Beacham
Post by Geoff Wass [dBVIPS]
In other words, the bug is specific to the way the query is created.
Curious, eh?!
And the difference is the database object - in the one case (Ivar's)
it's a specific database object, in the other case (mine) it's
_app.databases[1] - my instancing of a database is purely to open that
database.
Which may bear on another bug affecting _app.databases[1] recently
refreshed.
Bruce
Bruce,

It could be looked at that way. I was think more just that you embed the
database name in the SQL SELECT statement, while he uses the DATABASE
object.
--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
.|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
Lysander
2008-11-03 18:16:33 UTC
Permalink
Post by Geoff Wass [dBVIPS]
In other words, the bug is specific to the way the query is created.
You won't get away that easyly... :)

This story looks interesting so I hope you don't mind me adding some
tests using dBase 7 ?

first of all, I don't understand why it should be correct for 'first()'
to return false, when the condition is set to '=""'. I would understand
that this condition should apply to all records and therefore 'count()'
should return the number of total rows in the table, while 'first()'
should return true.


Alas... I am so far not able to reproduce any bug, maybe you can help me
to create a situation where the bug shows up.

I tried the following (please don't mind the old alias name in my
localized version)

Sample 1:
=========
d = new database("vdbsample")
q = new query([select * from :vdbsample:fish])
q.rowset.cangetrow = {|| this.fields["name"].value = ""}
? q.rowset.count()
? q.rowset.first()

count() returns 10, which is correct
first() returns true, which also is correct

Sample 2:
=========
d = new database("vdbsample")
q = new query([select * from :vdbsample:fish])
q.rowset.cangetrow = {|| this.fields["name"].value == ""}
? q.rowset.count()
? q.rowset.first()

using the "set exact" equivalent of 2 ==...
count() returns 0, which is correct
first() returns false, which is correct


Sample 3:
=========
d = new database()
d.databasename = "vdbsample"
d.active = true
q = new query()
q.database = d
q.sql = "select * from fish"
q.active = true
q.rowset.cangetrow = {|| this.fields["name"].value = "Blau"}
? q.rowset.count()
? q.rowset.first()

"Blau" is the localized version of "Blue", to stay in context.
count() returns 2, which is correct
first() returns true, which is correct

To me it looks like everything is okay, no matter how the query-object
is constructed.
unknown
2008-11-03 20:08:18 UTC
Permalink
On Mon, 03 Nov 2008 19:16:33 +0100 Lysander
Sender: Lysander <***@nowhere.de>
wrote the following in:
Newsgroup: dbase.programming
Post by Lysander
Post by Geoff Wass [dBVIPS]
In other words, the bug is specific to the way the query is created.
You won't get away that easyly... :)
This story looks interesting so I hope you don't mind me adding some
tests using dBase 7 ?
first of all, I don't understand why it should be correct for 'first()'
to return false, when the condition is set to '=""'. I would understand
that this condition should apply to all records and therefore 'count()'
should return the number of total rows in the table, while 'first()'
should return true.
Alas... I am so far not able to reproduce any bug, maybe you can help me
to create a situation where the bug shows up.
I tried the following (please don't mind the old alias name in my
Lysander,

I changed vdbsample to dbasesamples and Blau to Blue, and added the following to the bottom of each
sample.

Tested on XP Pro/Plus 2.21.

n = 0
q.rowset.first()
do while not q.rowset.endofset
n++
q.rowset.next()
enddo
? "Manual count = ", ""+n
Post by Lysander
localized version)
=========
d = new database("vdbsample")
q = new query([select * from :vdbsample:fish])
q.rowset.cangetrow = {|| this.fields["name"].value = ""}
? q.rowset.count()
? q.rowset.first()
count() returns 10, which is correct
first() returns true, which also is correct
result is: count() = 10; first() = true; manual = 10
Post by Lysander
=========
d = new database("vdbsample")
q = new query([select * from :vdbsample:fish])
q.rowset.cangetrow = {|| this.fields["name"].value == ""}
? q.rowset.count()
? q.rowset.first()
using the "set exact" equivalent of 2 ==...
count() returns 0, which is correct
first() returns false, which is correct
result is: count() = 10; first() = false; manual = 0 // <-- bug in count()

//Sample 2a:
//=========
d = new database()
d.databasename = "dbasesamples"
d.active = true
q = new query()
q.database = d
q.sql = "select * from fish"
q.active = true
q.rowset.cangetrow = {|| this.fields["name"].value == ""}
? q.rowset.count()
? q.rowset.first()

result is: count() = 0; first() = false; manual = 0
Post by Lysander
=========
d = new database()
d.databasename = "vdbsample"
d.active = true
q = new query()
q.database = d
q.sql = "select * from fish"
q.active = true
q.rowset.cangetrow = {|| this.fields["name"].value = "Blau"}
? q.rowset.count()
? q.rowset.first()
"Blau" is the localized version of "Blue", to stay in context.
count() returns 2, which is correct
first() returns true, which is correct
result is: count() = 2; first() = true; manual = 2
Post by Lysander
To me it looks like everything is okay, no matter how the query-object
is constructed.
I see a bug in sample 2, wheres Sample 2a is correct. It looks like Visual dBase 7 is better than
Plus :-)


Ivar B. Jessen
*Lysander*
2008-11-03 20:31:15 UTC
Permalink
Post by unknown
I see a bug in sample 2, wheres Sample 2a is correct. It looks like Visual dBase 7 is better than
Plus :-)
It certainly is, in some places, because later versions never only
removed bugs, they also put some in to keep a good balance :)
Which reminds me again of the unfulfilled promise I made to Marty about
helping him to eliminate the StoredProc bug in versions > 7.01.

But in this case I am not convinced. Although... they actually did some
changes to query-objects and probably have broken something unnoticed.

Or maybe my test-suite is different.
Or maybe my installation of the BDE is different...

A bug known in all details is not a danger. It's to not know exactly
under which circumstances a bug takes effect and which effect it takes
that makes them dangerous.

I would like to assist in nailing down what really _IS_ causing that
bug, but first I would have to be able to reproduce it
Geoff Wass [dBVIPS]
2008-11-04 06:02:09 UTC
Permalink
Post by *Lysander*
Which reminds me again of the unfulfilled promise I made to Marty about
helping him to eliminate the StoredProc bug in versions > 7.01.
André,

It's never too late. :-D


(It's the type of thing I would like to see fixed).
--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
.|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
*Lysander*
2008-11-03 20:32:51 UTC
Permalink
Post by unknown
Tested on XP Pro/Plus 2.21.
Hey! I thought you were using the most recent version!
If it's in 2.21 I probably have a chance of reproducing it also.
*Lysander*
2008-11-03 20:51:45 UTC
Permalink
Post by unknown
result is: count() = 10; first() = false; manual = 0 // <-- bug in count()
I see a bug in sample 2, wheres Sample 2a is correct. It looks like Visual dBase 7 is better than
Plus :-)
I just tried the same at my system at home.
Works fine, count() is returning 0, properly.

Here have XP/SP3 (in the company it's Win2000, since I don't run dBase
under Vista anymore).

Here (at home) I do have the english version of "fish" as well, but no
BDE-Alias for it... anyway, obviously it is not the table or something
as weird.
unknown
2008-11-03 21:58:53 UTC
Permalink
On Mon, 03 Nov 2008 21:51:45 +0100 *Lysander*
Sender: *Lysander* <***@nowhere.com>
wrote the following in:
Newsgroup: dbase.programming
Post by *Lysander*
Post by unknown
result is: count() = 10; first() = false; manual = 0 // <-- bug in count()
I see a bug in sample 2, wheres Sample 2a is correct. It looks like Visual dBase 7 is better than
Plus :-)
I just tried the same at my system at home.
Works fine, count() is returning 0, properly.
Here have XP/SP3 (in the company it's Win2000, since I don't run dBase
under Vista anymore).
Here (at home) I do have the english version of "fish" as well, but no
BDE-Alias for it... anyway, obviously it is not the table or something
as weird.
I believe that in the problem case, although the database is opened using the database object, the
query is not informed about the database object, it is only told to use the Xbase type database
alias, :dbasesamples:, which works with tables in workareas. The end result is that rowset.count()
is counting records in the table, whereas rowset.first() is using the rowset buffer.


Ivar B. Jessen
Lysander
2008-11-04 10:30:41 UTC
Permalink
Post by unknown
I believe that in the problem case, although the database is opened using the database object, the
query is not informed about the database object, it is only told to use the Xbase type database
alias, :dbasesamples:, which works with tables in workareas. The end result is that rowset.count()
is counting records in the table, whereas rowset.first() is using the rowset buffer.
Will be an interesting one.
When I turn on my conferences-laptop later on, I might get a chance to
run a test with a more recent version of dBase.
Lysander
2008-11-04 13:42:03 UTC
Permalink
Post by Lysander
Will be an interesting one.
When I turn on my conferences-laptop later on, I might get a chance to
run a test with a more recent version of dBase.
Did I tell you I am not convinced?
Well, I am not convinced. Here is where the fun starts...

I just tried with build2066 of "PLUS" 2.6.1.4, the version is from nov.
2nd 2007.

and.... no bug!

I always get the correct info from rowset.count() and from rowset.first().


This promises to be interesting...
What the heck is different on all of my machines in all of my available
dBase versions?

I am disturbed about this, because I still have some modules running
with dBase and even some DBFs and I am sure that I rely on the results
of rowset.count() in more than just a few places.

For what it's worth, I will have that laptop with me on the conference
next week, where we probably get the chance to get this analysed by more
than 30 dBase-users at once.
Geoff Wass [dBVIPS]
2008-11-04 06:04:10 UTC
Permalink
André,

So not only is it a bug, but a regression.
--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
.|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
Bruce Beacham
2008-11-01 09:20:32 UTC
Permalink
Post by unknown
I then tried the code below my signature and got 'false' and '0'. So where is the bug?
An exceedingly good question!


Bruce
Rich Assaf
2008-11-01 12:42:38 UTC
Permalink
Ivar,

Using the code you posted, substitute a value for Fish Name that should
return some records ("Blue" should return 2 records), I still got 0
records. Seems like it's a command window bug....

Rich
Post by unknown
Post by Bruce Beacham
********
count() does not necessarily respect a cangetrow.
d = new database("dbasesamples")
q = new query([select * from :dbasesamples:fish])
q.rowset.cangetrow = {|| this.fields["name"].value == "" }
? q.rowset.first() // correctly returns false
? q.rowset.count() // should be 0 but returns 10.
q.active = false
********
Bruce,
This is odd. I tried the code above and confirmed the results 'false' and '10'.
I then tried the code below my signature and got 'false' and '0'. So where is the bug?
All done with XP Pro/Plus 2.21
Ivar B. Jessen
//-----
d = new database("dbasesamples")
q = new query()
q.database = d
q.sql = 'select * from fish'
q.active = true
q.rowset.cangetrow = {|| this.fields["name"].value == ""}
q.rowset.cangetrow = {|| this.fields["name"].value == "Blue"}
Post by unknown
? q.rowset.first() // correctly returns false
? q.rowset.count() // correctly returns 0
q.active = false
unknown
2008-11-01 16:07:04 UTC
Permalink
On Sat, 1 Nov 2008 08:42:38 -0400 Rich Assaf
Sender: Rich Assaf <***@hotmail.com>
wrote the following in:
Newsgroup: dbase.programming
Post by Rich Assaf
Ivar,
Using the code you posted, substitute a value for Fish Name that should
return some records ("Blue" should return 2 records), I still got 0
records. Seems like it's a command window bug....
Rich,

No, it is not a command window bug, rather a command window user bug :-)

Notice that the line you inserted has *two* equal signs, meanining it works as SET EXACT ON. To make
your line work you must use the full name.


Example one:
q.rowset.cangetrow = {|| this.fields["name"].value == "Blue Anglefish"}
Result: true/1


With only one equal sign it is sufficient to use only a part of the name value, as the single equal
sign now acts as a "begins with" operator. ( See OLH on Comparison operators ).


Example two:
q.rowset.cangetrow = {|| this.fields["name"].value = "Blue"}
Result: true/2


Example three
q.rowset.cangetrow = {|| this.fields["name"].value == "b"}
Result: true/2


So where is the bug?


Ivar B. Jessen
unknown
2008-11-01 16:12:18 UTC
Permalink
On Sat, 01 Nov 2008 17:07:04 +0100 Ivar B. Jessen <>
Sender: Ivar B. Jessen <>
wrote the following in:
Newsgroup: dbase.programming
Post by unknown
Example three
q.rowset.cangetrow = {|| this.fields["name"].value == "b"}
Result: true/2
Sorry, I forgot to remove an equal sign in Example three. It should be,

q.rowset.cangetrow = {|| this.fields["name"].value = "b"}


Ivar B. Jessen
Marc VdB
2008-11-05 07:58:29 UTC
Permalink
I can reproduce the count-problem and i can confirm Andrés finding, that is
count returns the correct value, when the instantiation of the database and
the query are done following the rules.
You use a non documented feature by calling the new-operator with a
parameter.

d= new database("dbasesamples") // count "is not working"

d= new database()
d.databasename = "dbasesamples"
d.active = true // count works

First, it is not a surprise, that there is a difference in behaviour,
because two different constructors are called in those two cases.

Second, because the constructor with parameter is undocumented, it might be,
that this is not a bug but WAD, we have no way to know...

My 2 cent

Marc
Lysander
2008-11-05 09:26:09 UTC
Permalink
Post by Marc VdB
First, it is not a surprise, that there is a difference in behaviour,
because two different constructors are called in those two cases.
Makes sense if it's reproducible, though it's quite odd that the
different constructor should have effects downward to the rowset-object,
which is not a subclass of the database-object but a class of its own.

I will try out later.
Marc VdB
2008-11-05 09:54:59 UTC
Permalink
Post by Marc VdB
First, it is not a surprise, that there is a difference in behaviour,
because two different constructors are called in those two cases.
Makes sense if it's reproducible, though it's quite odd that the different
constructor should have effects downward to the rowset-object, which is
not a subclass of the database-object but a class of its own.
Indeed, it is odd but not impossible. :-)

CU,
Marc
Lysander
2008-11-05 10:31:21 UTC
Permalink
After reading Ivar's post carefully, i understand that sample 2 is not
working (because of new database with parameter)
and sample 2a (which uses your syntax) gives the correct result (as you
confirmed lateron)
well observed. But that would again mean it's working in versions 7.01
and 7.5 and was broken somewhere down to 2.21. Because _MY_ Sample2 was
working.

I will try that out, later.
Marc VdB
2008-11-05 10:39:07 UTC
Permalink
After reading Ivar's post carefully, i understand that sample 2 is not
working (because of new database with parameter)
and sample 2a (which uses your syntax) gives the correct result (as you
confirmed lateron)
well observed. But that would again mean it's working in versions 7.01 and
7.5 and was broken somewhere down to 2.21. Because _MY_ Sample2 was
working.
Ah ok, i see.
Maybe you can then confirm a regression
unknown
2008-11-05 13:28:27 UTC
Permalink
On Wed, 05 Nov 2008 12:23:45 +0100 Lysander
Sender: Lysander <***@nowhere.de>
wrote the following in:
Newsgroup: dbase.programming
Post by Marc VdB
Maybe you can then confirm a regression
Actually, maybe it's not a bug at all, but a feature? After all, a lot
of executives just like the ability to read a number/sum one or the
other way, depending on their need...
But, no, I cannot confirm.
See attached screenshot.
That should produce the error, but it does not.
The code in the screenshot should not produce the error, but change the following line,

q.sql = "select * from fish"

to the line,

q.sql = "select * from :dbasesamples:fish"

and you should see the error.

Ivar B. Jessen
Lysander
2008-11-05 14:06:01 UTC
Permalink
Post by unknown
The code in the screenshot should not produce the error, but change the following line,
q.sql = "select * from fish"
to the line,
q.sql = "select * from :dbasesamples:fish"
and you should see the error.
Yes, found that out meanwhile.
There is a later message, this time with 2 screenshots.

What you describe is indeed the reason for the error, and also it was
"added as a feature" sometime after dBase 7.5
Marc VdB
2008-11-05 15:56:24 UTC
Permalink
Post by Marc VdB
Maybe you can then confirm a regression
Confirmed. See 2 attached screenshots. Works correctly in 7.5, does not
work correctly in 2.6.1.4.
So we have indeed a new feature ;-)
And it is _NOT_ the constructor of the database-object, where this is
assigned to the query. It is the constructor of the query or the rowset,
as Ivar already had a guess. Since the rowset is constructed as soon as
a query is turned active, it looks indeed like the bug is dependent on
whether you have an explicit database-object assigned to the database
property or if this is done implicitely by parsing the sql-string.
Right you are.
Seems that most of the people use the more OOPish way of assigning the
database to the query-property, else this feature would have shown up
earlier i think...

CU at dbkon

Marc

Marc VdB
2008-11-05 10:05:05 UTC
Permalink
And what also disturbs me is that Ivar wrote he tested exactly with my
code example, using the "documented" constructor, but still got the error.
After reading Ivar's post carefully, i understand that sample 2 is not
working (because of new database with parameter)
and sample 2a (which uses your syntax) gives the correct result (as you
confirmed lateron)

So as i understand it, there is nothing to be disturbed about

CU
Lysander
2008-11-05 09:28:58 UTC
Permalink
Post by Lysander
Makes sense if it's reproducible, though it's quite odd that the
different constructor should have effects downward to the rowset-object,
which is not a subclass of the database-object but a class of its own.
And what also disturbs me is that Ivar wrote he tested exactly with my
code example, using the "documented" constructor, but still got the error.
Loading...