Skip to content

Add Singleton Support#15

Open
therealmitchconnors wants to merge 1 commit into
tuomur:masterfrom
therealmitchconnors:master
Open

Add Singleton Support#15
therealmitchconnors wants to merge 1 commit into
tuomur:masterfrom
therealmitchconnors:master

Conversation

@therealmitchconnors

Copy link
Copy Markdown

Implement QuerySingle methods and classes to support singleton
operations.

Implement QuerySingle methods and classes to support singleton
operations.
@therealmitchconnors

therealmitchconnors commented Nov 21, 2017

Copy link
Copy Markdown
Author

Fixes #14

@tuomur

tuomur commented Nov 22, 2017

Copy link
Copy Markdown
Owner

Thanks for looking into this. Copying all of query.py just for some small changes seems a bit too excessive. You could likely implement this in a more leaner way with a Entity subclass that returns the singleton's URL when queried. Metadata also would need to properly construct the Singleton classes.

@therealmitchconnors

Copy link
Copy Markdown
Author

I have trimmed out all the functions that were not used by singletons (filter, top, skip, etc). I see that I could trim a bit more from the get_options and new_query functions where they relate to those operators to reduce the size of this feature, but I think the rest of the class is being used...

With regard to the Entity subclass, what would that look like? With reference to the TripPin service, we would construct the Person entity, as well as a PersonSingle sublcass? How would we execute the query? Would the query return a Person entity or a PersonSingle entity?

Thanks!

@tuomur

tuomur commented Nov 23, 2017

Copy link
Copy Markdown
Owner

I had a look at Singletons too, and ended up rewriting some of the EntitySet handling. Check it out at 9bfff03 (new branch)

I tested this with the TripPin URL you mentioned.

@therealmitchconnors

Copy link
Copy Markdown
Author

That looks promising. How would you go about using this model from the Service class? Something like service.query(Customer, 'CustomerSingleton')?

@tuomur

tuomur commented Nov 27, 2017

Copy link
Copy Markdown
Owner

Sorry, forgot to mention the usage changes :)

Service.entities now contains the EntitySets with their original names (People, NewComePeople, Me) and those classes can be queried as usual. So for example:

Service = ODataService('http://services.odata.org/TripPinRESTierService/', reflect_entities=True)
Me = Service.entities['Me']
me = Service.query(Me).first()

@therealmitchconnors

Copy link
Copy Markdown
Author

I see, so singletons are effectively just an array of one?

@tuomur

tuomur commented Feb 22, 2018

Copy link
Copy Markdown
Owner

I merged my singleton branch to master.

@tpow

tpow commented Jan 21, 2019

Copy link
Copy Markdown

This pull request can be closed. @tuomur implemented singleton support and merged it to master.

@tpow tpow mentioned this pull request Feb 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants