python-sql 1.5.0__tar.gz → 1.5.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.
- {python_sql-1.5.0 → python_sql-1.5.1}/.hgtags +1 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/CHANGELOG +4 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/PKG-INFO +1 -1
- {python_sql-1.5.0 → python_sql-1.5.1}/python_sql.egg-info/PKG-INFO +1 -1
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/__init__.py +30 -7
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_select.py +10 -10
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_window.py +6 -6
- {python_sql-1.5.0 → python_sql-1.5.1}/.flake8 +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/.gitlab-ci.yml +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/.isort.cfg +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/COPYRIGHT +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/MANIFEST.in +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/README.rst +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/python_sql.egg-info/SOURCES.txt +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/python_sql.egg-info/dependency_links.txt +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/python_sql.egg-info/top_level.txt +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/setup.cfg +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/setup.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/aggregate.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/conditionals.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/functions.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/operators.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/__init__.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_aggregate.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_alias.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_as.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_cast.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_collate.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_column.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_combining_query.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_conditionals.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_delete.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_for.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_functions.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_insert.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_join.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_lateral.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_literal.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_merge.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_operators.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_order.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_table.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_update.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_values.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/sql/tests/test_with.py +0 -0
- {python_sql-1.5.0 → python_sql-1.5.1}/tox.ini +0 -0
|
@@ -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.5.
|
|
10
|
+
__version__ = '1.5.1'
|
|
11
11
|
__all__ = [
|
|
12
12
|
'Flavor', 'Table', 'Values', 'Literal', 'Column', 'Grouping', 'Conflict',
|
|
13
13
|
'Matched', 'MatchedUpdate', 'MatchedDelete',
|
|
@@ -380,13 +380,14 @@ class SelectQuery(WithQuery):
|
|
|
380
380
|
|
|
381
381
|
@property
|
|
382
382
|
def _limit_offset_str(self):
|
|
383
|
+
param = Flavor.get().param
|
|
383
384
|
if Flavor.get().limitstyle == 'limit':
|
|
384
385
|
offset = ''
|
|
385
386
|
if self.offset:
|
|
386
|
-
offset = ' OFFSET %s' %
|
|
387
|
+
offset = ' OFFSET %s' % param
|
|
387
388
|
limit = ''
|
|
388
389
|
if self.limit is not None:
|
|
389
|
-
limit = ' LIMIT %s' %
|
|
390
|
+
limit = ' LIMIT %s' % param
|
|
390
391
|
elif self.offset:
|
|
391
392
|
max_limit = Flavor.get().max_limit
|
|
392
393
|
if max_limit:
|
|
@@ -395,12 +396,27 @@ class SelectQuery(WithQuery):
|
|
|
395
396
|
else:
|
|
396
397
|
offset = ''
|
|
397
398
|
if self.offset:
|
|
398
|
-
offset = ' OFFSET (%s) ROWS' %
|
|
399
|
+
offset = ' OFFSET (%s) ROWS' % param
|
|
399
400
|
fetch = ''
|
|
400
401
|
if self.limit is not None:
|
|
401
|
-
fetch = ' FETCH FIRST (%s) ROWS ONLY' %
|
|
402
|
+
fetch = ' FETCH FIRST (%s) ROWS ONLY' % param
|
|
402
403
|
return offset + fetch
|
|
403
404
|
|
|
405
|
+
@property
|
|
406
|
+
def _limit_offset_params(self):
|
|
407
|
+
p = []
|
|
408
|
+
if Flavor.get().limitstyle == 'limit':
|
|
409
|
+
if self.limit is not None:
|
|
410
|
+
p.append(self.limit)
|
|
411
|
+
if self.offset:
|
|
412
|
+
p.append(self.offset)
|
|
413
|
+
else:
|
|
414
|
+
if self.offset:
|
|
415
|
+
p.append(self.offset)
|
|
416
|
+
if self.limit is not None:
|
|
417
|
+
p.append(self.limit)
|
|
418
|
+
return tuple(p)
|
|
419
|
+
|
|
404
420
|
def as_(self, output_name):
|
|
405
421
|
return As(self, output_name)
|
|
406
422
|
|
|
@@ -663,6 +679,7 @@ class Select(FromItem, SelectQuery):
|
|
|
663
679
|
p.extend(self.having.params)
|
|
664
680
|
for window in self.windows:
|
|
665
681
|
p.extend(window.params)
|
|
682
|
+
p.extend(self._limit_offset_params)
|
|
666
683
|
return tuple(p)
|
|
667
684
|
|
|
668
685
|
|
|
@@ -1992,6 +2009,7 @@ class Window(object):
|
|
|
1992
2009
|
return AliasManager.contains(self)
|
|
1993
2010
|
|
|
1994
2011
|
def __str__(self):
|
|
2012
|
+
param = Flavor.get().param
|
|
1995
2013
|
partition = ''
|
|
1996
2014
|
if self.partition:
|
|
1997
2015
|
partition = 'PARTITION BY ' + ', '.join(map(str, self.partition))
|
|
@@ -2005,9 +2023,9 @@ class Window(object):
|
|
|
2005
2023
|
elif not frame:
|
|
2006
2024
|
return 'CURRENT ROW'
|
|
2007
2025
|
elif frame < 0:
|
|
2008
|
-
return '%s PRECEDING' %
|
|
2026
|
+
return '%s PRECEDING' % param
|
|
2009
2027
|
elif frame > 0:
|
|
2010
|
-
return '%s FOLLOWING' %
|
|
2028
|
+
return '%s FOLLOWING' % param
|
|
2011
2029
|
|
|
2012
2030
|
frame = ''
|
|
2013
2031
|
if self.frame:
|
|
@@ -2028,6 +2046,11 @@ class Window(object):
|
|
|
2028
2046
|
if self.order_by:
|
|
2029
2047
|
for expression in self.order_by:
|
|
2030
2048
|
p.extend(expression.params)
|
|
2049
|
+
if self.frame:
|
|
2050
|
+
if self.start:
|
|
2051
|
+
p.append(abs(self.start))
|
|
2052
|
+
if self.end:
|
|
2053
|
+
p.append(abs(self.end))
|
|
2031
2054
|
return tuple(p)
|
|
2032
2055
|
|
|
2033
2056
|
|
|
@@ -253,13 +253,13 @@ class TestSelect(unittest.TestCase):
|
|
|
253
253
|
Flavor.set(Flavor(limitstyle='limit'))
|
|
254
254
|
query = self.table.select(limit=50, offset=10)
|
|
255
255
|
self.assertEqual(str(query),
|
|
256
|
-
'SELECT * FROM "t" AS "a" LIMIT
|
|
257
|
-
self.assertEqual(tuple(query.params), ())
|
|
256
|
+
'SELECT * FROM "t" AS "a" LIMIT %s OFFSET %s')
|
|
257
|
+
self.assertEqual(tuple(query.params), (50, 10))
|
|
258
258
|
|
|
259
259
|
query.limit = None
|
|
260
260
|
self.assertEqual(str(query),
|
|
261
|
-
'SELECT * FROM "t" AS "a" OFFSET
|
|
262
|
-
self.assertEqual(tuple(query.params), ())
|
|
261
|
+
'SELECT * FROM "t" AS "a" OFFSET %s')
|
|
262
|
+
self.assertEqual(tuple(query.params), (10,))
|
|
263
263
|
|
|
264
264
|
query.offset = 0
|
|
265
265
|
self.assertEqual(str(query),
|
|
@@ -280,8 +280,8 @@ class TestSelect(unittest.TestCase):
|
|
|
280
280
|
|
|
281
281
|
query.offset = 10
|
|
282
282
|
self.assertEqual(str(query),
|
|
283
|
-
'SELECT * FROM "t" AS "a" LIMIT -1 OFFSET
|
|
284
|
-
self.assertEqual(tuple(query.params), ())
|
|
283
|
+
'SELECT * FROM "t" AS "a" LIMIT -1 OFFSET %s')
|
|
284
|
+
self.assertEqual(tuple(query.params), (10,))
|
|
285
285
|
finally:
|
|
286
286
|
Flavor.set(Flavor())
|
|
287
287
|
|
|
@@ -291,13 +291,13 @@ class TestSelect(unittest.TestCase):
|
|
|
291
291
|
query = self.table.select(limit=50, offset=10)
|
|
292
292
|
self.assertEqual(str(query),
|
|
293
293
|
'SELECT * FROM "t" AS "a" '
|
|
294
|
-
'OFFSET (
|
|
295
|
-
self.assertEqual(tuple(query.params), ())
|
|
294
|
+
'OFFSET (%s) ROWS FETCH FIRST (%s) ROWS ONLY')
|
|
295
|
+
self.assertEqual(tuple(query.params), (10, 50))
|
|
296
296
|
|
|
297
297
|
query.limit = None
|
|
298
298
|
self.assertEqual(str(query),
|
|
299
|
-
'SELECT * FROM "t" AS "a" OFFSET (
|
|
300
|
-
self.assertEqual(tuple(query.params), ())
|
|
299
|
+
'SELECT * FROM "t" AS "a" OFFSET (%s) ROWS')
|
|
300
|
+
self.assertEqual(tuple(query.params), (10,))
|
|
301
301
|
|
|
302
302
|
query.offset = 0
|
|
303
303
|
self.assertEqual(str(query),
|
|
@@ -33,22 +33,22 @@ class TestWindow(unittest.TestCase):
|
|
|
33
33
|
window.start = -1
|
|
34
34
|
self.assertEqual(str(window),
|
|
35
35
|
'PARTITION BY "c" RANGE '
|
|
36
|
-
'BETWEEN
|
|
37
|
-
self.assertEqual(window.params, ())
|
|
36
|
+
'BETWEEN %s PRECEDING AND CURRENT ROW')
|
|
37
|
+
self.assertEqual(window.params, (1,))
|
|
38
38
|
|
|
39
39
|
window.start = 0
|
|
40
40
|
window.end = 1
|
|
41
41
|
self.assertEqual(str(window),
|
|
42
42
|
'PARTITION BY "c" RANGE '
|
|
43
|
-
'BETWEEN CURRENT ROW AND
|
|
44
|
-
self.assertEqual(window.params, ())
|
|
43
|
+
'BETWEEN CURRENT ROW AND %s FOLLOWING')
|
|
44
|
+
self.assertEqual(window.params, (1,))
|
|
45
45
|
|
|
46
46
|
window.start = 1
|
|
47
47
|
window.end = None
|
|
48
48
|
self.assertEqual(str(window),
|
|
49
49
|
'PARTITION BY "c" RANGE '
|
|
50
|
-
'BETWEEN
|
|
51
|
-
self.assertEqual(window.params, ())
|
|
50
|
+
'BETWEEN %s FOLLOWING AND UNBOUNDED FOLLOWING')
|
|
51
|
+
self.assertEqual(window.params, (1,))
|
|
52
52
|
|
|
53
53
|
def test_window_exclude(self):
|
|
54
54
|
t = Table('t')
|
|
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
|