Skip to content

Commit

Permalink
Commiting cleaned up comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Knucklessg1 committed Aug 9, 2024
1 parent 7b06051 commit 3848de8
Showing 1 changed file with 0 additions and 52 deletions.
52 changes: 0 additions & 52 deletions gitlab_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,55 +299,3 @@ def create_table(db_instance, engine):
print(f"Table {table_name} created.")
else:
print(f"Table {table_name} already exists.")


# def remove_none_values(d: dict) -> dict:
# return {k: v for k, v in d.items() if v is not None}
#
# def get_related_model(sqlalchemy_model, key):
# mapper = class_mapper(sqlalchemy_model)
# for prop in mapper.iterate_properties:
# if prop.key == key:
# print(f"\n\nRelated Model: {prop.mapper.class_} for key: {key}")
# return prop.mapper.class_
# raise ValueError(f"Unable to find related model for key: {key}")
#
# def validate_value(key, value, session, sqlalchemy_model):
# if isinstance(value, list):
# print(f"\n\nInstance is a list: {value}")
# return [pydantic_to_sqlalchemy(item, session) if hasattr(item, "Meta") and hasattr(item.Meta, "orm_model") else item for item in value]
# elif isinstance(value, dict):
# print(f"\n\nInstance is a dict: {value}")
# related_model = get_related_model(sqlalchemy_model, key)
# nested_model = related_model(**remove_none_values(value))
# return pydantic_to_sqlalchemy(nested_model, session)
# else:
# print(f"\n\nInstance is a value: {value}")
# return value
#
# def pydantic_to_sqlalchemy(pydantic_model, session):
# if not hasattr(pydantic_model, "Meta") or not hasattr(pydantic_model.Meta, "orm_model"):
# return pydantic_model
#
# sqlalchemy_model = pydantic_model.Meta.orm_model
# model_instance = sqlalchemy_model()
#
# for key, value in pydantic_model.model_dump(exclude_unset=True).items():
# if value is not None:
# new_value = validate_value(key, value, session, sqlalchemy_model)
# setattr(model_instance, key, new_value)
#
# session.add(model_instance)
# session.flush() # Ensure any new IDs are generated before returning
# return model_instance
#
#
# def create_table(db_instance, engine):
# inspector = reflection.Inspector.from_engine(engine)
# table_name = db_instance.__table__.name
#
# if not inspector.has_table(table_name):
# db_instance.__table__.create(engine)
# print(f"Table {table_name} created.")
# else:
# print(f"Table {table_name} already exists.")

0 comments on commit 3848de8

Please sign in to comment.