Skip to content

Commit 3a9d231

Browse files
committed
Removed multiple operators 🚖
1 parent b1cc735 commit 3a9d231

File tree

6 files changed

+290
-51
lines changed

6 files changed

+290
-51
lines changed

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.9.1 : 2021-07-20
4+
5+
- **Fix**: Fixed problem with multiple properites in operations (I had to remove comparison property check)
6+
37
## 0.9.0 : 2021-06-25
48

59
- **Fix**: Fixed nested conditions (`Operator` can contain another `Operator`)

‎duckql/structures/comparision.py‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
from enum import Enum
22
from typing import List
33

4-
from pydantic import validator
5-
64
try:
75
from typing import Literal
86
except ImportError:
97
from typing_extensions import Literal
108

11-
from duckql.exceptions import ParseError
129
from duckql.base import BaseType
1310
from duckql.properties.array import Array
1411

@@ -59,13 +56,6 @@ def containers(cls) -> List["Comparision.Operation"]:
5956
properties: List[BaseType]
6057
operation: Operation
6158

62-
@validator('properties', pre=True)
63-
def check_number_of_properties(cls, v):
64-
if len(v) != 2:
65-
raise ParseError("Comparison requires exactly two attributes!")
66-
67-
return v
68-
6959
def to_sql(self) -> str:
7060
sql = f"{self.properties[0]} {self.operation}"
7161

‎duckql/version.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.9.0'
1+
__version__ = '0.9.1'
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
{
2+
"obj": "structures.Query",
3+
"entity": "donations",
4+
"properties": [
5+
{
6+
"obj": "properties.Property",
7+
"name": "donations.periodicity",
8+
"alias": "donations__periodicity"
9+
},
10+
{
11+
"obj": "properties.Property",
12+
"name": "donations.id",
13+
"alias": "donations__id"
14+
},
15+
{
16+
"obj": "properties.Property",
17+
"name": "campaigns__organisations__fk.id",
18+
"alias": "organisations__id"
19+
},
20+
{
21+
"obj": "properties.Property",
22+
"name": "campaigns__organisations__fk.name",
23+
"alias": "organisations__name"
24+
},
25+
{
26+
"obj": "properties.Property",
27+
"name": "donations__campaigns__fk.note",
28+
"alias": "campaigns__note"
29+
},
30+
{
31+
"obj": "properties.Property",
32+
"name": "donations__donors__fk.name",
33+
"alias": "donors__name"
34+
},
35+
{
36+
"obj": "properties.Property",
37+
"name": "donations__donors__fk.surname",
38+
"alias": "donors__surname"
39+
},
40+
{
41+
"obj": "properties.Property",
42+
"name": "donations__payments__fk.value",
43+
"alias": "payments__value"
44+
},
45+
{
46+
"obj": "properties.Property",
47+
"name": "donations__payments__fk.happened_at",
48+
"alias": "payments__happened_at"
49+
},
50+
{
51+
"obj": "properties.Property",
52+
"name": "donations__payments__fk.status",
53+
"alias": "payments__status"
54+
},
55+
{
56+
"obj": "properties.Property",
57+
"name": "donations__payments__fk.variable_symbol",
58+
"alias": "payments__variable_symbol"
59+
}
60+
],
61+
"conditions": {
62+
"obj": "structures.Operator",
63+
"operation": "and",
64+
"properties": [
65+
{
66+
"obj": "structures.Comparision",
67+
"properties": [
68+
{
69+
"obj": "properties.Property",
70+
"name": "donations__payments__fk.status"
71+
},
72+
{
73+
"obj": "properties.Array",
74+
"values": [
75+
{
76+
"obj": "properties.Constant",
77+
"value": "successful"
78+
}
79+
]
80+
}
81+
],
82+
"operation": "in"
83+
},
84+
{
85+
"obj": "structures.Operator",
86+
"operation": "or",
87+
"properties": [
88+
{
89+
"obj": "structures.Comparision",
90+
"properties": [
91+
{
92+
"obj": "properties.Property",
93+
"name": "donations__payments__fk.value"
94+
},
95+
{
96+
"obj": "properties.Constant",
97+
"value": 0.01
98+
}
99+
],
100+
"operation": "eq"
101+
},
102+
{
103+
"obj": "structures.Comparision",
104+
"properties": [
105+
{
106+
"obj": "properties.Property",
107+
"name": "donations__payments__fk.value"
108+
},
109+
{
110+
"obj": "properties.Constant",
111+
"value": 1
112+
}
113+
],
114+
"operation": "eq"
115+
},
116+
{
117+
"obj": "structures.Comparision",
118+
"properties": [
119+
{
120+
"obj": "properties.Property",
121+
"name": "donations__payments__fk.value"
122+
},
123+
{
124+
"obj": "properties.Constant",
125+
"value": 5
126+
}
127+
],
128+
"operation": "eq"
129+
}
130+
]
131+
}
132+
]
133+
},
134+
"order": [
135+
{
136+
"obj": "structures.Order",
137+
"property": {
138+
"obj": "properties.Property",
139+
"name": "payments__value"
140+
},
141+
"kind": "ASC"
142+
}
143+
],
144+
"limit": {
145+
"obj": "structures.Limit",
146+
"limit": 10,
147+
"offset": 0
148+
},
149+
"joins": [
150+
{
151+
"obj": "structures.Join",
152+
"entity": "donors",
153+
"type": "left",
154+
"on": {
155+
"obj": "structures.Comparision",
156+
"properties": [
157+
{
158+
"obj": "properties.Property",
159+
"name": "donations__donors__fk.id"
160+
},
161+
{
162+
"obj": "properties.Property",
163+
"name": "donations.donor_id"
164+
}
165+
],
166+
"operation": "eq"
167+
},
168+
"alias": "donations__donors__fk"
169+
},
170+
{
171+
"obj": "structures.Join",
172+
"entity": "campaigns",
173+
"type": "left",
174+
"on": {
175+
"obj": "structures.Comparision",
176+
"properties": [
177+
{
178+
"obj": "properties.Property",
179+
"name": "donations__campaigns__fk.id"
180+
},
181+
{
182+
"obj": "properties.Property",
183+
"name": "donations.campaign_id"
184+
}
185+
],
186+
"operation": "eq"
187+
},
188+
"alias": "donations__campaigns__fk"
189+
},
190+
{
191+
"obj": "structures.Join",
192+
"entity": "payments",
193+
"type": "right",
194+
"on": {
195+
"obj": "structures.Comparision",
196+
"properties": [
197+
{
198+
"obj": "properties.Property",
199+
"name": "donations.id"
200+
},
201+
{
202+
"obj": "properties.Property",
203+
"name": "donations__payments__fk.donation_id"
204+
}
205+
],
206+
"operation": "eq"
207+
},
208+
"alias": "donations__payments__fk"
209+
},
210+
{
211+
"obj": "structures.Join",
212+
"entity": "organisations",
213+
"type": "left",
214+
"on": {
215+
"obj": "structures.Comparision",
216+
"properties": [
217+
{
218+
"obj": "properties.Property",
219+
"name": "campaigns__organisations__fk.id"
220+
},
221+
{
222+
"obj": "properties.Property",
223+
"name": "donations__campaigns__fk.organisation_id"
224+
}
225+
],
226+
"operation": "eq"
227+
},
228+
"alias": "campaigns__organisations__fk"
229+
}
230+
]
231+
}

0 commit comments

Comments
 (0)