nuql 0.0.8__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 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
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nuql
3
- Version: 0.0.8
3
+ Version: 0.0.9
4
4
  Summary: Nuql (pronounced 'nuckle') is a lightweight DynamoDB library for implementing the single table model pattern.
5
5
  License: MIT License
6
6
 
@@ -1,5 +1,5 @@
1
1
  nuql/__init__.py,sha256=IjH6hvOvMlqYwZUk7n2x0wy0XWUtZo0cwADTlv9VW-A,77
2
- nuql/client.py,sha256=SuLEKKKcxWZR252GP9w7ZB4327tn_mdSLbIWNtEMKdk,2868
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
@@ -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=5vqLjNzY07Rrl-u_-SufImjAGCxpF8txwzlhDW0OHiE,5169
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=tUv6-u29KMpazdvM8vKHEUtyaMUkE61KCdJCEG8LhZk,6583
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.8.dist-info/METADATA,sha256=pXKtyyEnRb_cVkKVNVQPUS2X2lpgKJayQwWxaGtRKGk,1667
64
- nuql-0.0.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
65
- nuql-0.0.8.dist-info/licenses/LICENSE,sha256=AS8DF6oGYsvk781m40Nec9eCkj_S_oUVAWaFakB2LMs,1097
66
- nuql-0.0.8.dist-info/RECORD,,
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