sqlacodegen 3.1.1__tar.gz → 4.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sqlacodegen-4.0.0/.github/FUNDING.yml +1 -0
- sqlacodegen-4.0.0/.github/dependabot.yml +13 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/.github/workflows/publish.yml +8 -5
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/.github/workflows/test.yml +4 -4
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/.pre-commit-config.yaml +5 -2
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/CHANGES.rst +60 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/PKG-INFO +34 -12
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/README.rst +30 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/pyproject.toml +14 -14
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/src/sqlacodegen/cli.py +1 -5
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/src/sqlacodegen/generators.py +478 -125
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/src/sqlacodegen/models.py +2 -2
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/src/sqlacodegen/utils.py +1 -7
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/src/sqlacodegen.egg-info/PKG-INFO +34 -12
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/src/sqlacodegen.egg-info/SOURCES.txt +2 -0
- sqlacodegen-4.0.0/src/sqlacodegen.egg-info/requires.txt +14 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/tests/test_generator_declarative.py +1965 -668
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/tests/test_generator_sqlmodel.py +126 -1
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/tests/test_generator_tables.py +261 -6
- sqlacodegen-3.1.1/src/sqlacodegen.egg-info/requires.txt +0 -25
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/.github/ISSUE_TEMPLATE/bug_report.yaml +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/.github/ISSUE_TEMPLATE/features_request.yaml +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/.github/pull_request_template.md +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/.gitignore +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/CONTRIBUTING.rst +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/LICENSE +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/setup.cfg +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/src/sqlacodegen/__init__.py +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/src/sqlacodegen/__main__.py +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/src/sqlacodegen/py.typed +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/src/sqlacodegen.egg-info/dependency_links.txt +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/src/sqlacodegen.egg-info/entry_points.txt +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/src/sqlacodegen.egg-info/top_level.txt +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/tests/__init__.py +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/tests/conftest.py +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/tests/test_cli.py +0 -0
- {sqlacodegen-3.1.1 → sqlacodegen-4.0.0}/tests/test_generator_dataclass.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
tidelift: pypi/sqlacodegen
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Keep GitHub Actions up to date with GitHub's Dependabot...
|
|
2
|
+
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
|
|
3
|
+
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
|
|
4
|
+
version: 2
|
|
5
|
+
updates:
|
|
6
|
+
- package-ecosystem: github-actions
|
|
7
|
+
directory: /
|
|
8
|
+
groups:
|
|
9
|
+
github-actions:
|
|
10
|
+
patterns:
|
|
11
|
+
- "*" # Group all Actions updates into a single larger pull request
|
|
12
|
+
schedule:
|
|
13
|
+
interval: quarterly
|
|
@@ -14,9 +14,9 @@ jobs:
|
|
|
14
14
|
runs-on: ubuntu-latest
|
|
15
15
|
environment: release
|
|
16
16
|
steps:
|
|
17
|
-
- uses: actions/checkout@
|
|
17
|
+
- uses: actions/checkout@v6
|
|
18
18
|
- name: Set up Python
|
|
19
|
-
uses: actions/setup-python@
|
|
19
|
+
uses: actions/setup-python@v6
|
|
20
20
|
with:
|
|
21
21
|
python-version: 3.x
|
|
22
22
|
- name: Install dependencies
|
|
@@ -24,7 +24,7 @@ jobs:
|
|
|
24
24
|
- name: Create packages
|
|
25
25
|
run: python -m build
|
|
26
26
|
- name: Archive packages
|
|
27
|
-
uses: actions/upload-artifact@
|
|
27
|
+
uses: actions/upload-artifact@v6
|
|
28
28
|
with:
|
|
29
29
|
name: dist
|
|
30
30
|
path: dist
|
|
@@ -38,7 +38,10 @@ jobs:
|
|
|
38
38
|
id-token: write
|
|
39
39
|
steps:
|
|
40
40
|
- name: Retrieve packages
|
|
41
|
-
uses: actions/download-artifact@
|
|
41
|
+
uses: actions/download-artifact@v7
|
|
42
|
+
with:
|
|
43
|
+
name: dist
|
|
44
|
+
path: dist
|
|
42
45
|
- name: Upload packages
|
|
43
46
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
44
47
|
|
|
@@ -49,7 +52,7 @@ jobs:
|
|
|
49
52
|
permissions:
|
|
50
53
|
contents: write
|
|
51
54
|
steps:
|
|
52
|
-
- uses: actions/checkout@
|
|
55
|
+
- uses: actions/checkout@v6
|
|
53
56
|
- id: changelog
|
|
54
57
|
uses: agronholm/release-notes@v1
|
|
55
58
|
with:
|
|
@@ -10,19 +10,19 @@ jobs:
|
|
|
10
10
|
strategy:
|
|
11
11
|
fail-fast: false
|
|
12
12
|
matrix:
|
|
13
|
-
python-version: ["3.
|
|
13
|
+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
14
14
|
runs-on: ubuntu-latest
|
|
15
15
|
steps:
|
|
16
|
-
- uses: actions/checkout@
|
|
16
|
+
- uses: actions/checkout@v6
|
|
17
17
|
- name: Set up Python ${{ matrix.python-version }}
|
|
18
|
-
uses: actions/setup-python@
|
|
18
|
+
uses: actions/setup-python@v6
|
|
19
19
|
with:
|
|
20
20
|
python-version: ${{ matrix.python-version }}
|
|
21
21
|
allow-prereleases: true
|
|
22
22
|
cache: pip
|
|
23
23
|
cache-dependency-path: pyproject.toml
|
|
24
24
|
- name: Install dependencies
|
|
25
|
-
run: pip install -e .[
|
|
25
|
+
run: pip install --group test -e .[sqlmodel,citext,geoalchemy2,pgvector]
|
|
26
26
|
- name: Test with pytest
|
|
27
27
|
run: coverage run -m pytest
|
|
28
28
|
- name: Upload Coverage
|
|
@@ -16,14 +16,14 @@ repos:
|
|
|
16
16
|
- id: trailing-whitespace
|
|
17
17
|
|
|
18
18
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
19
|
-
rev: v0.
|
|
19
|
+
rev: v0.14.10
|
|
20
20
|
hooks:
|
|
21
21
|
- id: ruff
|
|
22
22
|
args: [--fix, --show-fixes]
|
|
23
23
|
- id: ruff-format
|
|
24
24
|
|
|
25
25
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
26
|
-
rev: v1.
|
|
26
|
+
rev: v1.19.1
|
|
27
27
|
hooks:
|
|
28
28
|
- id: mypy
|
|
29
29
|
additional_dependencies:
|
|
@@ -36,3 +36,6 @@ repos:
|
|
|
36
36
|
- id: rst-backticks
|
|
37
37
|
- id: rst-directive-colons
|
|
38
38
|
- id: rst-inline-touching-normal
|
|
39
|
+
|
|
40
|
+
ci:
|
|
41
|
+
autoupdate_schedule: quarterly
|
|
@@ -1,6 +1,66 @@
|
|
|
1
1
|
Version history
|
|
2
2
|
===============
|
|
3
3
|
|
|
4
|
+
**4.0.0**
|
|
5
|
+
|
|
6
|
+
- **BACKWARD INCOMPATIBLE** API changes (for those who customize code generation by
|
|
7
|
+
subclassing the existing generators):
|
|
8
|
+
|
|
9
|
+
* Added new optional keyword argument, ``explicit_foreign_keys`` to
|
|
10
|
+
``DeclarativeGenerator``, to force foreign keys to be rendered as
|
|
11
|
+
``ClassName.attribute_name`` string references
|
|
12
|
+
* Removed the ``render_relationship_args()`` method from the SQLModel generator
|
|
13
|
+
* Added two new methods for customizing relationship rendering in
|
|
14
|
+
``DeclarativeGenerator``:
|
|
15
|
+
|
|
16
|
+
* ``render_relationship_annotation()``: returns the appropriate type annotation
|
|
17
|
+
(without the ``Mapped`` wrapper) for the relationship
|
|
18
|
+
* ``render_relationship_arguments()``: returns a dictionary of keyword arguments to
|
|
19
|
+
``sqlalchemy.orm.relationship()``
|
|
20
|
+
|
|
21
|
+
**4.0.0rc3**
|
|
22
|
+
|
|
23
|
+
- **BACKWARD INCOMPATIBLE** Relationship names changed when multiple FKs or junction tables
|
|
24
|
+
connect to the same target table. Regenerating models will break existing code.
|
|
25
|
+
- Added support for generating Python enum classes for ``ARRAY(Enum(...))`` columns
|
|
26
|
+
(e.g., PostgreSQL ``ARRAY(ENUM)``). Supports named/unnamed enums, shared enums across
|
|
27
|
+
columns, and multi-dimensional arrays. Respects ``--options nonativeenums``.
|
|
28
|
+
(PR by @sheinbergon)
|
|
29
|
+
- Improved relationship naming: one-to-many uses FK column names (e.g.,
|
|
30
|
+
``simple_items_parent_container``), many-to-many uses junction table names (e.g.,
|
|
31
|
+
``students_enrollments``). Use ``--options nofknames`` to revert to old behavior. (PR by @sheinbergon)
|
|
32
|
+
- Fixed ``Index`` kwargs (e.g. ``mysql_length``) being ignored during code generation
|
|
33
|
+
(PR by @luliangce)
|
|
34
|
+
- Fixed the SQLModel generator not adding the ``foreign_keys`` parameters when
|
|
35
|
+
generating multiple relationships between the same two tables
|
|
36
|
+
|
|
37
|
+
**4.0.0rc2**
|
|
38
|
+
|
|
39
|
+
- Add ``values_callable`` lambda to generated native enums column definitions.
|
|
40
|
+
This allows for proper enum value insertion when working with ORM models (PR by @sheinbergon)
|
|
41
|
+
|
|
42
|
+
**4.0.0rc1**
|
|
43
|
+
|
|
44
|
+
- **BACKWARD INCOMPATIBLE** ``TablesGenerator.render_column_type()`` was changed to
|
|
45
|
+
receive the ``Column`` object instead of the column type object as its sole argument
|
|
46
|
+
- Added Python enum generation for native database ENUM types (e.g., PostgreSQL / MySQL ENUM).
|
|
47
|
+
Retained synthetic Python enum generation from CHECK constraints with
|
|
48
|
+
IN clauses (e.g., ``column IN ('val1', 'val2', ...)``). Use ``--options nonativeenums`` to
|
|
49
|
+
disable enum generation for native database enums. Use ``--options nosyntheticenums`` to
|
|
50
|
+
disable enum generation for synthetic database enums (VARCHAR columns with check constraints).
|
|
51
|
+
(PR by @sheinbergon)
|
|
52
|
+
|
|
53
|
+
**3.2.0**
|
|
54
|
+
|
|
55
|
+
- Dropped support for Python 3.9
|
|
56
|
+
- Fix Postgres ``DOMAIN`` adaptation regression introduced in SQLAlchemy 2.0.42 (PR by @sheinbergon)
|
|
57
|
+
- Support disabling special naming logic for single column many-to-one and one-to-one relationships
|
|
58
|
+
(PR by @Henkhogan, revised by @sheinbergon)
|
|
59
|
+
- Add ``include_dialect_options`` option to render ``Table`` and ``Column``
|
|
60
|
+
dialect-specific kwargs and ``info`` in generated code. (PR by @jaogoy)
|
|
61
|
+
- Add ``keep_dialect_types`` option to preserve dialect-specific column types instead of
|
|
62
|
+
adapting to generic SQLAlchemy types. (PR by @jaogoy)
|
|
63
|
+
|
|
4
64
|
**3.1.1**
|
|
5
65
|
|
|
6
66
|
- Fallback ``NotImplemented`` errors encountered when accessing ``python_type`` for
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlacodegen
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0
|
|
4
4
|
Summary: Automatic model code generator for SQLAlchemy
|
|
5
5
|
Author-email: Alex Grönholm <alex.gronholm@nextday.fi>
|
|
6
6
|
Maintainer-email: Idan Sheinberg <ishinberg0@gmail.com>
|
|
@@ -15,24 +15,16 @@ Classifier: Topic :: Database
|
|
|
15
15
|
Classifier: Topic :: Software Development :: Code Generators
|
|
16
16
|
Classifier: Programming Language :: Python
|
|
17
17
|
Classifier: Programming Language :: Python :: 3
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.10
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.11
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.12
|
|
22
21
|
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
-
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
24
|
Description-Content-Type: text/x-rst
|
|
25
25
|
License-File: LICENSE
|
|
26
|
-
Requires-Dist: SQLAlchemy
|
|
26
|
+
Requires-Dist: SQLAlchemy>=2.0.29
|
|
27
27
|
Requires-Dist: inflect>=4.0.0
|
|
28
|
-
Requires-Dist: importlib_metadata; python_version < "3.10"
|
|
29
|
-
Requires-Dist: stdlib-list; python_version < "3.10"
|
|
30
|
-
Provides-Extra: test
|
|
31
|
-
Requires-Dist: sqlacodegen[geoalchemy2,pgvector,sqlmodel]; extra == "test"
|
|
32
|
-
Requires-Dist: pytest>=7.4; extra == "test"
|
|
33
|
-
Requires-Dist: coverage>=7; extra == "test"
|
|
34
|
-
Requires-Dist: psycopg[binary]; extra == "test"
|
|
35
|
-
Requires-Dist: mysql-connector-python; extra == "test"
|
|
36
28
|
Provides-Extra: sqlmodel
|
|
37
29
|
Requires-Dist: sqlmodel>=0.0.22; extra == "sqlmodel"
|
|
38
30
|
Provides-Extra: citext
|
|
@@ -49,6 +41,9 @@ Dynamic: license-file
|
|
|
49
41
|
.. image:: https://coveralls.io/repos/github/agronholm/sqlacodegen/badge.svg?branch=master
|
|
50
42
|
:target: https://coveralls.io/github/agronholm/sqlacodegen?branch=master
|
|
51
43
|
:alt: Code Coverage
|
|
44
|
+
.. image:: https://tidelift.com/badges/package/pypi/sqlacodegen
|
|
45
|
+
:target: https://tidelift.com/subscription/pkg/pypi-sqlacodegen
|
|
46
|
+
:alt: Tidelift
|
|
52
47
|
|
|
53
48
|
This is a tool that reads the structure of an existing database and generates the
|
|
54
49
|
appropriate SQLAlchemy model code, using the declarative style if possible.
|
|
@@ -148,6 +143,12 @@ values must be delimited by commas, e.g. ``--options noconstraints,nobidi``):
|
|
|
148
143
|
* ``noconstraints``: ignore constraints (foreign key, unique etc.)
|
|
149
144
|
* ``nocomments``: ignore table/column comments
|
|
150
145
|
* ``noindexes``: ignore indexes
|
|
146
|
+
* ``nonativeenums``: don't generate Python enum classes for native database ENUM types (e.g., PostgreSQL ENUM); use plain string mapping instead
|
|
147
|
+
* ``nosyntheticenums``: don't generate Python enum classes from CHECK constraints with IN clauses (e.g., ``column IN ('value1', 'value2', ...)``); preserves CHECK constraints as-is
|
|
148
|
+
* ``noidsuffix``: prevent the special naming logic for single column many-to-one
|
|
149
|
+
and one-to-one relationships (see `Relationship naming logic`_ for details)
|
|
150
|
+
* ``include_dialect_options``: render a table' dialect options, such as ``starrocks_partition`` for StarRocks' specific options.
|
|
151
|
+
* ``keep_dialect_types``: preserve dialect-specific column types instead of adapting to generic SQLAlchemy types.
|
|
151
152
|
|
|
152
153
|
* ``declarative``
|
|
153
154
|
|
|
@@ -158,6 +159,11 @@ values must be delimited by commas, e.g. ``--options noconstraints,nobidi``):
|
|
|
158
159
|
* ``nobidi``: generate relationships in a unidirectional fashion, so only the
|
|
159
160
|
many-to-one or first side of many-to-many relationships gets a relationship
|
|
160
161
|
attribute, as on v2.X
|
|
162
|
+
* ``nofknames``: disable improved relationship naming when multiple FKs or
|
|
163
|
+
junction tables connect to the same target. By default, uses FK column names
|
|
164
|
+
for one-to-many (e.g., ``simple_items_parent_container``) and junction table
|
|
165
|
+
names for many-to-many (e.g., ``students_enrollments``). Reverts to
|
|
166
|
+
underscore suffixes (``simple_items_``, ``student_``).
|
|
161
167
|
|
|
162
168
|
* ``dataclasses``
|
|
163
169
|
|
|
@@ -225,6 +231,14 @@ due to that ``_id`` suffix.
|
|
|
225
231
|
For self referential relationships, the reverse side of the relationship will be named
|
|
226
232
|
with the ``_reverse`` suffix appended to it.
|
|
227
233
|
|
|
234
|
+
When multiple foreign keys or junction tables connect to the same target table,
|
|
235
|
+
relationships use qualifiers for disambiguation. One-to-many relationships use FK
|
|
236
|
+
column names (e.g., ``simple_items_parent_container``, ``simple_items_top_container``).
|
|
237
|
+
Many-to-many relationships use junction table names (e.g., ``students_enrollments``,
|
|
238
|
+
``students_waitlist``), except for self-referential cases which use FK column names
|
|
239
|
+
(e.g., ``parent``, ``child``). The ``nofknames`` option reverts to underscore suffixes
|
|
240
|
+
(``simple_items_``, ``student_``).
|
|
241
|
+
|
|
228
242
|
Customizing code generation logic
|
|
229
243
|
=================================
|
|
230
244
|
|
|
@@ -249,3 +263,11 @@ sqlalchemy_ room on Gitter.
|
|
|
249
263
|
|
|
250
264
|
.. _sqlacodegen discussion forum: https://github.com/agronholm/sqlacodegen/discussions/categories/q-a
|
|
251
265
|
.. _sqlalchemy: https://app.gitter.im/#/room/#sqlalchemy_community:gitter.im
|
|
266
|
+
|
|
267
|
+
Security contact information
|
|
268
|
+
============================
|
|
269
|
+
|
|
270
|
+
To report a security vulnerability, please use the `Tidelift security contact`_.
|
|
271
|
+
Tidelift will coordinate the fix and disclosure.
|
|
272
|
+
|
|
273
|
+
.. _Tidelift security contact: https://tidelift.com/security
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
.. image:: https://coveralls.io/repos/github/agronholm/sqlacodegen/badge.svg?branch=master
|
|
5
5
|
:target: https://coveralls.io/github/agronholm/sqlacodegen?branch=master
|
|
6
6
|
:alt: Code Coverage
|
|
7
|
+
.. image:: https://tidelift.com/badges/package/pypi/sqlacodegen
|
|
8
|
+
:target: https://tidelift.com/subscription/pkg/pypi-sqlacodegen
|
|
9
|
+
:alt: Tidelift
|
|
7
10
|
|
|
8
11
|
This is a tool that reads the structure of an existing database and generates the
|
|
9
12
|
appropriate SQLAlchemy model code, using the declarative style if possible.
|
|
@@ -103,6 +106,12 @@ values must be delimited by commas, e.g. ``--options noconstraints,nobidi``):
|
|
|
103
106
|
* ``noconstraints``: ignore constraints (foreign key, unique etc.)
|
|
104
107
|
* ``nocomments``: ignore table/column comments
|
|
105
108
|
* ``noindexes``: ignore indexes
|
|
109
|
+
* ``nonativeenums``: don't generate Python enum classes for native database ENUM types (e.g., PostgreSQL ENUM); use plain string mapping instead
|
|
110
|
+
* ``nosyntheticenums``: don't generate Python enum classes from CHECK constraints with IN clauses (e.g., ``column IN ('value1', 'value2', ...)``); preserves CHECK constraints as-is
|
|
111
|
+
* ``noidsuffix``: prevent the special naming logic for single column many-to-one
|
|
112
|
+
and one-to-one relationships (see `Relationship naming logic`_ for details)
|
|
113
|
+
* ``include_dialect_options``: render a table' dialect options, such as ``starrocks_partition`` for StarRocks' specific options.
|
|
114
|
+
* ``keep_dialect_types``: preserve dialect-specific column types instead of adapting to generic SQLAlchemy types.
|
|
106
115
|
|
|
107
116
|
* ``declarative``
|
|
108
117
|
|
|
@@ -113,6 +122,11 @@ values must be delimited by commas, e.g. ``--options noconstraints,nobidi``):
|
|
|
113
122
|
* ``nobidi``: generate relationships in a unidirectional fashion, so only the
|
|
114
123
|
many-to-one or first side of many-to-many relationships gets a relationship
|
|
115
124
|
attribute, as on v2.X
|
|
125
|
+
* ``nofknames``: disable improved relationship naming when multiple FKs or
|
|
126
|
+
junction tables connect to the same target. By default, uses FK column names
|
|
127
|
+
for one-to-many (e.g., ``simple_items_parent_container``) and junction table
|
|
128
|
+
names for many-to-many (e.g., ``students_enrollments``). Reverts to
|
|
129
|
+
underscore suffixes (``simple_items_``, ``student_``).
|
|
116
130
|
|
|
117
131
|
* ``dataclasses``
|
|
118
132
|
|
|
@@ -180,6 +194,14 @@ due to that ``_id`` suffix.
|
|
|
180
194
|
For self referential relationships, the reverse side of the relationship will be named
|
|
181
195
|
with the ``_reverse`` suffix appended to it.
|
|
182
196
|
|
|
197
|
+
When multiple foreign keys or junction tables connect to the same target table,
|
|
198
|
+
relationships use qualifiers for disambiguation. One-to-many relationships use FK
|
|
199
|
+
column names (e.g., ``simple_items_parent_container``, ``simple_items_top_container``).
|
|
200
|
+
Many-to-many relationships use junction table names (e.g., ``students_enrollments``,
|
|
201
|
+
``students_waitlist``), except for self-referential cases which use FK column names
|
|
202
|
+
(e.g., ``parent``, ``child``). The ``nofknames`` option reverts to underscore suffixes
|
|
203
|
+
(``simple_items_``, ``student_``).
|
|
204
|
+
|
|
183
205
|
Customizing code generation logic
|
|
184
206
|
=================================
|
|
185
207
|
|
|
@@ -204,3 +226,11 @@ sqlalchemy_ room on Gitter.
|
|
|
204
226
|
|
|
205
227
|
.. _sqlacodegen discussion forum: https://github.com/agronholm/sqlacodegen/discussions/categories/q-a
|
|
206
228
|
.. _sqlalchemy: https://app.gitter.im/#/room/#sqlalchemy_community:gitter.im
|
|
229
|
+
|
|
230
|
+
Security contact information
|
|
231
|
+
============================
|
|
232
|
+
|
|
233
|
+
To report a security vulnerability, please use the `Tidelift security contact`_.
|
|
234
|
+
Tidelift will coordinate the fix and disclosure.
|
|
235
|
+
|
|
236
|
+
.. _Tidelift security contact: https://tidelift.com/security
|
|
@@ -21,18 +21,16 @@ classifiers = [
|
|
|
21
21
|
"Topic :: Software Development :: Code Generators",
|
|
22
22
|
"Programming Language :: Python",
|
|
23
23
|
"Programming Language :: Python :: 3",
|
|
24
|
-
"Programming Language :: Python :: 3.9",
|
|
25
24
|
"Programming Language :: Python :: 3.10",
|
|
26
25
|
"Programming Language :: Python :: 3.11",
|
|
27
26
|
"Programming Language :: Python :: 3.12",
|
|
28
27
|
"Programming Language :: Python :: 3.13",
|
|
28
|
+
"Programming Language :: Python :: 3.14",
|
|
29
29
|
]
|
|
30
|
-
requires-python = ">=3.
|
|
30
|
+
requires-python = ">=3.10"
|
|
31
31
|
dependencies = [
|
|
32
|
-
"SQLAlchemy >= 2.0.29
|
|
32
|
+
"SQLAlchemy >= 2.0.29",
|
|
33
33
|
"inflect >= 4.0.0",
|
|
34
|
-
"importlib_metadata; python_version < '3.10'",
|
|
35
|
-
"stdlib-list; python_version < '3.10'"
|
|
36
34
|
]
|
|
37
35
|
dynamic = ["version"]
|
|
38
36
|
|
|
@@ -41,13 +39,6 @@ dynamic = ["version"]
|
|
|
41
39
|
"Source Code" = "https://github.com/agronholm/sqlacodegen"
|
|
42
40
|
|
|
43
41
|
[project.optional-dependencies]
|
|
44
|
-
test = [
|
|
45
|
-
"sqlacodegen[sqlmodel,pgvector,geoalchemy2]",
|
|
46
|
-
"pytest >= 7.4",
|
|
47
|
-
"coverage >= 7",
|
|
48
|
-
"psycopg[binary]",
|
|
49
|
-
"mysql-connector-python",
|
|
50
|
-
]
|
|
51
42
|
sqlmodel = ["sqlmodel >= 0.0.22"]
|
|
52
43
|
citext = ["sqlalchemy-citext >= 1.7.0"]
|
|
53
44
|
geoalchemy2 = ["geoalchemy2 >= 0.17.0"]
|
|
@@ -62,6 +53,14 @@ sqlmodels = "sqlacodegen.generators:SQLModelGenerator"
|
|
|
62
53
|
[project.scripts]
|
|
63
54
|
sqlacodegen = "sqlacodegen.cli:main"
|
|
64
55
|
|
|
56
|
+
[dependency-groups]
|
|
57
|
+
test = [
|
|
58
|
+
"pytest >= 7.4",
|
|
59
|
+
"coverage >= 7",
|
|
60
|
+
"psycopg[binary]",
|
|
61
|
+
"mysql-connector-python",
|
|
62
|
+
]
|
|
63
|
+
|
|
65
64
|
[tool.setuptools_scm]
|
|
66
65
|
version_scheme = "post-release"
|
|
67
66
|
local_scheme = "dirty-tag"
|
|
@@ -95,10 +94,11 @@ relative_files = true
|
|
|
95
94
|
show_missing = true
|
|
96
95
|
|
|
97
96
|
[tool.tox]
|
|
98
|
-
env_list = ["
|
|
97
|
+
env_list = ["py310", "py311", "py312", "py313", "py314"]
|
|
99
98
|
skip_missing_interpreters = true
|
|
100
99
|
|
|
101
100
|
[tool.tox.env_run_base]
|
|
102
101
|
package = "editable"
|
|
103
102
|
commands = [["python", "-m", "pytest", { replace = "posargs", extend = true }]]
|
|
104
|
-
|
|
103
|
+
dependency_groups = ["test"]
|
|
104
|
+
extras = ["sqlmodel", "citext", "geoalchemy2", "pgvector"]
|
|
@@ -4,6 +4,7 @@ import argparse
|
|
|
4
4
|
import ast
|
|
5
5
|
import sys
|
|
6
6
|
from contextlib import ExitStack
|
|
7
|
+
from importlib.metadata import entry_points, version
|
|
7
8
|
from typing import Any, TextIO
|
|
8
9
|
|
|
9
10
|
from sqlalchemy.engine import create_engine
|
|
@@ -24,11 +25,6 @@ try:
|
|
|
24
25
|
except ImportError:
|
|
25
26
|
pgvector = None
|
|
26
27
|
|
|
27
|
-
if sys.version_info < (3, 10):
|
|
28
|
-
from importlib_metadata import entry_points, version
|
|
29
|
-
else:
|
|
30
|
-
from importlib.metadata import entry_points, version
|
|
31
|
-
|
|
32
28
|
|
|
33
29
|
def _parse_engine_arg(arg_str: str) -> tuple[str, Any]:
|
|
34
30
|
if "=" not in arg_str:
|