This happens when a form has a WHERE clause set.
Can NetMake please review and fix this?
To reproduce the bug I created a table containing only the following records
(the “id” field is not shown below but it exists in the table and it is an auto increment integer):
Field1 Field2
---------------
man walter
man jim
woman jane
I’ve created a single record form with all default settings, changing only these settings:
Application -> Navigation -> Return after Inserting: Yes
SQL -> Where Condition -> Field1 = “man”
and running the form shows correctly that it has loaded the first of 2 records having Field1 = “man”: [1 of 2].
After adding a a new record filling field1 with “man”
The record is added and the form returns with the total amount of records calculated correctly: 3 (correct taking into consideration the where clause),
But the current record position between square brackets is wrong [4 of 3].
4 is the the table total records: 3 man + 1 woman, so SC is ignoring the form where clause:
Note that when inserting the third “man” record, if the table had 105 records with fields1 <> “man”, the Row Counter would show: [108 of 3].
SQL debugging on
Enabling debug mode the following select statements are shown:
[B](pdo-mysql): select last_insert_id()
(pdo-mysql): SELECT COUNT(*) FROM table1 WHERE ((id < 10)) [/B]
Is the record position (4) wrong because it is calculated by using “WHERE id < last_insert_id”? (see statements above).
If so, the error is caused by ignoring the form original where clasue.
Shouldn’t the correct statement be SELECT COUNT(*) FROM table1 WHERE ((id < 10) AND (field1 = “man”)) ?
Another select shown by debugging:
(pdo-mysql): SELECT count(*) from table1 where field1 = "man"
Note that the total amount of records (3) is correctly calculated by taking into consideration the form original where clause.