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

storeAs option for references #1349

Merged
merged 20 commits into from
May 13, 2016

Conversation

coudenysj
Copy link
Contributor

As discusses in #807, this pull requests starts using a storeAs option to support different storage formats:

  • simple: $id
  • partial: $id, $ref
  • full: $id, $ref, $db

With full being the default.

/**#@+
* The types of storeAs references
*
* TODO move this to a different class?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good place 👍

@alcaeus
Copy link
Member

alcaeus commented Jan 23, 2016

Thanks for getting started with this, this should clean up reference mapping a bit!

I know I'm the one to come up with "partial" and "full", but I've "seen some things" that make me want to change the naming to include "dbref" in the name, especially since that's the name of the structure we're actually storing. Likewise, we could rename the "simple" option to "id" as a reference of that type would only store the ID of the reference object, not a DBRef object.

I'm really looking forward to this 👍

@coudenysj
Copy link
Contributor Author

I'm not sure if we should include the dbRef name, because the "simple" option would not use the the DBRef structure.

The 'simple' vs 'id' argument I can follow.

@alcaeus
Copy link
Member

alcaeus commented Jan 28, 2016

@coudenysj the "simple" option does not store it as DBRef and thus doesn't have "dbref" in its name. If we store it as "dbref" we might as well rename the storage option to include "dbref" in the name ;)

@coudenysj
Copy link
Contributor Author

@alcaeus Are you talking about the "storeAs" name? Or the different values it can have?

@alcaeus
Copy link
Member

alcaeus commented Jan 28, 2016

Sorry, I was talking about the values it can have. IMO, "dbref" is more descriptive than "full" - same goes for partial as it's actually a partial dbref object (still dislike the wording "partial" in there, don't have an alternative though)

@malarzm
Copy link
Member

malarzm commented Jan 28, 2016

Gotta love naming things

@coudenysj
Copy link
Contributor Author

So you want to make the values really descriptive.

Some more brain dumps:

@alcaeus
Copy link
Member

alcaeus commented Mar 12, 2016

@coudenysj what's the state of this? I could use some of this stuff for some sharding magic in references but want to hold off until we're done changing the whole simple vs. full thing. Any progress you can report?

@coudenysj
Copy link
Contributor Author

Hi @alcaeus, no further progress on this. If we can agree upon naming, I can do some more programming to finalize this.

@alcaeus
Copy link
Member

alcaeus commented Mar 16, 2016

Right. How about id, dbRef and dbRefWithDb? Sounds silly but in the end it's the term that best explains the difference between dbRef and dbRefWithDb. What do you think?

@coudenysj
Copy link
Contributor Author

I can live with that :). Let's see if I can work on it.

coudenysj pushed a commit to coudenysj/mongodb-odm that referenced this pull request Mar 18, 2016
@coudenysj
Copy link
Contributor Author

Owkay, so I've added the option to all drivers and scanned the code for the "simple" reference.

Is it the correct approach if I try to "redirect" the "simple" option to the "storeAs: id" option, and refactor all the "simple" checks?

@alcaeus
Copy link
Member

alcaeus commented Mar 19, 2016

Yes. Within ODM we can change all checks from simple to storeAs == 'ID'. I don't think we need to keep the simple flag around in the mapping for BC reasons - opinions @malarzm @jmikola?

@malarzm
Copy link
Member

malarzm commented Mar 19, 2016

I think we should keep it

@coudenysj
Copy link
Contributor Author

I will try to support both (simple=true triggers storeAs=id and storeAs=id triggers simple=true). I will however refactor all "simple" checks to "storeAs" checks in the code.

@coudenysj coudenysj force-pushed the feature/reference-storeAs branch from dc3b386 to 7ccc6bf Compare April 15, 2016 17:13
coudenysj pushed a commit to coudenysj/mongodb-odm that referenced this pull request Apr 15, 2016
@coudenysj
Copy link
Contributor Author

If this TravisCI check comes back positive, I think this pull request is ready.

@coudenysj
Copy link
Contributor Author

@alcaeus @malarzm Any suggestions of unit tests that should be added?

@coudenysj coudenysj changed the title WIP: storeAs option for references storeAs option for references Apr 15, 2016
@@ -314,6 +314,8 @@ a certain class, you can optionally specify a default discriminator value:
Simple References
-----------------

TODO: Rewrite this to reflect the new ``storeAs`` approach.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commenting on this so we don't forget to revisit before merging

@malarzm malarzm added this to the 1.1 milestone Apr 16, 2016
@alcaeus
Copy link
Member

alcaeus commented May 11, 2016

#1406 has been merged into 1.0.x and master - you can rebase this PR and update the fix.

Jachim Coudenys added 19 commits May 11, 2016 21:02
@coudenysj coudenysj force-pushed the feature/reference-storeAs branch from 916cb66 to 191c63f Compare May 11, 2016 19:19
@coudenysj
Copy link
Contributor Author

Processed changes from #1406, so this PR is ready for final review.


.. note::

The ``storeAs=id`` option used to call a "simple reference". The old syntax is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"used to be called"

@malarzm
Copy link
Member

malarzm commented May 12, 2016

LGTM, thanks @coudenysj for working on this!

@alcaeus alcaeus merged commit a4d5226 into doctrine:master May 13, 2016
@alcaeus
Copy link
Member

alcaeus commented May 13, 2016

Thank you @coudenysj!

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

Successfully merging this pull request may close these issues.

3 participants