Page 1 of 1

databaseManager.saveData oddity [SOLVED]

PostPosted: Thu Mar 28, 2019 6:53 pm
by steve1376656734
I am facing an issue where I cannot save some records and cannot figure out why. I have set a breakpoint where I think the problem is occurring and this is what I find:

1. I have some edited records which I confirmed by running databaseManager.getEditedRecords()
2. I run databaseManager.saveData() which returns false. From this, I assume the records have not been saved for some reason.
3. I run databaseManager.getFailedRecords() which returns no records.
4. I run databaseManager.getEditedRecords which shows the same records as in step 1.

debug.png
debug.png (235.17 KiB) Viewed 3011 times

During the above there are no errors shown in the developer console, no errors in the Servoy log and no SQL is issued to the database.

Can anyone suggest what may be happening?

Thanks.

Re: databaseManager.saveData oddity

PostPosted: Fri Mar 29, 2019 10:08 am
by Manolo_Etec
Hi Steve.
When I have this problem, normaly is because a have in an entity a condition that return false or when there is a duplicate pk, but normaly it return an error of duplicate pk that you can see....

Re: databaseManager.saveData oddity

PostPosted: Tue Apr 16, 2019 11:13 am
by dev-ws-011
Hi Steve,

The reason for save to fail can be as follows:

    1. Column is updated with duplicate pk after new/edit record.
    2. Column data type mismatch e.g. date is expected but string is passed.
    3. Data validation failure for not null on column has occurred.
Check for above mentioned probable issues. Hope this will resolve you problem.

Thanks.

Re: databaseManager.saveData oddity

PostPosted: Tue Apr 16, 2019 12:08 pm
by steve1376656734
Thanks both for the suggestions but unfortunately I cannot tell what the issue was as it appears to have stopped happening without any changes to the code!

Re: databaseManager.saveData oddity

PostPosted: Tue Apr 16, 2019 12:18 pm
by ROCLASI
Hi Steve,

I am not sure if you did but perhaps for next time, also check the PostgreSQL log(s) for exceptions.

Hope this helps.

Re: databaseManager.saveData oddity [SOLVED]

PostPosted: Thu Jul 11, 2019 5:20 pm
by steve1376656734
OK so the same problem cropped up again today with a different table and I was able to finally track down the root cause.

We have a table filter applied to the table in question that does the same job as a tenant flagged column (old solution that has not been upgraded to take advantage of the new functionality yet). The record I was trying to save had a null value in this field and causes this exact same behaviour. Moral of the story, make sure your filtered fields have a value that will allow the record to be read back from the DB when it is saved or else it causes major problems!!