From c2bd6343d321c6af325185ecaf9c00a45fe11c86 Mon Sep 17 00:00:00 2001 From: Taein Min Date: Fri, 19 Apr 2024 23:14:54 +0900 Subject: [PATCH] fix: broken sample code on 'SQLAlchemy Repository Tutorial' (#3405) fix: broken sample code. --- .../01-modeling-and-features.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/tutorials/repository-tutorial/01-modeling-and-features.rst b/docs/tutorials/repository-tutorial/01-modeling-and-features.rst index d739f83443..ce66ea2979 100644 --- a/docs/tutorials/repository-tutorial/01-modeling-and-features.rst +++ b/docs/tutorials/repository-tutorial/01-modeling-and-features.rst @@ -7,12 +7,6 @@ to make working with models easier. .. tip:: The full code for this tutorial can be found below in the :ref:`Full Code <01-repo-full-code>` section. -.. literalinclude:: /examples/contrib/sqlalchemy/sqlalchemy_declarative_models.py - :language: python - :caption: app.py - :lines: 9,18,19,20 - :linenos: - Modeling -------- @@ -21,6 +15,12 @@ We'll start by creating the ``Author`` table, utilizing the :class:`UUIDBase ` class. To keep things simple, our first model will encompass only three fields: ``id``, ``name``, and ``dob``. +.. literalinclude:: /examples/contrib/sqlalchemy/sqlalchemy_declarative_models.py + :language: python + :caption: app.py + :lines: 9,11,18,19,20 + :linenos: + The book entity is not considered a "strong" entity and therefore always requires an author to be created. We need to configure our SQLAlchemy classes so that it is aware of this relationship. We will extend the ``Author`` model by incorporating a ``Book`` @@ -31,7 +31,7 @@ key constraints when using the ``author_id`` field in each ``Book`` record. .. literalinclude:: /examples/contrib/sqlalchemy/sqlalchemy_declarative_models.py :language: python :caption: app.py - :lines: 9,21,27,28,29,30 + :lines: 9,11,18,19,20,21,22,27,28,29,30 :linenos: By using the audit model, we can automatically record the time a record was created and