Skip to content

Commit b25a774

Browse files
authored
Merge pull request #191 from poissoncorp/RDBC-740
Multiple minor tickets RDBC (739-749)
2 parents be7987f + 243b292 commit b25a774

File tree

6 files changed

+30
-20
lines changed

6 files changed

+30
-20
lines changed

ravendb/data/query.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import Union, TYPE_CHECKING
22

3+
from ravendb.documents.queries.facets.misc import FacetTermSortMode
34
from ravendb.tools.utils import Utils
45
from abc import ABCMeta
56
from enum import Enum
@@ -197,16 +198,6 @@ def __str__(self):
197198
return self.value
198199

199200

200-
class FacetTermSortMode(Enum):
201-
value_asc = "ValueAsc"
202-
value_desc = "ValueDesc"
203-
hits_asc = "HitsAsc"
204-
hits_desc = "HitsDesc"
205-
206-
def __str__(self):
207-
return self.value
208-
209-
210201
class OldFacet(object):
211202
def __init__(
212203
self,
@@ -218,7 +209,7 @@ def __init__(
218209
aggregation_field=None,
219210
aggregation_type=None,
220211
max_result=None,
221-
term_sort_mode=FacetTermSortMode.value_asc,
212+
term_sort_mode=FacetTermSortMode.VALUE_ASC,
222213
include_remaining_terms=False,
223214
):
224215
"""

ravendb/documents/indexes/spatial/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def geohash_prefix_tree_index(
165165
opts.units = circle_radius_units
166166
return opts
167167

168-
def quad_prefix_tree_level(
168+
def quad_prefix_tree_index(
169169
self, max_tree_level: int, circle_radius_units: SpatialUnits = SpatialUnits.KILOMETERS
170170
) -> SpatialOptions:
171171
if max_tree_level == 0:

ravendb/documents/queries/facets/definitions.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@ def to_facet_token(self, add_query_parameter: Callable[[object], str]) -> FacetT
4444
pass
4545

4646
def to_json(self) -> Dict:
47-
return {
47+
json_dict = {
4848
"DisplayFieldName": self.display_field_name,
49-
"Options": self.options.to_json(),
5049
"Aggregations": {
5150
aggregation.to_json(): {aggregation_field.to_json() for aggregation_field in aggregation_fields_set}
5251
for aggregation, aggregation_fields_set in self.aggregations.items()
5352
},
5453
}
54+
if self.options:
55+
json_dict["Options"] = self.options.to_json()
56+
return json_dict
5557

5658
@classmethod
5759
def from_json(cls, json_dict: Dict) -> FacetBase:
@@ -133,6 +135,15 @@ class FacetSetup:
133135
def __init__(self, facets: List[Facet] = None, range_facets: List[RangeFacet] = None):
134136
self.facets = facets or []
135137
self.range_facets = range_facets or []
138+
self.Id: Optional[str] = None
139+
140+
@property
141+
def id_(self):
142+
return self.Id
143+
144+
@id_.setter
145+
def id_(self, value: str):
146+
self.Id = value
136147

137148
@classmethod
138149
def from_json(cls, json_dict: Dict) -> FacetSetup:

ravendb/documents/session/document_session.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from ravendb.documents.operations.attachments import (
2121
GetAttachmentOperation,
2222
AttachmentName,
23+
CloseableAttachmentResult,
2324
)
2425
from ravendb.documents.operations.batch import BatchOperation
2526
from ravendb.documents.operations.executor import OperationExecutor, SessionOperationExecutor
@@ -1027,7 +1028,14 @@ def exists(self, document_id: str, name: str) -> bool:
10271028
self.__session._request_executor.execute_command(command, self.__session.session_info)
10281029
return command.result is not None
10291030

1030-
def store(self, entity_or_document_id, name, stream, content_type=None, change_vector=None):
1031+
def store(
1032+
self,
1033+
entity_or_document_id: Union[object, str],
1034+
name: str,
1035+
stream: bytes,
1036+
content_type: str = None,
1037+
change_vector: str = None,
1038+
):
10311039
if not isinstance(entity_or_document_id, str):
10321040
entity = self.__session._documents_by_entity.get(entity_or_document_id, None)
10331041
if not entity:
@@ -1120,7 +1128,7 @@ def get(
11201128
name: str = None,
11211129
# att_requests: Optional[List[AttachmentRequest]] = None,
11221130
# todo: fetching multiple attachments with single command
1123-
):
1131+
) -> CloseableAttachmentResult:
11241132
# if att_requests is not None:
11251133
# if entity_or_document_id or name:
11261134
# raise ValueError("Specify either <att_requests> or <entity/document_id, name>")

ravendb/documents/session/loaders/loaders.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def include(self, path: str) -> LoaderWithInclude:
1616
pass
1717

1818
@abstractmethod
19-
def load(self, object_type: type, *ids: str) -> Dict[str, object]:
19+
def load(self, object_type: _T, *ids: str) -> _T:
2020
pass
2121

2222

@@ -29,7 +29,7 @@ def include(self, path: str) -> LoaderWithInclude:
2929
self.__includes.append(path)
3030
return self
3131

32-
def load(self, object_type: Type[_T], *ids: str) -> Dict[str, object]:
32+
def load(self, object_type: Type[_T], *ids: str) -> Dict[str, _T]:
3333
return self.__session._load_internal(object_type, list(ids), self.__includes)
3434

3535

@@ -42,5 +42,5 @@ def include(self, path: str) -> LazyMultiLoaderWithInclude:
4242
self.__includes.append(path)
4343
return self
4444

45-
def load(self, object_type: Type[_T], *ids: str) -> Lazy[Dict[str, object]]:
45+
def load(self, object_type: Type[_T], *ids: str) -> Lazy[Dict[str, _T]]:
4646
return self.__session.lazy_load_internal(object_type, list(ids), self.__includes, None)

ravendb/documents/session/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,7 @@ def aggregate_by(
20972097

20982098
return AggregationDocumentQuery(self)
20992099

2100-
def aggregate_by_facets(self, *facets: FacetBase) -> AggregationDocumentQuery[_T]:
2100+
def aggregate_by_facets(self, facets: List[FacetBase]) -> AggregationDocumentQuery[_T]:
21012101
for facet in facets:
21022102
self.aggregate_by(facet)
21032103

0 commit comments

Comments
 (0)