Opened 12 years ago

Closed 11 years ago

#451 closed enhancement (fixed)

Convert all mongokit style .find, .find_one, .one calls over to SQLAlchemy queries

Reported by: Christopher Allan Webber Owned by:
Priority: minor Milestone:
Component: programming Keywords: bitesized
Cc: Elrond, ben@… Parent Tickets:

Description

Right now (esp thanks to Elrond) we managed to have a nice transitional period between Mongo and SQL by having mongokit like queries via .find() .find_one() and .one() reproduction for SQLAlchemy. But it's time to remove those from the codebase. We should start removing all instances of those and replacing them with proper queries.

Attachments (2)

trac#451-convert_mongokit.diff (9.8 KB ) - added by Ben Sturmfels 11 years ago.
Replace transitional calls to 'first_one()' with 'filter_by().first()'.
trac#451-convert_mongokit.2.diff (13.3 KB ) - added by Ben Sturmfels 11 years ago.
Replace transitional calls to 'find_one()', 'find()', and 'one()'.

Download all attachments as: .zip

Change History (18)

comment:1 by Christopher Allan Webber, 12 years ago

Priority: majorminor

Elrond seems unsure that we should remove these, last I spoke to him, for this reason: the mongokit-style queries look pretty nice, and they seem to work well. This is true, but I think it's also true that the less types of syntax our devs need to learn, the better.

The result is that I think this is slightly lower priority, but if someone works on this I'll definitely merge it.

comment:2 by Will Kahn-Greene, 12 years ago

Milestone: 0.3.1

I'm bumping this out of the 0.3.1 milestone. I don't think it was done for 0.3.1 and it's not assigned to anyone.

comment:3 by spaetz, 11 years ago

Is this what we have in mind: see my branch 451_mongolisms. Not complete, but a first step.git://gitorious.org/~spaetz/mediagoblin/spaetz-mediagoblin.git

comment:4 by spaetz, 11 years ago

I just merged the above branch (master changed from 2783c65 to 70f8b2d) removing mongolisms from auth.views and user_pages. There are still quite a few remaining that need to be done though.

comment:5 by Elrond, 11 years ago

Milestone: 0.3.3
Type: defectenhancement

I think, we're done with this for the big part.

The remaining ones can be fixed "on the go". They don't hurt. They're getting handled by our wrapper tools.

I vote for closing.

comment:6 by Christopher Allan Webber, 11 years ago

I think it's worth leaving open until these are closed.

comment:7 by Christopher Allan Webber, 11 years ago

Milestone: 0.3.30.3.4

If someone wants to pick this up, it's not really a complex ticket, it's just very manual. Moving to 0.3.4 anyway.

comment:8 by rodney757, 11 years ago

Keywords: bitesized added

comment:9 by rodney757, 11 years ago

Milestone: 0.4.0

by Ben Sturmfels, 11 years ago

Replace transitional calls to 'first_one()' with 'filter_by().first()'.

comment:10 by Ben Sturmfels, 11 years ago

Cc: sturm added
Status: newreview

I've attached a patch to replace calls to first_one(). I'm happy to proceed with the others, but would love someone to take a quick look to make sure I'm on the right track. (Tests still pass)

comment:11 by Ben Sturmfels, 11 years ago

Cc: ben@… added; sturm removed

comment:12 by rodney757, 11 years ago

Your one the right track :)

Now only .find and .one to go.

Thanks

comment:13 by rodney757, 11 years ago

Status: reviewaccepted

by Ben Sturmfels, 11 years ago

Replace transitional calls to 'find_one()', 'find()', and 'one()'.

comment:14 by Ben Sturmfels, 11 years ago

Status: acceptedreview

Thanks rodney757. I've attached an updated patch replacing all of find_one(), find() and one().

comment:15 by rodney757, 11 years ago

Okay, So I looked over this and everything looks good to me. All tests pass as well.

I talked to cwebb on irc about the db.MediaEntry.query.filter_by() in gmg_commands/import_export.py and we agreed that this is probably better then using .query.all() since it returns a query object vs a list.

comment:16 by rodney757, 11 years ago

Resolution: fixed
Status: reviewclosed

Committed! Thanks for the patch.

Note: See TracTickets for help on using tickets.