MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / _should_exclude

Method _should_exclude

lib/sqlalchemy/orm/mapper.py:3315–3359  ·  view source on GitHub ↗

determine whether a particular property should be implicitly present on the class. This occurs when properties are propagated from an inherited class, or are applied from the columns present in the mapped table.

(self, name, assigned_name, local, column)

Source from the content-addressed store, hash-verified

3313 return [f.name for f in util.dataclass_fields(self.class_)]
3314
3315 def _should_exclude(self, name, assigned_name, local, column):
3316 """determine whether a particular property should be implicitly
3317 present on the class.
3318
3319 This occurs when properties are propagated from an inherited class, or
3320 are applied from the columns present in the mapped table.
3321
3322 """
3323
3324 if column is not None and sql_base._never_select_column(column):
3325 return True
3326
3327 # check for class-bound attributes and/or descriptors,
3328 # either local or from an inherited class
3329 # ignore dataclass field default values
3330 if local:
3331 if self.class_.__dict__.get(
3332 assigned_name, None
3333 ) is not None and self._is_userland_descriptor(
3334 assigned_name, self.class_.__dict__[assigned_name]
3335 ):
3336 return True
3337 else:
3338 attr = self.class_manager._get_class_attr_mro(assigned_name, None)
3339 if attr is not None and self._is_userland_descriptor(
3340 assigned_name, attr
3341 ):
3342 return True
3343
3344 if (
3345 self.include_properties is not None
3346 and name not in self.include_properties
3347 and (column is None or column not in self.include_properties)
3348 ):
3349 self._log("not including property %s" % (name))
3350 return True
3351
3352 if self.exclude_properties is not None and (
3353 name in self.exclude_properties
3354 or (column is not None and column in self.exclude_properties)
3355 ):
3356 self._log("excluding property %s" % (name))
3357 return True
3358
3359 return False
3360
3361 def common_parent(self, other: Mapper[Any]) -> bool:
3362 """Return true if the given mapper shares a

Callers 3

_set_concrete_baseMethod · 0.95
_configure_propertiesMethod · 0.95

Calls 4

_logMethod · 0.95
_get_class_attr_mroMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected