piccolo 1.20.0__py3-none-any.whl → 1.21.0__py3-none-any.whl
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.
- piccolo/__init__.py +1 -1
- piccolo/query/methods/select.py +1 -1
- {piccolo-1.20.0.dist-info → piccolo-1.21.0.dist-info}/METADATA +1 -1
- {piccolo-1.20.0.dist-info → piccolo-1.21.0.dist-info}/RECORD +9 -9
- {piccolo-1.20.0.dist-info → piccolo-1.21.0.dist-info}/WHEEL +1 -1
- tests/columns/test_db_column_name.py +58 -13
- {piccolo-1.20.0.dist-info → piccolo-1.21.0.dist-info}/LICENSE +0 -0
- {piccolo-1.20.0.dist-info → piccolo-1.21.0.dist-info}/entry_points.txt +0 -0
- {piccolo-1.20.0.dist-info → piccolo-1.21.0.dist-info}/top_level.txt +0 -0
piccolo/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__VERSION__ = "1.
|
1
|
+
__VERSION__ = "1.21.0"
|
piccolo/query/methods/select.py
CHANGED
@@ -534,7 +534,7 @@ class Select(Query[TableInstance, t.List[t.Dict[str, t.Any]]]):
|
|
534
534
|
_joins.append(
|
535
535
|
f'LEFT JOIN {right_tablename} "{table_alias}"'
|
536
536
|
" ON "
|
537
|
-
f'({left_tablename}."{key._meta.
|
537
|
+
f'({left_tablename}."{key._meta.db_column_name}" = "{table_alias}"."{pk_name}")' # noqa: E501
|
538
538
|
)
|
539
539
|
|
540
540
|
joins.extend(_joins)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
piccolo/__init__.py,sha256=
|
1
|
+
piccolo/__init__.py,sha256=lfg4osIcO7gnlgKb0zY1KT8t1Ngd2pATD-6YnBkIDcU,23
|
2
2
|
piccolo/custom_types.py,sha256=7HMQAze-5mieNLfbQ5QgbRQgR2abR7ol0qehv2SqROY,604
|
3
3
|
piccolo/main.py,sha256=1VsFV67FWTUikPTysp64Fmgd9QBVa_9wcwKfwj2UCEA,5117
|
4
4
|
piccolo/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -169,7 +169,7 @@ piccolo/query/methods/insert.py,sha256=ssLJ_wn08KnOwwr7t-VILyn1P4hrvM63CfPIcAJWT
|
|
169
169
|
piccolo/query/methods/objects.py,sha256=BfCOIbNMj7FWkmK5STaINkfDFmwzZvDZi60jCumjs1o,15627
|
170
170
|
piccolo/query/methods/raw.py,sha256=wQWR8b-yA_Gr-5lqRMZe9BOAAMBAw8CqTx37qVYvM1A,987
|
171
171
|
piccolo/query/methods/refresh.py,sha256=wg1zghKfwz-VmqK4uWa4GNMiDtK-skTqow591Hb3ONM,5854
|
172
|
-
piccolo/query/methods/select.py,sha256=
|
172
|
+
piccolo/query/methods/select.py,sha256=41OW-DIE_wr5VdxSusMKNT2aUhzQsCwK2Qh1XqgXHg0,22424
|
173
173
|
piccolo/query/methods/table_exists.py,sha256=0yb3n6Jd2ovSBWlZ-gl00K4E7Jnbj7J8qAAX5d7hvNk,1259
|
174
174
|
piccolo/query/methods/update.py,sha256=LfWqIXEl1aecc0rkVssTFmwyD6wXGhlKcTrUVhtlEsw,3705
|
175
175
|
piccolo/testing/__init__.py,sha256=pRFSqRInfx95AakOq54atmvqoB-ue073q2aR8u8zR40,83
|
@@ -253,7 +253,7 @@ tests/columns/test_bytea.py,sha256=doN8S1eFVU4ntSXIg4IgMSZcbvqW1WJ-AEm3OjKLGkI,1
|
|
253
253
|
tests/columns/test_choices.py,sha256=q8TLe7nvGERXyGO_XEryEBR-DuWwFY1jPpscsrXjdXo,4066
|
254
254
|
tests/columns/test_combination.py,sha256=BuBwR7k5X1EkOWraZpjqU6gvtb6ow_k-7N1KQBiW2RA,1681
|
255
255
|
tests/columns/test_date.py,sha256=QLC6kJMQwM-1mbUP4ksJVM7P8WwjzGZyynH3rHHdSew,1030
|
256
|
-
tests/columns/test_db_column_name.py,sha256=
|
256
|
+
tests/columns/test_db_column_name.py,sha256=0wz6y4GNGy4nhMdHmYzEnChQGpK2UhWFFKrnmmML3Mk,9027
|
257
257
|
tests/columns/test_defaults.py,sha256=rwlU1fXt3cCl7C51eLlZXqgWkE-K5W0pHvTrwkAKyCo,2896
|
258
258
|
tests/columns/test_double_precision.py,sha256=7rhcSfDkb2fBh_zEG4UGwD_GW1sy6U9-8NooHuCS09Q,544
|
259
259
|
tests/columns/test_get_sql_value.py,sha256=mKgsInN374jzV99y9mg_ZiG-AvnJgz36SZi89xL7RZM,1768
|
@@ -368,9 +368,9 @@ tests/utils/test_sql_values.py,sha256=vzxRmy16FfLZPH-sAQexBvsF9MXB8n4smr14qoEOS5
|
|
368
368
|
tests/utils/test_sync.py,sha256=9ytVo56y2vPQePvTeIi9lHIouEhWJbodl1TmzkGFrSo,799
|
369
369
|
tests/utils/test_table_reflection.py,sha256=SIzuat-IpcVj1GCFyOWKShI8YkhdOPPFH7qVrvfyPNE,3794
|
370
370
|
tests/utils/test_warnings.py,sha256=NvSC_cvJ6uZcwAGf1m-hLzETXCqprXELL8zg3TNLVMw,269
|
371
|
-
piccolo-1.
|
372
|
-
piccolo-1.
|
373
|
-
piccolo-1.
|
374
|
-
piccolo-1.
|
375
|
-
piccolo-1.
|
376
|
-
piccolo-1.
|
371
|
+
piccolo-1.21.0.dist-info/LICENSE,sha256=zFIpi-16uIJ420UMIG75NU0JbDBykvrdnXcj5U_EYBI,1059
|
372
|
+
piccolo-1.21.0.dist-info/METADATA,sha256=CMfZm7IYerdMTQLFwzuyCPWZMlrGf1G_shqoq2LlnGM,5178
|
373
|
+
piccolo-1.21.0.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
374
|
+
piccolo-1.21.0.dist-info/entry_points.txt,sha256=SJPHET4Fi1bN5F3WqcKkv9SClK3_F1I7m4eQjk6AFh0,46
|
375
|
+
piccolo-1.21.0.dist-info/top_level.txt,sha256=-SR74VGbk43VoPy1HH-mHm97yoGukLK87HE5kdBW6qM,24
|
376
|
+
piccolo-1.21.0.dist-info/RECORD,,
|
@@ -1,12 +1,20 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import typing as t
|
2
|
+
|
3
|
+
from piccolo.columns.column_types import ForeignKey, Integer, Serial, Varchar
|
4
|
+
from piccolo.table import Table, create_db_tables_sync, drop_db_tables_sync
|
3
5
|
from tests.base import DBTestCase, engine_is, engines_only, engines_skip
|
4
6
|
|
5
7
|
|
8
|
+
class Manager(Table):
|
9
|
+
id: Serial
|
10
|
+
name = Varchar()
|
11
|
+
|
12
|
+
|
6
13
|
class Band(Table):
|
7
14
|
id: Serial
|
8
15
|
name = Varchar(db_column_name="regrettable_column_name")
|
9
16
|
popularity = Integer()
|
17
|
+
manager = ForeignKey(Manager, db_column_name="manager_fk")
|
10
18
|
|
11
19
|
|
12
20
|
class TestDBColumnName(DBTestCase):
|
@@ -22,10 +30,15 @@ class TestDBColumnName(DBTestCase):
|
|
22
30
|
"""
|
23
31
|
|
24
32
|
def setUp(self):
|
25
|
-
Band
|
33
|
+
create_db_tables_sync(Band, Manager)
|
26
34
|
|
27
35
|
def tearDown(self):
|
28
|
-
Band
|
36
|
+
drop_db_tables_sync(Band, Manager)
|
37
|
+
|
38
|
+
def insert_band(self, manager: t.Optional[Manager] = None) -> Band:
|
39
|
+
band = Band(name="Pythonistas", popularity=1000, manager=manager)
|
40
|
+
band.save().run_sync()
|
41
|
+
return band
|
29
42
|
|
30
43
|
@engines_only("postgres", "cockroach")
|
31
44
|
def test_column_name_correct(self):
|
@@ -45,8 +58,7 @@ class TestDBColumnName(DBTestCase):
|
|
45
58
|
"""
|
46
59
|
Make sure save queries work correctly.
|
47
60
|
"""
|
48
|
-
|
49
|
-
band.save().run_sync()
|
61
|
+
self.insert_band()
|
50
62
|
|
51
63
|
band_from_db = Band.objects().first().run_sync()
|
52
64
|
assert band_from_db is not None
|
@@ -56,11 +68,7 @@ class TestDBColumnName(DBTestCase):
|
|
56
68
|
"""
|
57
69
|
Make sure create queries work correctly.
|
58
70
|
"""
|
59
|
-
band = (
|
60
|
-
Band.objects()
|
61
|
-
.create(name="Pythonistas", popularity=1000)
|
62
|
-
.run_sync()
|
63
|
-
)
|
71
|
+
band = self.insert_band()
|
64
72
|
self.assertEqual(band.name, "Pythonistas")
|
65
73
|
|
66
74
|
band_from_db = Band.objects().first().run_sync()
|
@@ -74,7 +82,7 @@ class TestDBColumnName(DBTestCase):
|
|
74
82
|
name to it's alias, but it's hard to predict what behaviour the user
|
75
83
|
wants.
|
76
84
|
"""
|
77
|
-
|
85
|
+
self.insert_band()
|
78
86
|
|
79
87
|
# Make sure we can select all columns
|
80
88
|
bands = Band.select().run_sync()
|
@@ -86,6 +94,7 @@ class TestDBColumnName(DBTestCase):
|
|
86
94
|
"id": bands[0]["id"],
|
87
95
|
"regrettable_column_name": "Pythonistas",
|
88
96
|
"popularity": 1000,
|
97
|
+
"manager_fk": None,
|
89
98
|
}
|
90
99
|
],
|
91
100
|
)
|
@@ -97,6 +106,7 @@ class TestDBColumnName(DBTestCase):
|
|
97
106
|
"id": 1,
|
98
107
|
"regrettable_column_name": "Pythonistas",
|
99
108
|
"popularity": 1000,
|
109
|
+
"manager_fk": None,
|
100
110
|
}
|
101
111
|
],
|
102
112
|
)
|
@@ -123,11 +133,36 @@ class TestDBColumnName(DBTestCase):
|
|
123
133
|
],
|
124
134
|
)
|
125
135
|
|
136
|
+
def test_join(self):
|
137
|
+
"""
|
138
|
+
Make sure that foreign keys with a ``db_column_name`` specified still
|
139
|
+
work for joins.
|
140
|
+
|
141
|
+
https://github.com/piccolo-orm/piccolo/issues/1101
|
142
|
+
|
143
|
+
"""
|
144
|
+
manager = Manager.objects().create(name="Guido").run_sync()
|
145
|
+
band = self.insert_band(manager=manager)
|
146
|
+
|
147
|
+
bands = Band.select().where(Band.manager.name == "Guido").run_sync()
|
148
|
+
|
149
|
+
self.assertListEqual(
|
150
|
+
bands,
|
151
|
+
[
|
152
|
+
{
|
153
|
+
"id": band.id,
|
154
|
+
"manager_fk": manager.id,
|
155
|
+
"popularity": 1000,
|
156
|
+
"regrettable_column_name": "Pythonistas",
|
157
|
+
}
|
158
|
+
],
|
159
|
+
)
|
160
|
+
|
126
161
|
def test_update(self):
|
127
162
|
"""
|
128
163
|
Make sure update queries work correctly.
|
129
164
|
"""
|
130
|
-
|
165
|
+
self.insert_band()
|
131
166
|
|
132
167
|
Band.update({Band.name: "Pythonistas 2"}, force=True).run_sync()
|
133
168
|
|
@@ -140,6 +175,7 @@ class TestDBColumnName(DBTestCase):
|
|
140
175
|
"id": bands[0]["id"],
|
141
176
|
"regrettable_column_name": "Pythonistas 2",
|
142
177
|
"popularity": 1000,
|
178
|
+
"manager_fk": None,
|
143
179
|
}
|
144
180
|
],
|
145
181
|
)
|
@@ -151,6 +187,7 @@ class TestDBColumnName(DBTestCase):
|
|
151
187
|
"id": 1,
|
152
188
|
"regrettable_column_name": "Pythonistas 2",
|
153
189
|
"popularity": 1000,
|
190
|
+
"manager_fk": None,
|
154
191
|
}
|
155
192
|
],
|
156
193
|
)
|
@@ -166,6 +203,7 @@ class TestDBColumnName(DBTestCase):
|
|
166
203
|
"id": bands[0]["id"],
|
167
204
|
"regrettable_column_name": "Pythonistas 3",
|
168
205
|
"popularity": 1000,
|
206
|
+
"manager_fk": None,
|
169
207
|
}
|
170
208
|
],
|
171
209
|
)
|
@@ -177,6 +215,7 @@ class TestDBColumnName(DBTestCase):
|
|
177
215
|
"id": 1,
|
178
216
|
"regrettable_column_name": "Pythonistas 3",
|
179
217
|
"popularity": 1000,
|
218
|
+
"manager_fk": None,
|
180
219
|
}
|
181
220
|
],
|
182
221
|
)
|
@@ -199,11 +238,13 @@ class TestDBColumnName(DBTestCase):
|
|
199
238
|
"id": 1,
|
200
239
|
"regrettable_column_name": "Pythonistas",
|
201
240
|
"popularity": 1000,
|
241
|
+
"manager_fk": None,
|
202
242
|
},
|
203
243
|
{
|
204
244
|
"id": 2,
|
205
245
|
"regrettable_column_name": "Rustaceans",
|
206
246
|
"popularity": 500,
|
247
|
+
"manager_fk": None,
|
207
248
|
},
|
208
249
|
],
|
209
250
|
)
|
@@ -218,6 +259,7 @@ class TestDBColumnName(DBTestCase):
|
|
218
259
|
"id": 1,
|
219
260
|
"regrettable_column_name": "Pythonistas",
|
220
261
|
"popularity": 1000,
|
262
|
+
"manager_fk": None,
|
221
263
|
}
|
222
264
|
],
|
223
265
|
)
|
@@ -244,11 +286,13 @@ class TestDBColumnName(DBTestCase):
|
|
244
286
|
"id": result[0]["id"],
|
245
287
|
"regrettable_column_name": "Pythonistas",
|
246
288
|
"popularity": 1000,
|
289
|
+
"manager_fk": None,
|
247
290
|
},
|
248
291
|
{
|
249
292
|
"id": result[1]["id"],
|
250
293
|
"regrettable_column_name": "Rustaceans",
|
251
294
|
"popularity": 500,
|
295
|
+
"manager_fk": None,
|
252
296
|
},
|
253
297
|
],
|
254
298
|
)
|
@@ -263,6 +307,7 @@ class TestDBColumnName(DBTestCase):
|
|
263
307
|
"id": result[0]["id"],
|
264
308
|
"regrettable_column_name": "Pythonistas",
|
265
309
|
"popularity": 1000,
|
310
|
+
"manager_fk": None,
|
266
311
|
}
|
267
312
|
],
|
268
313
|
)
|
File without changes
|
File without changes
|
File without changes
|