MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / visit_unary

Method visit_unary

lib/sqlalchemy/sql/compiler.py:3255–3301  ·  view source on GitHub ↗
(
        self, unary, add_to_result_map=None, result_map_targets=(), **kw
    )

Source from the content-addressed store, hash-verified

3253 return getattr(self, attrname, None)
3254
3255 def visit_unary(
3256 self, unary, add_to_result_map=None, result_map_targets=(), **kw
3257 ):
3258 if add_to_result_map is not None:
3259 result_map_targets += (unary,)
3260 kw["add_to_result_map"] = add_to_result_map
3261 kw["result_map_targets"] = result_map_targets
3262
3263 if unary.operator is operators.distinct_op and not kw.get(
3264 "within_aggregate_function", False
3265 ):
3266 util.warn(
3267 "Column-expression-level unary distinct() "
3268 "should not be used outside of an aggregate "
3269 "function. For general 'SELECT DISTINCT' support"
3270 "use select().distinct()."
3271 )
3272
3273 if unary.operator:
3274 if unary.modifier:
3275 raise exc.CompileError(
3276 "Unary expression does not support operator "
3277 "and modifier simultaneously"
3278 )
3279 disp = self._get_operator_dispatch(
3280 unary.operator, "unary", "operator"
3281 )
3282 if disp:
3283 return disp(unary, unary.operator, **kw)
3284 else:
3285 return self._generate_generic_unary_operator(
3286 unary, OPERATORS[unary.operator], **kw
3287 )
3288 elif unary.modifier:
3289 disp = self._get_operator_dispatch(
3290 unary.modifier, "unary", "modifier"
3291 )
3292 if disp:
3293 return disp(unary, unary.modifier, **kw)
3294 else:
3295 return self._generate_generic_unary_modifier(
3296 unary, OPERATORS[unary.modifier], **kw
3297 )
3298 else:
3299 raise exc.CompileError(
3300 "Unary expression has no operator or modifier"
3301 )
3302
3303 def visit_truediv_binary(self, binary, operator, **kw):
3304 if self.dialect.div_is_floordiv:

Callers

nothing calls this directly

Calls 5

getMethod · 0.45
warnMethod · 0.45

Tested by

no test coverage detected