MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _should_exclude

Method _should_exclude

lib/sqlalchemy/orm/mapper.py:3273–3317  ·  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

3271 return [f.name for f in util.dataclass_fields(self.class_)]
3272
3273 def _should_exclude(self, name, assigned_name, local, column):
3274 """determine whether a particular property should be implicitly
3275 present on the class.
3276
3277 This occurs when properties are propagated from an inherited class, or
3278 are applied from the columns present in the mapped table.
3279
3280 """
3281
3282 if column is not None and sql_base._never_select_column(column):
3283 return True
3284
3285 # check for class-bound attributes and/or descriptors,
3286 # either local or from an inherited class
3287 # ignore dataclass field default values
3288 if local:
3289 if self.class_.__dict__.get(
3290 assigned_name, None
3291 ) is not None and self._is_userland_descriptor(
3292 assigned_name, self.class_.__dict__[assigned_name]
3293 ):
3294 return True
3295 else:
3296 attr = self.class_manager._get_class_attr_mro(assigned_name, None)
3297 if attr is not None and self._is_userland_descriptor(
3298 assigned_name, attr
3299 ):
3300 return True
3301
3302 if (
3303 self.include_properties is not None
3304 and name not in self.include_properties
3305 and (column is None or column not in self.include_properties)
3306 ):
3307 self._log("not including property %s" % (name))
3308 return True
3309
3310 if self.exclude_properties is not None and (
3311 name in self.exclude_properties
3312 or (column is not None and column in self.exclude_properties)
3313 ):
3314 self._log("excluding property %s" % (name))
3315 return True
3316
3317 return False
3318
3319 def common_parent(self, other: Mapper[Any]) -> bool:
3320 """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