Serious issue saving record with duplicate unique values

Dear Backendless,

I have a table with 2 relationships to other tables only. The definition is as follows:

table latest_post
  post - Data relation (1:1) post - <no default value> - Non Null
  owner - Data Relation (1:1) User - <no default value> - Non Null, Unique Value

I create records in this table from a Post Create event on the post table in Java.
The code is as follows:

  public void afterCreate( RunnerContext context, Post post, ExecutionResult<Post> result ) throws Exception
      Latest_post latest_post;
      Backendless.UserService.login("1da1ac26-b7b6-4238-8453-cc5fcc5cb785", "SuperUserPassword");
      latest_post = new Latest_post();
    catch( BackendlessException exception )
    	 System.out.println("Exception " + exception.getDetail());    	

Every time I create a new post in the post table, this trigger runs and creates a record in the latest_post table. The problem is that it completely breaks the constraints on the owner column. If a previous record exists with the same owner, then the field is nullified before the new record is created. In other words, neither the Unique Value nor the Non Null constraint are respected.
Expected behaviour: throw an exception that a record already exists.


Hi Emmanuel,

We will investigate this problem and report back. My understanding was that we do not support constraints for relations, but I see that console allows you to set them. It might be a problem on the console side (the fact that it allows).

Once again, we will check and report the status.


Thanks for the quick answer!

As a workaround, I will store the ID of the objects in separate columns and setup the constraints on these.

Hello, Emmanuel!

We’ve released a fix for this problem. Can you please try again?
best regards,

Hi Alex,
I’ve modified my code to work around this bug so I’ll try as soon as I get a chance to go back to a previous version.