john-bodley commented on code in PR #24467:
URL: https://github.com/apache/superset/pull/24467#discussion_r1264335099
##########
superset/daos/base.py:
##########
@@ -127,57 +128,72 @@ def find_one_or_none(cls, **filter_by: Any) ->
Optional[T]:
return query.filter_by(**filter_by).one_or_none()
@classmethod
- def create(cls, properties: dict[str, Any], commit: bool = True) -> T:
- """
- Generic for creating models
- :raises: DAOCreateFailedError
+ def create(
+ cls,
+ item: T | None = None,
Review Comment:
@michael-s-molina that's an interesting idea. I was likely just trying to
replicate the same behavior as the `update` method which needs to have
either/or both the item and attributes—well technically you're just updating an
existing item, but it seems cleaner (from a DRY perspective) to have the base
`update` method perform said logic.
##########
superset/daos/base.py:
##########
@@ -127,57 +128,72 @@ def find_one_or_none(cls, **filter_by: Any) ->
Optional[T]:
return query.filter_by(**filter_by).one_or_none()
@classmethod
- def create(cls, properties: dict[str, Any], commit: bool = True) -> T:
- """
- Generic for creating models
- :raises: DAOCreateFailedError
+ def create(
+ cls,
+ item: T | None = None,
Review Comment:
@michael-s-molina that's an interesting idea. I was likely just trying to
replicate the same behavior as the `update` method which needs to have
either/or both the item and attributes—well technically you're just updating an
existing item, but it seems cleaner (from a DRY perspective) to have the base
`update` method perform said logic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]