Skip to content

Commit ce746bd

Browse files
committed
property/condition optimization: case_sensistive is opt-in for strings #29
1 parent 8d39ec1 commit ce746bd

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

objectbox/condition.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ def alias(self, value: str):
113113

114114
def _apply_eq(self, qb: QueryBuilder) -> obx_qb_cond:
115115
value = self._args['value']
116-
case_sensitive = self._args['case_sensitive']
117116
if isinstance(value, str):
117+
case_sensitive = self._args['case_sensitive']
118118
return qb.equals_string(self._property_id, value, case_sensitive)
119119
elif isinstance(value, int):
120120
return qb.equals_int(self._property_id, value)
@@ -123,8 +123,8 @@ def _apply_eq(self, qb: QueryBuilder) -> obx_qb_cond:
123123

124124
def _apply_not_eq(self, qb: QueryBuilder) -> obx_qb_cond:
125125
value = self._args['value']
126-
case_sensitive = self._args['case_sensitive']
127126
if isinstance(value, str):
127+
case_sensitive = self._args['case_sensitive']
128128
return qb.not_equals_string(self._property_id, value, case_sensitive)
129129
elif isinstance(value, int):
130130
return qb.not_equals_int(self._property_id, value)
@@ -149,16 +149,16 @@ def _apply_starts_with(self, qb: QueryBuilder) -> obx_qb_cond:
149149

150150
def _apply_ends_with(self, qb: QueryBuilder) -> obx_qb_cond:
151151
value = self._args['value']
152-
case_sensitive = self._args['case_sensitive']
153152
if isinstance(value, str):
153+
case_sensitive = self._args['case_sensitive']
154154
return qb.ends_with_string(self._property_id, value, case_sensitive)
155155
else:
156156
raise Exception(f"Unsupported type for 'ENDS_WITH': {type(value)}")
157157

158158
def _apply_gt(self, qb: QueryBuilder) -> obx_qb_cond:
159159
value = self._args['value']
160-
case_sensitive = self._args['case_sensitive']
161160
if isinstance(value, str):
161+
case_sensitive = self._args['case_sensitive']
162162
return qb.greater_than_string(self._property_id, value, case_sensitive)
163163
elif isinstance(value, int):
164164
return qb.greater_than_int(self._property_id, value)
@@ -167,8 +167,8 @@ def _apply_gt(self, qb: QueryBuilder) -> obx_qb_cond:
167167

168168
def _apply_gte(self, qb: QueryBuilder) -> obx_qb_cond:
169169
value = self._args['value']
170-
case_sensitive = self._args['case_sensitive']
171170
if isinstance(value, str):
171+
case_sensitive = self._args['case_sensitive']
172172
return qb.greater_or_equal_string(self._property_id, value, case_sensitive)
173173
elif isinstance(value, int):
174174
return qb.greater_or_equal_int(self._property_id, value)
@@ -177,8 +177,8 @@ def _apply_gte(self, qb: QueryBuilder) -> obx_qb_cond:
177177

178178
def _apply_lt(self, qb: QueryBuilder) -> obx_qb_cond:
179179
value = self._args['value']
180-
case_sensitive = self._args['case_sensitive']
181180
if isinstance(value, str):
181+
case_sensitive = self._args['case_sensitive']
182182
return qb.less_than_string(self._property_id, value, case_sensitive)
183183
elif isinstance(value, int):
184184
return qb.less_than_int(self._property_id, value)
@@ -187,8 +187,8 @@ def _apply_lt(self, qb: QueryBuilder) -> obx_qb_cond:
187187

188188
def _apply_lte(self, qb: QueryBuilder) -> obx_qb_cond:
189189
value = self._args['value']
190-
case_sensitive = self._args['case_sensitive']
191190
if isinstance(value, str):
191+
case_sensitive = self._args['case_sensitive']
192192
return qb.less_or_equal_string(self._property_id, value, case_sensitive)
193193
elif isinstance(value, int):
194194
return qb.less_or_equal_int(self._property_id, value)

objectbox/model/properties.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ def _set_flags(self):
184184
self._flags |= self._index.type
185185

186186
def equals(self, value) -> PropertyQueryCondition:
187-
args = {'value': value, 'case_sensitive': False}
187+
args = {'value': value}
188188
return PropertyQueryCondition(self._id, PropertyQueryConditionOp.EQ, args)
189189

190190
def not_equals(self, value) -> PropertyQueryCondition:
191-
args = {'value': value, 'case_sensitive': False}
191+
args = {'value': value}
192192
return PropertyQueryCondition(self._id, PropertyQueryConditionOp.NOT_EQ, args)
193193

194194
# ID property (primary key)
@@ -249,27 +249,27 @@ def __init__(self, py_type : Type, **kwargs):
249249
super(_NumericProperty, self).__init__(py_type, **kwargs)
250250

251251
def equals(self, value) -> PropertyQueryCondition:
252-
args = {'value': value, 'case_sensitive': False}
252+
args = {'value': value}
253253
return PropertyQueryCondition(self._id, PropertyQueryConditionOp.EQ, args)
254254

255255
def not_equals(self, value) -> PropertyQueryCondition:
256-
args = {'value': value, 'case_sensitive': False}
256+
args = {'value': value}
257257
return PropertyQueryCondition(self._id, PropertyQueryConditionOp.NOT_EQ, args)
258258

259259
def greater_than(self, value) -> PropertyQueryCondition:
260-
args = {'value': value, 'case_sensitive': False}
260+
args = {'value': value}
261261
return PropertyQueryCondition(self._id, PropertyQueryConditionOp.GT, args)
262262

263263
def greater_or_equal(self, value) -> PropertyQueryCondition:
264-
args = {'value': value, 'case_sensitive': False}
264+
args = {'value': value}
265265
return PropertyQueryCondition(self._id, PropertyQueryConditionOp.GTE, args)
266266

267267
def less_than(self, value) -> PropertyQueryCondition:
268-
args = {'value': value, 'case_sensitive': False}
268+
args = {'value': value}
269269
return PropertyQueryCondition(self._id, PropertyQueryConditionOp.LT, args)
270270

271271
def less_or_equal(self, value) -> PropertyQueryCondition:
272-
args = {'value': value, 'case_sensitive': False}
272+
args = {'value': value}
273273
return PropertyQueryCondition(self._id, PropertyQueryConditionOp.LTE, args)
274274

275275
def between(self, a, b) -> PropertyQueryCondition:

0 commit comments

Comments
 (0)