python-sql 1.5.2__tar.gz → 1.7.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.
- {python_sql-1.5.2 → python_sql-1.7.0}/.gitlab-ci.yml +1 -1
- {python_sql-1.5.2 → python_sql-1.7.0}/.hgtags +2 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/CHANGELOG +9 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/COPYRIGHT +3 -3
- {python_sql-1.5.2 → python_sql-1.7.0}/PKG-INFO +24 -11
- {python_sql-1.5.2 → python_sql-1.7.0}/README.rst +9 -9
- {python_sql-1.5.2 → python_sql-1.7.0}/python_sql.egg-info/PKG-INFO +24 -11
- {python_sql-1.5.2 → python_sql-1.7.0}/setup.py +2 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/__init__.py +9 -8
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/aggregate.py +16 -6
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/__init__.py +1 -1
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_aggregate.py +2 -2
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_select.py +13 -3
- {python_sql-1.5.2 → python_sql-1.7.0}/tox.ini +1 -1
- {python_sql-1.5.2 → python_sql-1.7.0}/.flake8 +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/.isort.cfg +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/MANIFEST.in +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/python_sql.egg-info/SOURCES.txt +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/python_sql.egg-info/dependency_links.txt +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/python_sql.egg-info/top_level.txt +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/setup.cfg +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/conditionals.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/functions.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/operators.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_alias.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_as.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_cast.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_collate.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_column.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_combining_query.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_conditionals.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_delete.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_excluded.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_expression.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_flavor.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_for.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_from.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_from_item.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_functions.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_grouping.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_insert.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_join.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_lateral.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_literal.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_merge.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_operators.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_order.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_rollup.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_table.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_update.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_values.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_window.py +0 -0
- {python_sql-1.5.2 → python_sql-1.7.0}/sql/tests/test_with.py +0 -0
|
@@ -57,7 +57,7 @@ test-tox-python:
|
|
|
57
57
|
- tox -e "py${PYTHON_VERSION/./}" -- -v --output-file junit.xml
|
|
58
58
|
parallel:
|
|
59
59
|
matrix:
|
|
60
|
-
- PYTHON_VERSION: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
|
|
60
|
+
- PYTHON_VERSION: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
61
61
|
|
|
62
62
|
test-tox-pypy:
|
|
63
63
|
extends: .test-tox
|
|
@@ -20,3 +20,5 @@ fcb64787b51db2068061eb4aa13825abc1134916 1.4.2
|
|
|
20
20
|
6f9066b83fe3a8c4699a8555ad1bc406f18974ff 1.5.0
|
|
21
21
|
79a69b0bbbd35a8d95e1b754ed3feb03df23fb70 1.5.1
|
|
22
22
|
41b0aaa68f5e5bab3889fa1ef57ef44c6c21cacf 1.5.2
|
|
23
|
+
475502ba46eba3b7e141e8fbceaf495b545bcddb 1.6.0
|
|
24
|
+
231ce10b975e41027c6121f9bb9033d786553b90 1.7.0
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
Version 1.7.0 - 2025-11-24
|
|
2
|
+
* Add support for Python 3.14
|
|
3
|
+
* Do not use parameters for COUNT(*)
|
|
4
|
+
|
|
5
|
+
Version 1.6.0 - 2025-05-02
|
|
6
|
+
* Fix position of order_by parameters in Select query
|
|
7
|
+
* Add support for weak reference on SQL objects
|
|
8
|
+
* Add support for Python 3.13
|
|
9
|
+
|
|
1
10
|
Version 1.5.2 - 2024-09-30
|
|
2
11
|
* Use parameter for unary operator
|
|
3
12
|
* Support default values when inserting not matched merge
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Copyright (c) 2011-
|
|
2
|
-
Copyright (c) 2013-
|
|
3
|
-
Copyright (c) 2011-
|
|
1
|
+
Copyright (c) 2011-2025, Cédric Krier
|
|
2
|
+
Copyright (c) 2013-2025, Nicolas Évrard
|
|
3
|
+
Copyright (c) 2011-2025, B2CK
|
|
4
4
|
All rights reserved.
|
|
5
5
|
|
|
6
6
|
Redistribution and use in source and binary forms, with or without
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: python-sql
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
4
4
|
Summary: Library to write SQL queries
|
|
5
5
|
Home-page: https://pypi.org/project/python-sql/
|
|
6
6
|
Download-URL: https://downloads.tryton.org/python-sql/
|
|
@@ -24,9 +24,22 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
24
24
|
Classifier: Programming Language :: Python :: 3.10
|
|
25
25
|
Classifier: Programming Language :: Python :: 3.11
|
|
26
26
|
Classifier: Programming Language :: Python :: 3.12
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
27
29
|
Classifier: Topic :: Database
|
|
28
30
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
29
31
|
Requires-Python: >=3.5
|
|
32
|
+
Dynamic: author
|
|
33
|
+
Dynamic: author-email
|
|
34
|
+
Dynamic: classifier
|
|
35
|
+
Dynamic: description
|
|
36
|
+
Dynamic: download-url
|
|
37
|
+
Dynamic: home-page
|
|
38
|
+
Dynamic: keywords
|
|
39
|
+
Dynamic: license
|
|
40
|
+
Dynamic: project-url
|
|
41
|
+
Dynamic: requires-python
|
|
42
|
+
Dynamic: summary
|
|
30
43
|
|
|
31
44
|
python-sql
|
|
32
45
|
==========
|
|
@@ -136,23 +149,23 @@ Select on other schema::
|
|
|
136
149
|
Insert query with default values::
|
|
137
150
|
|
|
138
151
|
>>> tuple(user.insert())
|
|
139
|
-
('INSERT INTO "user"
|
|
152
|
+
('INSERT INTO "user" DEFAULT VALUES', ())
|
|
140
153
|
|
|
141
154
|
Insert query with values::
|
|
142
155
|
|
|
143
156
|
>>> tuple(user.insert(columns=[user.name, user.login],
|
|
144
157
|
... values=[['Foo', 'foo']]))
|
|
145
|
-
('INSERT INTO "user"
|
|
158
|
+
('INSERT INTO "user" ("name", "login") VALUES (%s, %s)', ('Foo', 'foo'))
|
|
146
159
|
>>> tuple(user.insert(columns=[user.name, user.login],
|
|
147
160
|
... values=[['Foo', 'foo'], ['Bar', 'bar']]))
|
|
148
|
-
('INSERT INTO "user"
|
|
161
|
+
('INSERT INTO "user" ("name", "login") VALUES (%s, %s), (%s, %s)', ('Foo', 'foo', 'Bar', 'bar'))
|
|
149
162
|
|
|
150
163
|
Insert query with query::
|
|
151
164
|
|
|
152
165
|
>>> passwd = Table('passwd')
|
|
153
166
|
>>> select = passwd.select(passwd.login, passwd.passwd)
|
|
154
167
|
>>> tuple(user.insert(values=select))
|
|
155
|
-
('INSERT INTO "user"
|
|
168
|
+
('INSERT INTO "user" SELECT "a"."login", "a"."passwd" FROM "passwd" AS "a"', ())
|
|
156
169
|
|
|
157
170
|
Update query with values::
|
|
158
171
|
|
|
@@ -196,23 +209,23 @@ Flavors::
|
|
|
196
209
|
>>> select.offset = 10
|
|
197
210
|
>>> Flavor.set(Flavor())
|
|
198
211
|
>>> tuple(select)
|
|
199
|
-
('SELECT * FROM "user" AS "a" OFFSET
|
|
212
|
+
('SELECT * FROM "user" AS "a" OFFSET %s', (10,))
|
|
200
213
|
>>> Flavor.set(Flavor(max_limit=18446744073709551615))
|
|
201
214
|
>>> tuple(select)
|
|
202
|
-
('SELECT * FROM "user" AS "a" LIMIT 18446744073709551615 OFFSET
|
|
215
|
+
('SELECT * FROM "user" AS "a" LIMIT 18446744073709551615 OFFSET %s', (10,))
|
|
203
216
|
>>> Flavor.set(Flavor(max_limit=-1))
|
|
204
217
|
>>> tuple(select)
|
|
205
|
-
('SELECT * FROM "user" AS "a" LIMIT -1 OFFSET
|
|
218
|
+
('SELECT * FROM "user" AS "a" LIMIT -1 OFFSET %s', (10,))
|
|
206
219
|
|
|
207
220
|
Limit style::
|
|
208
221
|
|
|
209
222
|
>>> select = user.select(limit=10, offset=20)
|
|
210
223
|
>>> Flavor.set(Flavor(limitstyle='limit'))
|
|
211
224
|
>>> tuple(select)
|
|
212
|
-
('SELECT * FROM "user" AS "a" LIMIT
|
|
225
|
+
('SELECT * FROM "user" AS "a" LIMIT %s OFFSET %s', (10, 20))
|
|
213
226
|
>>> Flavor.set(Flavor(limitstyle='fetch'))
|
|
214
227
|
>>> tuple(select)
|
|
215
|
-
('SELECT * FROM "user" AS "a" OFFSET (
|
|
228
|
+
('SELECT * FROM "user" AS "a" OFFSET (%s) ROWS FETCH FIRST (%s) ROWS ONLY', (20, 10))
|
|
216
229
|
>>> Flavor.set(Flavor(limitstyle='rownum'))
|
|
217
230
|
>>> tuple(select)
|
|
218
231
|
('SELECT "a".* FROM (SELECT "b".*, ROWNUM AS "rnum" FROM (SELECT * FROM "user" AS "c") AS "b" WHERE (ROWNUM <= %s)) AS "a" WHERE ("rnum" > %s)', (30, 20))
|
|
@@ -106,23 +106,23 @@ Select on other schema::
|
|
|
106
106
|
Insert query with default values::
|
|
107
107
|
|
|
108
108
|
>>> tuple(user.insert())
|
|
109
|
-
('INSERT INTO "user"
|
|
109
|
+
('INSERT INTO "user" DEFAULT VALUES', ())
|
|
110
110
|
|
|
111
111
|
Insert query with values::
|
|
112
112
|
|
|
113
113
|
>>> tuple(user.insert(columns=[user.name, user.login],
|
|
114
114
|
... values=[['Foo', 'foo']]))
|
|
115
|
-
('INSERT INTO "user"
|
|
115
|
+
('INSERT INTO "user" ("name", "login") VALUES (%s, %s)', ('Foo', 'foo'))
|
|
116
116
|
>>> tuple(user.insert(columns=[user.name, user.login],
|
|
117
117
|
... values=[['Foo', 'foo'], ['Bar', 'bar']]))
|
|
118
|
-
('INSERT INTO "user"
|
|
118
|
+
('INSERT INTO "user" ("name", "login") VALUES (%s, %s), (%s, %s)', ('Foo', 'foo', 'Bar', 'bar'))
|
|
119
119
|
|
|
120
120
|
Insert query with query::
|
|
121
121
|
|
|
122
122
|
>>> passwd = Table('passwd')
|
|
123
123
|
>>> select = passwd.select(passwd.login, passwd.passwd)
|
|
124
124
|
>>> tuple(user.insert(values=select))
|
|
125
|
-
('INSERT INTO "user"
|
|
125
|
+
('INSERT INTO "user" SELECT "a"."login", "a"."passwd" FROM "passwd" AS "a"', ())
|
|
126
126
|
|
|
127
127
|
Update query with values::
|
|
128
128
|
|
|
@@ -166,23 +166,23 @@ Flavors::
|
|
|
166
166
|
>>> select.offset = 10
|
|
167
167
|
>>> Flavor.set(Flavor())
|
|
168
168
|
>>> tuple(select)
|
|
169
|
-
('SELECT * FROM "user" AS "a" OFFSET
|
|
169
|
+
('SELECT * FROM "user" AS "a" OFFSET %s', (10,))
|
|
170
170
|
>>> Flavor.set(Flavor(max_limit=18446744073709551615))
|
|
171
171
|
>>> tuple(select)
|
|
172
|
-
('SELECT * FROM "user" AS "a" LIMIT 18446744073709551615 OFFSET
|
|
172
|
+
('SELECT * FROM "user" AS "a" LIMIT 18446744073709551615 OFFSET %s', (10,))
|
|
173
173
|
>>> Flavor.set(Flavor(max_limit=-1))
|
|
174
174
|
>>> tuple(select)
|
|
175
|
-
('SELECT * FROM "user" AS "a" LIMIT -1 OFFSET
|
|
175
|
+
('SELECT * FROM "user" AS "a" LIMIT -1 OFFSET %s', (10,))
|
|
176
176
|
|
|
177
177
|
Limit style::
|
|
178
178
|
|
|
179
179
|
>>> select = user.select(limit=10, offset=20)
|
|
180
180
|
>>> Flavor.set(Flavor(limitstyle='limit'))
|
|
181
181
|
>>> tuple(select)
|
|
182
|
-
('SELECT * FROM "user" AS "a" LIMIT
|
|
182
|
+
('SELECT * FROM "user" AS "a" LIMIT %s OFFSET %s', (10, 20))
|
|
183
183
|
>>> Flavor.set(Flavor(limitstyle='fetch'))
|
|
184
184
|
>>> tuple(select)
|
|
185
|
-
('SELECT * FROM "user" AS "a" OFFSET (
|
|
185
|
+
('SELECT * FROM "user" AS "a" OFFSET (%s) ROWS FETCH FIRST (%s) ROWS ONLY', (20, 10))
|
|
186
186
|
>>> Flavor.set(Flavor(limitstyle='rownum'))
|
|
187
187
|
>>> tuple(select)
|
|
188
188
|
('SELECT "a".* FROM (SELECT "b".*, ROWNUM AS "rnum" FROM (SELECT * FROM "user" AS "c") AS "b" WHERE (ROWNUM <= %s)) AS "a" WHERE ("rnum" > %s)', (30, 20))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: python-sql
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
4
4
|
Summary: Library to write SQL queries
|
|
5
5
|
Home-page: https://pypi.org/project/python-sql/
|
|
6
6
|
Download-URL: https://downloads.tryton.org/python-sql/
|
|
@@ -24,9 +24,22 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
24
24
|
Classifier: Programming Language :: Python :: 3.10
|
|
25
25
|
Classifier: Programming Language :: Python :: 3.11
|
|
26
26
|
Classifier: Programming Language :: Python :: 3.12
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
27
29
|
Classifier: Topic :: Database
|
|
28
30
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
29
31
|
Requires-Python: >=3.5
|
|
32
|
+
Dynamic: author
|
|
33
|
+
Dynamic: author-email
|
|
34
|
+
Dynamic: classifier
|
|
35
|
+
Dynamic: description
|
|
36
|
+
Dynamic: download-url
|
|
37
|
+
Dynamic: home-page
|
|
38
|
+
Dynamic: keywords
|
|
39
|
+
Dynamic: license
|
|
40
|
+
Dynamic: project-url
|
|
41
|
+
Dynamic: requires-python
|
|
42
|
+
Dynamic: summary
|
|
30
43
|
|
|
31
44
|
python-sql
|
|
32
45
|
==========
|
|
@@ -136,23 +149,23 @@ Select on other schema::
|
|
|
136
149
|
Insert query with default values::
|
|
137
150
|
|
|
138
151
|
>>> tuple(user.insert())
|
|
139
|
-
('INSERT INTO "user"
|
|
152
|
+
('INSERT INTO "user" DEFAULT VALUES', ())
|
|
140
153
|
|
|
141
154
|
Insert query with values::
|
|
142
155
|
|
|
143
156
|
>>> tuple(user.insert(columns=[user.name, user.login],
|
|
144
157
|
... values=[['Foo', 'foo']]))
|
|
145
|
-
('INSERT INTO "user"
|
|
158
|
+
('INSERT INTO "user" ("name", "login") VALUES (%s, %s)', ('Foo', 'foo'))
|
|
146
159
|
>>> tuple(user.insert(columns=[user.name, user.login],
|
|
147
160
|
... values=[['Foo', 'foo'], ['Bar', 'bar']]))
|
|
148
|
-
('INSERT INTO "user"
|
|
161
|
+
('INSERT INTO "user" ("name", "login") VALUES (%s, %s), (%s, %s)', ('Foo', 'foo', 'Bar', 'bar'))
|
|
149
162
|
|
|
150
163
|
Insert query with query::
|
|
151
164
|
|
|
152
165
|
>>> passwd = Table('passwd')
|
|
153
166
|
>>> select = passwd.select(passwd.login, passwd.passwd)
|
|
154
167
|
>>> tuple(user.insert(values=select))
|
|
155
|
-
('INSERT INTO "user"
|
|
168
|
+
('INSERT INTO "user" SELECT "a"."login", "a"."passwd" FROM "passwd" AS "a"', ())
|
|
156
169
|
|
|
157
170
|
Update query with values::
|
|
158
171
|
|
|
@@ -196,23 +209,23 @@ Flavors::
|
|
|
196
209
|
>>> select.offset = 10
|
|
197
210
|
>>> Flavor.set(Flavor())
|
|
198
211
|
>>> tuple(select)
|
|
199
|
-
('SELECT * FROM "user" AS "a" OFFSET
|
|
212
|
+
('SELECT * FROM "user" AS "a" OFFSET %s', (10,))
|
|
200
213
|
>>> Flavor.set(Flavor(max_limit=18446744073709551615))
|
|
201
214
|
>>> tuple(select)
|
|
202
|
-
('SELECT * FROM "user" AS "a" LIMIT 18446744073709551615 OFFSET
|
|
215
|
+
('SELECT * FROM "user" AS "a" LIMIT 18446744073709551615 OFFSET %s', (10,))
|
|
203
216
|
>>> Flavor.set(Flavor(max_limit=-1))
|
|
204
217
|
>>> tuple(select)
|
|
205
|
-
('SELECT * FROM "user" AS "a" LIMIT -1 OFFSET
|
|
218
|
+
('SELECT * FROM "user" AS "a" LIMIT -1 OFFSET %s', (10,))
|
|
206
219
|
|
|
207
220
|
Limit style::
|
|
208
221
|
|
|
209
222
|
>>> select = user.select(limit=10, offset=20)
|
|
210
223
|
>>> Flavor.set(Flavor(limitstyle='limit'))
|
|
211
224
|
>>> tuple(select)
|
|
212
|
-
('SELECT * FROM "user" AS "a" LIMIT
|
|
225
|
+
('SELECT * FROM "user" AS "a" LIMIT %s OFFSET %s', (10, 20))
|
|
213
226
|
>>> Flavor.set(Flavor(limitstyle='fetch'))
|
|
214
227
|
>>> tuple(select)
|
|
215
|
-
('SELECT * FROM "user" AS "a" OFFSET (
|
|
228
|
+
('SELECT * FROM "user" AS "a" OFFSET (%s) ROWS FETCH FIRST (%s) ROWS ONLY', (20, 10))
|
|
216
229
|
>>> Flavor.set(Flavor(limitstyle='rownum'))
|
|
217
230
|
>>> tuple(select)
|
|
218
231
|
('SELECT "a".* FROM (SELECT "b".*, ROWNUM AS "rnum" FROM (SELECT * FROM "user" AS "c") AS "b" WHERE (ROWNUM <= %s)) AS "a" WHERE ("rnum" > %s)', (30, 20))
|
|
@@ -48,6 +48,8 @@ setup(name='python-sql',
|
|
|
48
48
|
'Programming Language :: Python :: 3.10',
|
|
49
49
|
'Programming Language :: Python :: 3.11',
|
|
50
50
|
'Programming Language :: Python :: 3.12',
|
|
51
|
+
'Programming Language :: Python :: 3.13',
|
|
52
|
+
'Programming Language :: Python :: 3.14',
|
|
51
53
|
'Topic :: Database',
|
|
52
54
|
'Topic :: Software Development :: Libraries :: Python Modules',
|
|
53
55
|
],
|
|
@@ -7,7 +7,7 @@ from collections import defaultdict
|
|
|
7
7
|
from itertools import chain
|
|
8
8
|
from threading import current_thread, local
|
|
9
9
|
|
|
10
|
-
__version__ = '1.
|
|
10
|
+
__version__ = '1.7.0'
|
|
11
11
|
__all__ = [
|
|
12
12
|
'Flavor', 'Table', 'Values', 'Literal', 'Column', 'Grouping', 'Conflict',
|
|
13
13
|
'Matched', 'MatchedUpdate', 'MatchedDelete',
|
|
@@ -182,7 +182,7 @@ def format2numeric(query, params):
|
|
|
182
182
|
|
|
183
183
|
|
|
184
184
|
class Query(object):
|
|
185
|
-
__slots__ = ()
|
|
185
|
+
__slots__ = ('__weakref__',)
|
|
186
186
|
|
|
187
187
|
@property
|
|
188
188
|
def params(self):
|
|
@@ -243,7 +243,7 @@ class WithQuery(Query):
|
|
|
243
243
|
|
|
244
244
|
|
|
245
245
|
class FromItem(object):
|
|
246
|
-
__slots__ = ()
|
|
246
|
+
__slots__ = ('__weakref__',)
|
|
247
247
|
|
|
248
248
|
@property
|
|
249
249
|
def alias(self):
|
|
@@ -692,13 +692,13 @@ class Select(FromItem, SelectQuery):
|
|
|
692
692
|
if self.group_by:
|
|
693
693
|
for expression in self.group_by:
|
|
694
694
|
p.extend(expression.params)
|
|
695
|
-
if self.order_by:
|
|
696
|
-
for expression in self.order_by:
|
|
697
|
-
p.extend(expression.params)
|
|
698
695
|
if self.having:
|
|
699
696
|
p.extend(self.having.params)
|
|
700
697
|
for window in self.windows:
|
|
701
698
|
p.extend(window.params)
|
|
699
|
+
if self.order_by:
|
|
700
|
+
for expression in self.order_by:
|
|
701
|
+
p.extend(expression.params)
|
|
702
702
|
p.extend(self._limit_offset_params)
|
|
703
703
|
return tuple(p)
|
|
704
704
|
|
|
@@ -1615,7 +1615,7 @@ class Values(list, Query, FromItem):
|
|
|
1615
1615
|
|
|
1616
1616
|
|
|
1617
1617
|
class Expression(object):
|
|
1618
|
-
__slots__ = ()
|
|
1618
|
+
__slots__ = ('__weakref__',)
|
|
1619
1619
|
|
|
1620
1620
|
def __str__(self):
|
|
1621
1621
|
raise NotImplementedError
|
|
@@ -1986,7 +1986,8 @@ class Cube(Rollup):
|
|
|
1986
1986
|
|
|
1987
1987
|
class Window(object):
|
|
1988
1988
|
__slots__ = (
|
|
1989
|
-
'_partition', '_order_by', '_frame', '_start', '_end', '_exclude'
|
|
1989
|
+
'_partition', '_order_by', '_frame', '_start', '_end', '_exclude',
|
|
1990
|
+
'__weakref__')
|
|
1990
1991
|
|
|
1991
1992
|
def __init__(self, partition, order_by=None,
|
|
1992
1993
|
frame=None, start=None, end=0, exclude=None):
|
|
@@ -4,7 +4,6 @@ from sql import Expression, Flavor, Literal, Window
|
|
|
4
4
|
|
|
5
5
|
__all__ = ['Avg', 'BitAnd', 'BitOr', 'BoolAnd', 'BoolOr', 'Count', 'Every',
|
|
6
6
|
'Max', 'Min', 'Stddev', 'Sum', 'Variance']
|
|
7
|
-
_sentinel = object()
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
class Aggregate(Expression):
|
|
@@ -169,20 +168,31 @@ class BoolOr(Aggregate):
|
|
|
169
168
|
_sql = 'BOOL_OR'
|
|
170
169
|
|
|
171
170
|
|
|
171
|
+
class _Star(Expression):
|
|
172
|
+
__slots__ = ()
|
|
173
|
+
|
|
174
|
+
def __str__(self):
|
|
175
|
+
return '*'
|
|
176
|
+
|
|
177
|
+
@property
|
|
178
|
+
def params(self):
|
|
179
|
+
return ()
|
|
180
|
+
|
|
181
|
+
|
|
172
182
|
class Count(Aggregate):
|
|
173
183
|
__slots__ = ()
|
|
174
184
|
_sql = 'COUNT'
|
|
175
185
|
|
|
176
|
-
def __init__(self, expression=
|
|
177
|
-
if expression is _sentinel:
|
|
178
|
-
expression = Literal('*')
|
|
186
|
+
def __init__(self, expression=_Star(), **kwargs):
|
|
179
187
|
super().__init__(expression, **kwargs)
|
|
180
188
|
|
|
181
189
|
@property
|
|
182
190
|
def _case_expression(self):
|
|
183
191
|
expression = super(Count, self)._case_expression
|
|
184
|
-
if (isinstance(self.expression,
|
|
185
|
-
|
|
192
|
+
if (isinstance(self.expression, _Star)
|
|
193
|
+
# Keep testing Literal('*') for backward compatibility
|
|
194
|
+
or (isinstance(self.expression, Literal)
|
|
195
|
+
and expression.value == '*')):
|
|
186
196
|
expression = Literal(1)
|
|
187
197
|
return expression
|
|
188
198
|
|
|
@@ -42,8 +42,8 @@ class TestAggregate(unittest.TestCase):
|
|
|
42
42
|
|
|
43
43
|
def test_count_without_expression(self):
|
|
44
44
|
count = Count()
|
|
45
|
-
self.assertEqual(str(count), 'COUNT(
|
|
46
|
-
self.assertEqual(count.params, (
|
|
45
|
+
self.assertEqual(str(count), 'COUNT(*)')
|
|
46
|
+
self.assertEqual(count.params, ())
|
|
47
47
|
|
|
48
48
|
def test_order_by_one_column(self):
|
|
49
49
|
avg = Avg(self.table.a, order_by=self.table.b)
|
|
@@ -531,14 +531,24 @@ class TestSelect(unittest.TestCase):
|
|
|
531
531
|
def test_order_params(self):
|
|
532
532
|
with_ = With(query=self.table.select(self.table.c,
|
|
533
533
|
where=(self.table.c > 1)))
|
|
534
|
-
w = Window([Literal(
|
|
534
|
+
w = Window([Literal(7)])
|
|
535
535
|
query = Select([Literal(2), Min(self.table.c, window=w)],
|
|
536
536
|
from_=self.table.select(where=self.table.c > 3),
|
|
537
537
|
with_=with_,
|
|
538
538
|
where=self.table.c > 4,
|
|
539
539
|
group_by=[Literal(5)],
|
|
540
|
-
|
|
541
|
-
|
|
540
|
+
having=Literal(6),
|
|
541
|
+
order_by=[Literal(8)])
|
|
542
|
+
self.assertEqual(
|
|
543
|
+
str(query),
|
|
544
|
+
'WITH "c" AS (SELECT "a"."c" FROM "t" AS "a" WHERE ("a"."c" > %s))'
|
|
545
|
+
' SELECT %s, MIN("a"."c") OVER "b" '
|
|
546
|
+
'FROM SELECT * FROM "t" AS "a" WHERE ("a"."c" > %s) '
|
|
547
|
+
'WHERE ("a"."c" > %s) '
|
|
548
|
+
'GROUP BY %s '
|
|
549
|
+
'HAVING %s '
|
|
550
|
+
'WINDOW "b" AS (PARTITION BY %s) '
|
|
551
|
+
'ORDER BY %s')
|
|
542
552
|
self.assertEqual(tuple(query.params), (1, 2, 3, 4, 5, 6, 7, 8))
|
|
543
553
|
|
|
544
554
|
def test_no_as(self):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|