sqlalchemy-boltons 2.0.0__tar.gz → 2.0.1__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.
Files changed (25) hide show
  1. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/CHANGELOG.md +12 -0
  2. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/PKG-INFO +2 -2
  3. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/README.md +1 -1
  4. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/pyproject.toml +1 -1
  5. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/src/sqlalchemy_boltons.egg-info/PKG-INFO +2 -2
  6. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/tests/test_orm.py +45 -2
  7. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/AUTHORS.md +0 -0
  8. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/LICENSE +0 -0
  9. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/MANIFEST.in +0 -0
  10. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/doc/Makefile +0 -0
  11. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/doc/conf.py +0 -0
  12. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/doc/index.rst +0 -0
  13. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/doc/make.bat +0 -0
  14. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/setup.cfg +0 -0
  15. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/setup.py +0 -0
  16. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/src/sqlalchemy_boltons/__init__.py +0 -0
  17. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/src/sqlalchemy_boltons/orm.py +0 -0
  18. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/src/sqlalchemy_boltons/py.typed +0 -0
  19. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/src/sqlalchemy_boltons/sqlite.py +0 -0
  20. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/src/sqlalchemy_boltons.egg-info/SOURCES.txt +0 -0
  21. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/src/sqlalchemy_boltons.egg-info/dependency_links.txt +0 -0
  22. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/src/sqlalchemy_boltons.egg-info/top_level.txt +0 -0
  23. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/tests/__init__.py +0 -0
  24. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/tests/conftest.py +0 -0
  25. {sqlalchemy_boltons-2.0.0 → sqlalchemy_boltons-2.0.1}/tests/test_sqlite.py +0 -0
@@ -4,6 +4,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [2.0.1] - 2025-06-28
8
+
9
+ ### Added
10
+
11
+ - `orm`: Add self-referential tables to test cases.
12
+
13
+ ## [2.0.0] - 2025-06-28
14
+
15
+ ### Added
16
+
17
+ - `orm`: Add module for elegantly extracting the filter condition out of an ORM relationship.
18
+
7
19
  ## [1.1.0] - 2025-03-11
8
20
 
9
21
  ### Changed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sqlalchemy_boltons
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: Utilities that should've been inside SQLAlchemy but aren't
5
5
  Author-email: Eduard Christian Dumitrescu <eduard.c.dumitrescu@gmail.com>
6
6
  Maintainer-email: Eduard Christian Dumitrescu <eduard.c.dumitrescu@gmail.com>
@@ -103,4 +103,4 @@ select(Parent1).where(
103
103
  ) # ^^^^ ^
104
104
  ```
105
105
 
106
- Hope is restored.
106
+ Hope is restored. This even works on self-referential tables!
@@ -89,4 +89,4 @@ select(Parent1).where(
89
89
  ) # ^^^^ ^
90
90
  ```
91
91
 
92
- Hope is restored.
92
+ Hope is restored. This even works on self-referential tables!
@@ -3,7 +3,7 @@ line-length = 120
3
3
 
4
4
  [project]
5
5
  name = "sqlalchemy_boltons"
6
- version = "2.0.0"
6
+ version = "2.0.1"
7
7
  description = "Utilities that should've been inside SQLAlchemy but aren't"
8
8
  readme = "README.md"
9
9
  license = { text = "MIT" }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sqlalchemy-boltons
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: Utilities that should've been inside SQLAlchemy but aren't
5
5
  Author-email: Eduard Christian Dumitrescu <eduard.c.dumitrescu@gmail.com>
6
6
  Maintainer-email: Eduard Christian Dumitrescu <eduard.c.dumitrescu@gmail.com>
@@ -103,4 +103,4 @@ select(Parent1).where(
103
103
  ) # ^^^^ ^
104
104
  ```
105
105
 
106
- Hope is restored.
106
+ Hope is restored. This even works on self-referential tables!
@@ -21,6 +21,18 @@ def _make_rel_2(p=None, c=None):
21
21
  return (p.ix == c.parent_ix) & (p.iy == c.parent_iy)
22
22
 
23
23
 
24
+ def _make_rel_3(p=None, c=None):
25
+ p = p or Parent3
26
+ c = c or Parent3
27
+ return p.id == c.parent_id
28
+
29
+
30
+ def _make_rel_4(p=None, c=None):
31
+ p = p or Parent4
32
+ c = c or Parent4
33
+ return (p.ix == c.parent_ix) & (p.iy == c.parent_iy)
34
+
35
+
24
36
  class Parent1(Base):
25
37
  __tablename__ = "parent1"
26
38
 
@@ -57,22 +69,53 @@ class Child2(Base):
57
69
  parent = sao.relationship("Parent2", primaryjoin=_make_rel_2)
58
70
 
59
71
 
60
- _cases = {"1": (Parent1, Child1, _make_rel_1), "2": (Parent2, Child2, _make_rel_2)}
72
+ class Parent3(Base):
73
+ __tablename__ = "parent3"
74
+
75
+ id = sa.Column(sa.Integer, primary_key=True)
76
+ parent_id = sa.Column(sa.ForeignKey("parent3.id"), index=True, nullable=True)
77
+
78
+ parent = sao.relationship("Parent3", primaryjoin=_make_rel_3, foreign_keys=parent_id, remote_side=id)
79
+
80
+
81
+ class Parent4(Base):
82
+ __tablename__ = "parent4"
83
+
84
+ ix = sa.Column(sa.Integer, primary_key=True)
85
+ iy = sa.Column(sa.String, primary_key=True)
86
+
87
+ parent_ix = sa.Column(sa.ForeignKey("parent4.ix"), index=True, nullable=True)
88
+ parent_iy = sa.Column(sa.ForeignKey("parent4.iy"), index=True, nullable=True)
89
+
90
+ parent = sao.relationship(
91
+ "Parent4", primaryjoin=_make_rel_4, foreign_keys=[parent_ix, parent_iy], remote_side=[ix, iy]
92
+ )
93
+
94
+
95
+ _cases = {
96
+ "simple": (Parent1, Child1, _make_rel_1),
97
+ "simple_multikey": (Parent2, Child2, _make_rel_2),
98
+ "selfref": (Parent3, Parent3, _make_rel_3),
99
+ "selfref_multikey": (Parent4, Parent4, _make_rel_4),
100
+ }
61
101
 
62
102
 
63
103
  def assert_same_sql(x, y):
64
104
  assert str(x) == str(y), "expected equivalent SQL"
65
105
 
66
106
 
67
- @pytest.mark.parametrize("case", _cases.keys())
68
107
  @pytest.mark.parametrize("alias_parent", [False, True])
69
108
  @pytest.mark.parametrize("alias_child", [False, True])
109
+ @pytest.mark.parametrize("case", _cases.keys())
70
110
  def test_join_expr(case, alias_parent, alias_child):
71
111
  Parent, Child, make_rel = _cases[case]
72
112
 
73
113
  P = sao.aliased(Parent) if alias_parent else Parent
74
114
  C = sao.aliased(Child) if alias_child else Child
75
115
 
116
+ if (Parent is Child) and not (alias_child and alias_child):
117
+ pytest.skip(reason="doesn't make sense for a self-referential relationship")
118
+
76
119
  assert_same_sql(_orm.join_expr(P, C.parent), make_rel(P, C))
77
120
 
78
121
  Rel = _orm.RelationshipComparator