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

Issue #1498 - Mongo -> MongoClient Transition #1552

Merged
merged 3 commits into from May 2, 2014

Conversation

Projects
None yet
3 participants
@eltimn
Copy link
Member

eltimn commented Apr 26, 2014

Deprecated MongoAddress, MongoHostBase, MongoHost, MongoSet, and the MongoDB functions that take them as an argument.

Deprecated the MongoDB functions that take Mongo as an argument and added ones that take MongoClient as an argument.

Deprecated MongoRecord.save (no arguments).

Added default argument of true to MongoRecord.save(safe: Boolean) function.

Added MongoRecord.save(inst: BaseRecord) function that uses the WriteConcern configured in Mongo/MongoClient.

Added saveBox(), updateBox(), and deleteBox_! functions to MongoRecord that all wrap the related functions in tryo and return a Box.

Internally, MongoDB still uses Mongo, so no behavior will change unless MongoClient (or MongoOptions with a different WriteConcern) is used.

Issue 1498 - Mongo -> MongoClient Transition
Deprecated MongoAddress, MongoHostBase, MongoHost, MongoSet, and the MongoDB functions that take them as an argument.

Deprecated the MongoDB functions that take Mongo as an argument and added ones that take MongoClient as an argument.

Deprecated MongoRecord.save (no arguments).

Added default argument of `true` to MongoRecord.save(safe: Boolean) function.

Added MongoRecord.save(inst: BaseRecord) function that uses the WriteConcern configured in Mongo/MongoClient.

Added saveBox(), updateBox(), and deleteBox_! functions to MongoRecord that all wrap the related functions in tryo and return a Box.

Internally, MongoDB still uses Mongo, so no behavior will change unless MongoClient (or MongoOptions with a different WriteConcern) is used.
def save: MyType = save(false)

/**
* Try to save the instance and return the instance in a Box.
*/
def saveBox(): Box[MyType] = tryo {

This comment has been minimized.

@Shadowfiend

Shadowfiend Apr 26, 2014

Member

Would it make sense for each of these to have a safe parameter like save does?

This comment has been minimized.

@eltimn

eltimn Apr 27, 2014

Author Member

I would prefer they used the settings configured on Mongo/MongoClient and not have to pass something in every time.

This comment has been minimized.

@Shadowfiend

Shadowfiend Apr 27, 2014

Member

Yeah, that's fair, actually.

sd2.save(false) // no exception thrown
sd2.save(true) must throwA[MongoException]
sd2.saveBox() match {
case Failure(msg, _, _) => msg must contain("E11000 duplicate key error")

This comment has been minimized.

@Shadowfiend

Shadowfiend Apr 26, 2014

Member

Hm… I thought the default behavior of Mongo vs MongoClient should be different?

This comment has been minimized.

@eltimn

eltimn Apr 27, 2014

Author Member

They are. It was just a poorly written test.

I wish there was a Box matcher, like there is with Option. I started one a few years ago, maybe I should dust that off ...

This comment has been minimized.

@Shadowfiend

Shadowfiend Apr 27, 2014

Member

Could be good. I usually want to verify value and box, and must_== works for that in cases of Full or Empty, but that doesn't necessarily as well for failures. Though you can use must beLike to reasonable effect in those cases.

This comment has been minimized.

@eltimn

eltimn Apr 27, 2014

Author Member

I hadn't known of beLike's existence. That will be very useful. I most often want to just check the text of a failure, which beLike handles pretty well.

@Shadowfiend

This comment has been minimized.

Copy link
Member

Shadowfiend commented Apr 26, 2014

Couple of small questions, but overall this looks good. I guess we'll need to remove some of the other stuff that got deprecated for Lift 3, as well, but we can deal with that once this gets merged to 2.6 and we merge 2.6 back to lift_30.

@Shadowfiend

This comment has been minimized.

Copy link
Member

Shadowfiend commented Apr 26, 2014

It would also be handy if someone who used mongo-record tested this; I unfortunately don't.

@Shadowfiend

This comment has been minimized.

Copy link
Member

Shadowfiend commented Apr 28, 2014

👍 from me, will way t a few days to see if someone who uses mongo-record can give it a spin; otherwise we'll go for it.

@Shadowfiend

This comment has been minimized.

Copy link
Member

Shadowfiend commented May 2, 2014

Hokay, let's do this.

Shadowfiend added a commit that referenced this pull request May 2, 2014

Merge pull request #1552 from lift/tcn_issue_1498_2
Issue #1498 - Mongo -> MongoClient Transition

Deprecates old constructors that interact with Mongo and Lift's abstractions
over it and adds versions that deal with MongoClient.

Also deals with WriteConcern differences in MongoClient vs Mongo, and adds
a couple of new convenience methods to MongoRecord.

@Shadowfiend Shadowfiend merged commit 5a8f5cf into master May 2, 2014

@Shadowfiend Shadowfiend deleted the tcn_issue_1498_2 branch May 2, 2014

@eltimn

This comment has been minimized.

Copy link
Member Author

eltimn commented May 2, 2014

Thanks for merging this. Let me know when you sync up lift_30 and I'll update that with the changes here.

@Shadowfiend

This comment has been minimized.

Copy link
Member

Shadowfiend commented May 2, 2014

Sounds great! I may open a PR for this merge, just because there are going to be more moving parts than usual; we'll see.

@Shadowfiend

This comment has been minimized.

Copy link
Member

Shadowfiend commented May 2, 2014

Just ran the master->lift_30 merge. I'll let you do your Mongo pass there before dealing with merging #1534 .

@fmpwizard fmpwizard added this to the 2.6-M4 milestone Jun 7, 2014

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