Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default value and creation of new document #4535

Closed
PhantomYdn opened this issue Jul 9, 2015 · 8 comments
Closed

Default value and creation of new document #4535

PhantomYdn opened this issue Jul 9, 2015 · 8 comments
Assignees

Comments

@PhantomYdn
Copy link
Contributor

Guys,

From common logic perspective new ODocument(classA) should already have all fields with default values prepopulated, but OrientDB requires storing of ODocument for population of default values. And more over: this done in strange for this taks method ODocument.validateField().

I suggest:

  1. Refactor ODocument.validateField() (might be in parallel with Validation and hooks order #3429)
  2. Allow to prepopulate ODocument by default values on creation, but not onSave

So, what do you think?

@luigidellaquila
Copy link
Member

IMHO pre-populating ODocument with default values is a good solution. I just have to check how it will affect backward compatibility.

@luigidellaquila luigidellaquila self-assigned this Jul 9, 2015
@lvca
Copy link
Member

lvca commented Jul 9, 2015

:+1

PhantomYdn added a commit to PhantomYdn/orientdb that referenced this issue Jul 11, 2015
@PhantomYdn
Copy link
Contributor Author

Guys, please consider PR. All tests are OK.

@lvca
Copy link
Member

lvca commented Jul 12, 2015

The call to the populateDefaultValues() should be done also on setClass() and setClassname() right?

@PhantomYdn
Copy link
Contributor Author

My idea was that once document created we can do with the object what ever we want, but fields values remains the same. Other wise there are lots of additional questions like: what to do with the a prepopulated field if super class was changed? Clean it or keep it? What to do if new class has the same property by with some default value? And so on.

@lvca
Copy link
Member

lvca commented Jul 12, 2015

The problem is that new ODocument() is semantically equivalent to:

new ODocument().setClassname(<class>);

And what about this?:

new ODocument("ClassA").setClassname("ClassB");

@PhantomYdn
Copy link
Contributor Author

My idea was that in case

new ODocument().setClassname(<class>);

document will not have default values, because class was defined after creation of a document, so population of default values should be explicitly invoked.

In case

new ODocument("ClassA").setClassname("ClassB");

document will have default values from ClassA and changing to ClassB will preserve already set values.

If you disagree: just let me know proper way to resolve that.

lvca added a commit that referenced this issue Aug 24, 2015
@PhantomYdn
Copy link
Contributor Author

Seems to be fixed in #4552. Closing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants