databaseManager.saveData oddity [SOLVED]

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.

[attachment=0]debug.png[/attachment]
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.

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…

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.

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!

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.

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!!