nuql 0.0.7__py3-none-any.whl → 0.0.9__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.
- nuql/client.py +5 -0
- nuql/fields/datetime_timestamp.py +8 -8
- nuql/resources/records/serialiser.py +3 -0
- nuql/resources/utils/validators.py +15 -0
- {nuql-0.0.7.dist-info → nuql-0.0.9.dist-info}/METADATA +1 -1
- {nuql-0.0.7.dist-info → nuql-0.0.9.dist-info}/RECORD +8 -8
- {nuql-0.0.7.dist-info → nuql-0.0.9.dist-info}/WHEEL +0 -0
- {nuql-0.0.7.dist-info → nuql-0.0.9.dist-info}/licenses/LICENSE +0 -0
nuql/client.py
CHANGED
@@ -47,6 +47,11 @@ class Nuql:
|
|
47
47
|
|
48
48
|
resources.validate_schema(self.__schema, self.fields)
|
49
49
|
|
50
|
+
def __getattr__(self, name: str) -> 'resources.Table':
|
51
|
+
if name in self.__schema:
|
52
|
+
return self.get_table(name)
|
53
|
+
raise AttributeError(f'\'{self.__class__.__name__}\' object has no attribute \'{name}\'')
|
54
|
+
|
50
55
|
@property
|
51
56
|
def indexes(self) -> 'resources.Indexes':
|
52
57
|
return self.__indexes
|
@@ -12,10 +12,10 @@ class DatetimeTimestamp(FieldBase):
|
|
12
12
|
|
13
13
|
def serialise(self, value: datetime | None) -> int | None:
|
14
14
|
"""
|
15
|
-
Serialises a datetime to a timestamp.
|
15
|
+
Serialises a `datetime` to a timestamp.
|
16
16
|
|
17
|
-
:arg value: datetime instance or None
|
18
|
-
:return: int or None
|
17
|
+
:arg value: `datetime` instance or `None`.
|
18
|
+
:return: `int` or `None`.
|
19
19
|
"""
|
20
20
|
if not isinstance(value, datetime):
|
21
21
|
return None
|
@@ -27,19 +27,19 @@ class DatetimeTimestamp(FieldBase):
|
|
27
27
|
message='Datetime value must be timezone-aware.'
|
28
28
|
)
|
29
29
|
|
30
|
-
return int(value.astimezone(UTC).timestamp()
|
30
|
+
return int(value.astimezone(UTC).timestamp())
|
31
31
|
|
32
32
|
def deserialise(self, value: Decimal | None) -> datetime | None:
|
33
33
|
"""
|
34
|
-
Deserialises a timestamp to a datetime
|
34
|
+
Deserialises a timestamp to a `datetime`.
|
35
35
|
|
36
|
-
:arg value: Decimal instance or None
|
37
|
-
:return: datetime instance or None
|
36
|
+
:arg value: `Decimal` instance or `None`.
|
37
|
+
:return: `datetime` instance or `None`.
|
38
38
|
"""
|
39
39
|
if not isinstance(value, Decimal):
|
40
40
|
return None
|
41
41
|
|
42
42
|
try:
|
43
|
-
return datetime.fromtimestamp(int(value)
|
43
|
+
return datetime.fromtimestamp(int(value), UTC)
|
44
44
|
except (ValueError, TypeError):
|
45
45
|
return None
|
@@ -48,6 +48,9 @@ class Serialiser:
|
|
48
48
|
if not isinstance(data, dict):
|
49
49
|
data = {}
|
50
50
|
|
51
|
+
if action != 'query' and isinstance(self.parent, resources.Table):
|
52
|
+
data['nuql:type'] = self.parent.name
|
53
|
+
|
51
54
|
# Serialise provided fields
|
52
55
|
for key, deserialised_value in data.items():
|
53
56
|
field = self.get_field(key)
|
@@ -1,6 +1,8 @@
|
|
1
1
|
__all__ = ['validate_condition_dict', 'validate_schema']
|
2
2
|
|
3
3
|
import inspect
|
4
|
+
import re
|
5
|
+
import keyword
|
4
6
|
from typing import Dict, Any, List, Type
|
5
7
|
|
6
8
|
import nuql
|
@@ -161,5 +163,18 @@ def validate_schema(schema: Dict[str, Any], fields: List[Type['types.FieldType']
|
|
161
163
|
'message': 'Table name in schema must be a string.',
|
162
164
|
}])
|
163
165
|
|
166
|
+
# Validate table name format and reserved keywords
|
167
|
+
if not re.match(r'^[a-zA-Z_][a-zA-Z0-9_]*$', table_name):
|
168
|
+
raise nuql.ValidationError([{
|
169
|
+
'name': 'schema.table_name',
|
170
|
+
'message': f'Table name \'{table_name}\' must match pattern ^[a-zA-Z_][a-zA-Z0-9_]*$.',
|
171
|
+
}])
|
172
|
+
|
173
|
+
if keyword.iskeyword(table_name):
|
174
|
+
raise nuql.ValidationError([{
|
175
|
+
'name': 'schema.table_name',
|
176
|
+
'message': f'Table name \'{table_name}\' is a reserved keyword.',
|
177
|
+
}])
|
178
|
+
|
164
179
|
# Validate table schema
|
165
180
|
validate_table(table_name, config, fields)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
nuql/__init__.py,sha256=IjH6hvOvMlqYwZUk7n2x0wy0XWUtZo0cwADTlv9VW-A,77
|
2
|
-
nuql/client.py,sha256=
|
2
|
+
nuql/client.py,sha256=j_A-n2ldJ9I-Qk5NNzprf5hW-Z9gZZsw_hcUXr4ksxg,3105
|
3
3
|
nuql/connection.py,sha256=6PusMgUwPoOT8X0CqWLKdgsdvdAEwmb_dfelz0WpJE8,1471
|
4
4
|
nuql/exceptions.py,sha256=1dhtHoLJZyP-njCPC2hNTK48tSllbGV7amlwq3tJQps,2044
|
5
5
|
nuql/api/__init__.py,sha256=DKxuIAjckS1vjMIPykbI3h81HszlBB9LdwQuFf53-wo,324
|
@@ -28,7 +28,7 @@ nuql/api/update/utils.py,sha256=ZT2EuSSvoD6-C3Gpybn68N9MohVYDGa6DdpSDIGh-GA,3728
|
|
28
28
|
nuql/fields/__init__.py,sha256=Ldf91fDoiNRkseWo3NksQlOxJTEI-EdS6i1OPjzE_9Y,256
|
29
29
|
nuql/fields/boolean.py,sha256=OnmxZyaFH2up1dHDc5p9iHi8fvYZQV1TPI-LMwSb0NA,712
|
30
30
|
nuql/fields/datetime.py,sha256=4K28yydnzUc1HsMH-lgSSNOx2NbEL4qXC3kTpuRBVis,1386
|
31
|
-
nuql/fields/datetime_timestamp.py,sha256
|
31
|
+
nuql/fields/datetime_timestamp.py,sha256=-R8IWDq0y92lkqq6BUJLzgeGgcx1RNd6jdA3sHPmjrU,1281
|
32
32
|
nuql/fields/float.py,sha256=x48Spo_GNku0djO0Ogs8usZTfwOY-27Mh5OPOQBO3OY,1316
|
33
33
|
nuql/fields/integer.py,sha256=pHs3CJM4xKN60IYg5aTe4QjSQQBR4jp08HyANtidHgs,1312
|
34
34
|
nuql/fields/key.py,sha256=vG_yj4Lkiz3bsD2f31HEVgU5lEde_gTYk4awQ78gko8,6912
|
@@ -48,19 +48,19 @@ nuql/resources/fields/field_map.py,sha256=bOzoBFbB2XOyLfnqaVEL_BDwt3S9_oUGIl1N0a
|
|
48
48
|
nuql/resources/fields/value.py,sha256=CG3PnGeSMHDQciIMR6jkMhogCJZhpEfipLdyk9gnjJw,59
|
49
49
|
nuql/resources/records/__init__.py,sha256=gD8-xt4uIOpx_ZTnw1QTzOiwUpjKhR3nhkZw4AmEvaI,81
|
50
50
|
nuql/resources/records/projections.py,sha256=PTwoc8-XXieXsYw0H-3Fv7G8SzSN__j35QsqempXBj8,1618
|
51
|
-
nuql/resources/records/serialiser.py,sha256=
|
51
|
+
nuql/resources/records/serialiser.py,sha256=jWH9CHbxvEliea03lfKUgs-ym5PbURLWLKPOK5dEAMM,5297
|
52
52
|
nuql/resources/records/validator.py,sha256=d8GQN_rwnuKnV6tkEDCqswE_ARso7ZNH0vB1L2eVrj0,1558
|
53
53
|
nuql/resources/tables/__init__.py,sha256=Bk8ewpPb_myliQPmyIarzma_Vezd4XR-Z1lABsTUMPQ,46
|
54
54
|
nuql/resources/tables/indexes.py,sha256=5e5bQ_yRgyLmnoXuKAqEw0mJJhY_NE4Sk0vavvMG2m4,5076
|
55
55
|
nuql/resources/tables/table.py,sha256=2UjpxhW_0C2nXQr6gMf2k8JLRYA6M1vf5QaGXMDRZw4,5513
|
56
56
|
nuql/resources/utils/__init__.py,sha256=vRZp-isHvATfzDlIPLOSu8x6sj3GprPQViL2l6p4OQk,48
|
57
57
|
nuql/resources/utils/dict.py,sha256=K-BWbeaXEIDwSRLUXI8BIKr9UluOE0dhd378733j6ug,553
|
58
|
-
nuql/resources/utils/validators.py,sha256=
|
58
|
+
nuql/resources/utils/validators.py,sha256=IKrknjGdkZcXd9Pr6Ndisglj-DvwNawRCIXnzDY8gQg,7184
|
59
59
|
nuql/types/__init__.py,sha256=Ea4KR4mUs1RNUEskKF9sXfGpoQw2V9cnIYeE20wkChs,76
|
60
60
|
nuql/types/config.py,sha256=lFfPPe62l4DkfLXR8ecw5AiSRAFzsTYy_3a0d_1M7hY,659
|
61
61
|
nuql/types/fields.py,sha256=LjGgXM84WO54gRDkgvnwF3pjFvFxErdGYOvs0BskF_o,883
|
62
62
|
nuql/types/serialisation.py,sha256=XAy_gARcwYmfEuxWAJox2ClWK9ow0F5WXKVbMUVBq9w,242
|
63
|
-
nuql-0.0.
|
64
|
-
nuql-0.0.
|
65
|
-
nuql-0.0.
|
66
|
-
nuql-0.0.
|
63
|
+
nuql-0.0.9.dist-info/METADATA,sha256=YsBKPqCTNBbd3p7hMrZPkHz_l1KyW6C5YEJWi7BLNYM,1667
|
64
|
+
nuql-0.0.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
65
|
+
nuql-0.0.9.dist-info/licenses/LICENSE,sha256=AS8DF6oGYsvk781m40Nec9eCkj_S_oUVAWaFakB2LMs,1097
|
66
|
+
nuql-0.0.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|