How can we improve Breeze.js?

Entity creation: Initialise Foreign Key - Properties which are Nullable with Null (Currently it's 0)

i'm currently working on a angular/breeze/web api - based solution.
to simplify user input i'm marking all the required fields thanks to the getValidationErrors() method. in this case the user presses an add button on a grid, then a new entity gets created and angular takes care of the rest. sounds good right?
This works for regular Properties but not for Foreign Keys because they get created with an "0" Value (I didn't assign defaults and the column is not nullable) and therefore validationErrors is empty after entity creation which is imho wrong.

additional information:
http://stackoverflow.com/questions/20339402/breeze-entity-creation-foreign-key-column-is-set-to-0-by-default

19 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Anonymous shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

2 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • SteveB commented  ·   ·  Flag as inappropriate

    A note about implementing this change: It seems unwise to simply change the behavior of breeze as described here since that would change the behavior rather drastically. I suppose a good solution is to provide a single option to use null for all properties (even if it's nonnullable).

  • SteveB commented  ·   ·  Flag as inappropriate

    I think I agree with this suggestion -- even though there are a couple technical issues with the wording. First, I think you meant to say 'nonnullable' instead of 'nullable' in the title. Second, from my understanding the issue is not specific to fkeys. It's that any nonnullable property is initialized to a nonnull value. But, as you say, this leads to problems. I agree that the current behavior of breeze is wrong. I'd say it is a design bug/error. It is dangerous since it leads to bad data being saved. It's better to fail save (since a non-nullable property is null) than to accidentally save a value that is valid (passes validation) but is arbitrary WRT the application.

Feedback and Knowledge Base