@@ -30,85 +30,90 @@ def error_code(self) -> int:
3030 def error_message (self ) -> str :
3131 return obx_qb_error_message (self ._c_builder )
3232
33- def equals_string (self , prop : Union [int , str , Property ], value : str , case_sensitive : bool = True ):
33+ def equals_string (self , prop : Union [int , str , Property ], value : str , case_sensitive : bool = True ) -> obx_qb_cond :
3434 prop_id = self ._get_property_id (prop )
35- obx_qb_equals_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
36- return self
35+ cond = obx_qb_equals_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
36+ return cond
3737
38- def not_equals_string (self , prop : Union [int , str , Property ], value : str , case_sensitive : bool = True ):
38+ def not_equals_string (self , prop : Union [int , str , Property ], value : str ,
39+ case_sensitive : bool = True ) -> obx_qb_cond :
3940 prop_id = self ._get_property_id (prop )
40- obx_qb_not_equals_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
41- return self
41+ cond = obx_qb_not_equals_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
42+ return cond
4243
43- def contains_string (self , prop : Union [int , str , Property ], value : str , case_sensitive : bool = True ):
44+ def contains_string (self , prop : Union [int , str , Property ], value : str , case_sensitive : bool = True ) -> obx_qb_cond :
4445 prop_id = self ._get_property_id (prop )
45- obx_qb_contains_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
46- return self
46+ cond = obx_qb_contains_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
47+ return cond
4748
48- def starts_with_string (self , prop : Union [int , str , Property ], value : str , case_sensitive : bool = True ):
49+ def starts_with_string (self , prop : Union [int , str , Property ], value : str ,
50+ case_sensitive : bool = True ) -> obx_qb_cond :
4951 prop_id = self ._get_property_id (prop )
50- obx_qb_starts_with_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
51- return self
52+ cond = obx_qb_starts_with_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
53+ return cond
5254
53- def ends_with_string (self , prop : Union [int , str , Property ], value : str , case_sensitive : bool = True ):
55+ def ends_with_string (self , prop : Union [int , str , Property ], value : str , case_sensitive : bool = True ) -> obx_qb_cond :
5456 prop_id = self ._get_property_id (prop )
55- obx_qb_ends_with_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
56- return self
57+ cond = obx_qb_ends_with_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
58+ return cond
5759
58- def greater_than_string (self , prop : Union [int , str , Property ], value : str , case_sensitive : bool = True ):
60+ def greater_than_string (self , prop : Union [int , str , Property ], value : str ,
61+ case_sensitive : bool = True ) -> obx_qb_cond :
5962 prop_id = self ._get_property_id (prop )
60- obx_qb_greater_than_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
61- return self
63+ cond = obx_qb_greater_than_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
64+ return cond
6265
63- def greater_or_equal_string (self , prop : Union [int , str , Property ], value : str , case_sensitive : bool = True ):
66+ def greater_or_equal_string (self , prop : Union [int , str , Property ], value : str ,
67+ case_sensitive : bool = True ) -> obx_qb_cond :
6468 prop_id = self ._get_property_id (prop )
65- obx_qb_greater_or_equal_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
66- return self
69+ cond = obx_qb_greater_or_equal_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
70+ return cond
6771
68- def less_than_string (self , prop : Union [int , str , Property ], value : str , case_sensitive : bool = True ):
72+ def less_than_string (self , prop : Union [int , str , Property ], value : str , case_sensitive : bool = True ) -> obx_qb_cond :
6973 prop_id = self ._get_property_id (prop )
70- obx_qb_less_than_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
71- return self
74+ cond = obx_qb_less_than_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
75+ return cond
7276
73- def less_or_equal_string (self , prop : Union [int , str , Property ], value : str , case_sensitive : bool = True ):
77+ def less_or_equal_string (self , prop : Union [int , str , Property ], value : str ,
78+ case_sensitive : bool = True ) -> obx_qb_cond :
7479 prop_id = self ._get_property_id (prop )
75- obx_qb_less_or_equal_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
76- return self
80+ cond = obx_qb_less_or_equal_string (self ._c_builder , prop_id , c_str (value ), case_sensitive )
81+ return cond
7782
78- def equals_int (self , prop : Union [int , str , Property ], value : int ):
83+ def equals_int (self , prop : Union [int , str , Property ], value : int ) -> obx_qb_cond :
7984 prop_id = self ._get_property_id (prop )
80- obx_qb_equals_int (self ._c_builder , prop_id , value )
81- return self
85+ cond = obx_qb_equals_int (self ._c_builder , prop_id , value )
86+ return cond
8287
83- def not_equals_int (self , prop : Union [int , str , Property ], value : int ):
88+ def not_equals_int (self , prop : Union [int , str , Property ], value : int ) -> obx_qb_cond :
8489 prop_id = self ._get_property_id (prop )
85- obx_qb_not_equals_int (self ._c_builder , prop_id , value )
86- return self
90+ cond = obx_qb_not_equals_int (self ._c_builder , prop_id , value )
91+ return cond
8792
88- def greater_than_int (self , prop : Union [int , str , Property ], value : int ):
93+ def greater_than_int (self , prop : Union [int , str , Property ], value : int ) -> obx_qb_cond :
8994 prop_id = self ._get_property_id (prop )
90- obx_qb_greater_than_int (self ._c_builder , prop_id , value )
91- return self
95+ cond = obx_qb_greater_than_int (self ._c_builder , prop_id , value )
96+ return cond
9297
93- def greater_or_equal_int (self , prop : Union [int , str , Property ], value : int ):
98+ def greater_or_equal_int (self , prop : Union [int , str , Property ], value : int ) -> obx_qb_cond :
9499 prop_id = self ._get_property_id (prop )
95- obx_qb_greater_or_equal_int (self ._c_builder , prop_id , value )
96- return self
100+ cond = obx_qb_greater_or_equal_int (self ._c_builder , prop_id , value )
101+ return cond
97102
98- def less_than_int (self , prop : Union [int , str , Property ], value : int ):
103+ def less_than_int (self , prop : Union [int , str , Property ], value : int ) -> obx_qb_cond :
99104 prop_id = self ._get_property_id (prop )
100- obx_qb_less_than_int (self ._c_builder , prop_id , value )
101- return self
105+ cond = obx_qb_less_than_int (self ._c_builder , prop_id , value )
106+ return cond
102107
103- def less_or_equal_int (self , prop : Union [int , str , Property ], value : int ):
108+ def less_or_equal_int (self , prop : Union [int , str , Property ], value : int ) -> obx_qb_cond :
104109 prop_id = self ._get_property_id (prop )
105- obx_qb_less_or_equal_int (self ._c_builder , prop_id , value )
106- return self
110+ cond = obx_qb_less_or_equal_int (self ._c_builder , prop_id , value )
111+ return cond
107112
108- def between_2ints (self , prop : Union [int , str , Property ], value_a : int , value_b : int ):
113+ def between_2ints (self , prop : Union [int , str , Property ], value_a : int , value_b : int ) -> obx_qb_cond :
109114 prop_id = self ._get_property_id (prop )
110- obx_qb_between_2ints (self ._c_builder , prop_id , value_a , value_b )
111- return self
115+ cond = obx_qb_between_2ints (self ._c_builder , prop_id , value_a , value_b )
116+ return cond
112117
113118 def nearest_neighbors_f32 (self , prop : Union [int , str , Property ], query_vector : Union [np .ndarray , List [float ]],
114119 element_count : int ):
@@ -117,11 +122,21 @@ def nearest_neighbors_f32(self, prop: Union[int, str, Property], query_vector: U
117122 raise Exception (f"query_vector dtype must be float32" )
118123 query_vector_data = query_vector .ctypes .data_as (ctypes .POINTER (ctypes .c_float ))
119124 else : # List[float]
120- query_vector_data = ( ctypes .c_float * len ( query_vector ))( * query_vector )
125+ query_vector_data = py_list_to_c_array ( query_vector , ctypes .c_float )
121126
122127 prop_id = self ._get_property_id (prop )
123- obx_qb_nearest_neighbors_f32 (self ._c_builder , prop_id , query_vector_data , element_count )
124- return self
128+ cond = obx_qb_nearest_neighbors_f32 (self ._c_builder , prop_id , query_vector_data , element_count )
129+ return cond
130+
131+ def any (self , conditions : List [obx_qb_cond ]) -> obx_qb_cond :
132+ c_conditions = py_list_to_c_pointer (conditions , obx_qb_cond )
133+ cond = obx_qb_any (self ._c_builder , c_conditions , len (conditions ))
134+ return cond
135+
136+ def all (self , conditions : List [obx_qb_cond ]) -> obx_qb_cond :
137+ c_conditions = py_list_to_c_pointer (conditions , obx_qb_cond )
138+ cond = obx_qb_all (self ._c_builder , c_conditions , len (conditions ))
139+ return cond
125140
126141 def build (self ) -> Query :
127142 c_query = obx_query (self ._c_builder )
0 commit comments