-
Notifications
You must be signed in to change notification settings - Fork 16
SQLAlchemy models, refactor helpers calls #73
Conversation
Drop dataset and use pure SQLAlchemy models. I'm still not 100% happy with how the tasks don't use the same interface for getting (and updating) jobs than the rest of the app, just because they don't use the same session. We can probably pass the session as an optional parameter to the helpers and use these consistently.
One important thing to note is that the factories explicitly created the object on the database in all cases. This is to simplify tests where two sessions are used (tasks). We can revisit this in the future but I don't think it will be an issue.
Rather than having SQLAlchemy all over the place let's keep these at the helpers level so plugins or tasks don't need to worry about SA calls. This implies that sometimes you need to explicitly pass a session if the one you are using is not the default one one `goodtablesio.services` (ie you are in a task). I think the benefits of conceptually separating the interaction with the DB outweigh this minor incovenience. Improved helpers docstrings.
@amercader
|
@roll +1 on the first point, see 904ce90 On moving DB logic to models, I'm also happy to do that. I'm not so keen on static methods on classes though, specially on the actual SQLAlchemy models. I think plugins should just pass and get dicts around and not actual SA objects. What about keeping the helpers as they are but moving them to the
Usage: from goodtablesio import models
job = models.job.create(params) or this, whatever we prefer: job = models.job.create(**params) |
@amercader |
As per discussion in #73, eg: job = models.job.create(params)
…ables.io into sqlalchemy-models
@roll please have a look I've moved all db related methods to While I was at it I renamed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
fixes #33
@roll This is ready to review.
There are two main things:
helpers
should be the main API to interact with jobs and other future objects. Because tasks use a different session, this implies that sometimes you need to explicitly pass a session to the helper methods. I think the benefits of conceptually separating the interaction with the DB outweigh this minor inconvenience.Let me know what you think