FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sqlobject/sqlobject/tests/test_sorting.py at master · sqlobject/sqlobject · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
sqlobject
/
sqlobject
Public
Notifications
You must be signed in to change notification settings
Fork
26
Star
156
Code
Issues
2
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
sqlobject
/
sqlobject
/
tests
/
test_sorting.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
80 lines (62 loc) · 2.55 KB
Breadcrumbs
sqlobject
/
sqlobject
/
tests
/
test_sorting.py
Copy path
File metadata and controls
80 lines (62 loc) · 2.55 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from
sqlobject
import
DESC
,
SQLObject
,
StringCol
,
sqlmeta
from
sqlobject
.
tests
.
dbtest
import
inserts
,
setupClass
class
Names
(
SQLObject
):
class
sqlmeta
(
sqlmeta
):
table
=
'names_table'
defaultOrder
=
[
'lastName'
,
'firstName'
]
firstName
=
StringCol
(
length
=
30
)
lastName
=
StringCol
(
length
=
30
)
def
setupNames
():
setupClass
(
Names
)
inserts
(
Names
, [(
'aj'
,
'baker'
), (
'joe'
,
'robbins'
),
(
'tim'
,
'jackson'
), (
'joe'
,
'baker'
),
(
'zoe'
,
'robbins'
)],
schema
=
'firstName lastName'
)
def
nameList
(
names
):
result
=
[]
for
name
in
names
:
result
.
append
(
'%s %s'
%
(
name
.
firstName
,
name
.
lastName
))
return
result
def
firstList
(
names
):
return
[
n
.
firstName
for
n
in
names
]
def
test_defaultOrder
():
setupNames
()
assert
nameList
(
Names
.
select
())
==
\
[
'aj baker'
,
'joe baker'
,
'tim jackson'
,
'joe robbins'
,
'zoe robbins'
]
def
test_otherOrder
():
setupNames
()
assert
nameList
(
Names
.
select
().
orderBy
([
'firstName'
,
'lastName'
]))
==
\
[
'aj baker'
,
'joe baker'
,
'joe robbins'
,
'tim jackson'
,
'zoe robbins'
]
def
test_untranslatedColumnOrder
():
setupNames
()
assert
nameList
(
Names
.
select
().
orderBy
([
'first_name'
,
'last_name'
]))
==
\
[
'aj baker'
,
'joe baker'
,
'joe robbins'
,
'tim jackson'
,
'zoe robbins'
]
def
test_singleUntranslatedColumnOrder
():
setupNames
()
assert
firstList
(
Names
.
select
().
orderBy
(
'firstName'
))
==
\
[
'aj'
,
'joe'
,
'joe'
,
'tim'
,
'zoe'
]
assert
firstList
(
Names
.
select
().
orderBy
(
'first_name'
))
==
\
[
'aj'
,
'joe'
,
'joe'
,
'tim'
,
'zoe'
]
assert
firstList
(
Names
.
select
().
orderBy
(
'-firstName'
))
==
\
[
'zoe'
,
'tim'
,
'joe'
,
'joe'
,
'aj'
]
assert
firstList
(
Names
.
select
().
orderBy
(
u'-first_name'
))
==
\
[
'zoe'
,
'tim'
,
'joe'
,
'joe'
,
'aj'
]
assert
firstList
(
Names
.
select
().
orderBy
(
Names
.
q
.
firstName
))
==
\
[
'aj'
,
'joe'
,
'joe'
,
'tim'
,
'zoe'
]
assert
firstList
(
Names
.
select
().
orderBy
(
'firstName'
).
reversed
())
==
\
[
'zoe'
,
'tim'
,
'joe'
,
'joe'
,
'aj'
]
assert
firstList
(
Names
.
select
().
orderBy
(
'-firstName'
).
reversed
())
==
\
[
'aj'
,
'joe'
,
'joe'
,
'tim'
,
'zoe'
]
assert
firstList
(
Names
.
select
().
orderBy
(
DESC
(
Names
.
q
.
firstName
)))
==
\
[
'zoe'
,
'tim'
,
'joe'
,
'joe'
,
'aj'
]
assert
firstList
(
Names
.
select
().
orderBy
(
Names
.
q
.
firstName
).
reversed
())
==
\
[
'zoe'
,
'tim'
,
'joe'
,
'joe'
,
'aj'
]
assert
firstList
(
Names
.
select
().
orderBy
(
DESC
(
Names
.
q
.
firstName
)).
reversed
())
==
\
[
'aj'
,
'joe'
,
'joe'
,
'tim'
,
'zoe'
]
Back
|
FazBrowse Home
|
New Git URL