Skip to content

Conversation

EliuX
Copy link
Contributor

@EliuX EliuX commented Mar 20, 2020

This PR creates the base for using the SQL Repository in endpoint queries, so we are ready to persist data.

@EliuX EliuX force-pushed the feature/Create-repository-sql-database#25 branch from a2898a8 to cb6104b Compare March 20, 2020 14:35
from time_tracker_api.sql_repository import db, SQLAuditedModel


class PersonSQLModel(db.Model, SQLAuditedModel):
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason to have SQL as part of the class name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because this is the SQLAlchemy model, not a generic one

Copy link
Contributor

Choose a reason for hiding this comment

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

is it extremelly necessat to include SQL as part of the name?

Copy link
Contributor Author

@EliuX EliuX Mar 20, 2020

Choose a reason for hiding this comment

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

Yes, because this model is specific to the SQL implementation. As well as I have the SQL prefix in the repository and other resources related to this particular technology, which has its own characteristics: specific library, handling of commits, rollbacks, the concept of tables, columns and so forth, which is not the same as, for instance, an In-memory implementation, a Mongo Implementation, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just by looking it has the SQL prefix you know that this has SQL-specific logic.

Copy link
Contributor

Choose a reason for hiding this comment

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

We are not going to add support for Mongo, in-memory or so. We should not pollute code with implementation details.

@EliuX EliuX force-pushed the feature/Create-repository-sql-database#25 branch 4 times, most recently from 604e8dd to abf19f8 Compare March 20, 2020 18:07
@EliuX EliuX force-pushed the feature/Create-repository-sql-database#25 branch from abf19f8 to bafb867 Compare March 20, 2020 18:13


def test_create(sql_repository):
"""Should create a new Entry"""
Copy link
Contributor

Choose a reason for hiding this comment

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

why not naming the function/method name as

test_creates_a_new_entry

Then you can get rid of comments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function just tests the function create of the repository, this is a simple and unique name. As I explained before the comment in the function is providing a verbose description of the test.



def test_update(sql_repository):
"""Updates an existing element"""
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to have comments, please remove them and make test name consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In Java I would not have put comments, but this is Python. It is common here put comments even in modules. This is a test that tests the function called update. This is very simple.


return ProjectSQLDao()
else:
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should get rid of all the in-memory implementation.

  1. We will need to implement this in-memory code for all DAOs
  2. We are not going to need this in-memory solution
  3. A Dao should has more implementations if we really need them. For now, just one sql implementation is good enough

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This in-memory code will not be used, this is just basically for documentation purposes. I wanted the other people who work in the project to see how you can create other db mechanisms. And now that the Azure database serverless implementation is showing some issues, it is nice to be aware of how this work.

@EliuX EliuX force-pushed the feature/Create-repository-sql-database#25 branch from a6e994c to 336eb75 Compare March 20, 2020 22:54
@EliuX EliuX force-pushed the feature/Create-repository-sql-database#25 branch from d75da71 to 2ed13c9 Compare March 23, 2020 15:49
@EliuX EliuX merged commit d5a4e5c into master Mar 23, 2020
@EliuX EliuX deleted the feature/Create-repository-sql-database#25 branch March 23, 2020 17:22
@EliuX EliuX self-assigned this Apr 17, 2020
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