aiteamutils 0.2.131__tar.gz → 0.2.133__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiteamutils
3
- Version: 0.2.131
3
+ Version: 0.2.133
4
4
  Summary: AI Team Utilities
5
5
  Project-URL: Homepage, https://github.com/yourusername/aiteamutils
6
6
  Project-URL: Issues, https://github.com/yourusername/aiteamutils/issues
@@ -7,7 +7,8 @@ from typing import (
7
7
  Dict,
8
8
  List,
9
9
  Optional,
10
- AsyncGenerator
10
+ AsyncGenerator,
11
+ Union
11
12
  )
12
13
  from sqlalchemy.ext.asyncio import AsyncSession
13
14
  from sqlalchemy import select, and_, or_
@@ -151,12 +152,8 @@ def process_response(
151
152
  if not entity:
152
153
  return None
153
154
 
154
- print(f"\n[DEBUG] Processing entity: {entity.__class__.__name__}")
155
- print(f"[DEBUG] Entity dict: {entity.__dict__}")
156
-
157
155
  # 모든 필드 처리
158
156
  result = process_columns(entity)
159
- print(f"[DEBUG] After process_columns: {result}")
160
157
 
161
158
  # Relationship 처리 (이미 로드된 관계만 처리)
162
159
  for relationship in entity.__mapper__.relationships:
@@ -175,6 +172,12 @@ def process_response(
175
172
  field_info = response_model.model_fields[relationship.key]
176
173
  nested_response_model = field_info.annotation
177
174
  print(f"[DEBUG] Found nested response model for {relationship.key}: {nested_response_model}")
175
+
176
+ # Optional[ProjectResponse] 같은 경우 실제 모델 추출
177
+ if hasattr(nested_response_model, '__origin__') and nested_response_model.__origin__ is Union:
178
+ print(f"[DEBUG] Extracting actual model from Union type: {nested_response_model.__args__}")
179
+ nested_response_model = next((t for t in nested_response_model.__args__ if hasattr(t, 'model_fields')), None)
180
+ print(f"[DEBUG] Extracted model: {nested_response_model}")
178
181
 
179
182
  if value is not None:
180
183
  if isinstance(value, list):
@@ -183,18 +186,19 @@ def process_response(
183
186
  for item in value
184
187
  ]
185
188
  else:
189
+ print(f"[DEBUG] Processing single value with model: {nested_response_model}")
186
190
  result[relationship.key] = process_response(value, nested_response_model)
191
+ print(f"[DEBUG] After processing relationship {relationship.key}: {result[relationship.key]}")
187
192
  else:
188
193
  result[relationship.key] = None
189
- print(f"[DEBUG] After processing relationship {relationship.key}: {result[relationship.key]}")
190
194
  except Exception as e:
191
195
  print(f"[DEBUG] Error processing relationship {relationship.key}: {str(e)}")
196
+ import traceback
197
+ print(f"[DEBUG] Full traceback: {traceback.format_exc()}")
192
198
  result[relationship.key] = None
193
199
 
194
- print(f"\n[DEBUG] Before response model processing: {result}")
195
200
  # response_model이 있는 경우 필터링
196
201
  if response_model:
197
- print(f"[DEBUG] Response model fields: {response_model.model_fields}")
198
202
  # 현재 키 목록을 저장
199
203
  current_keys = list(result.keys())
200
204
  # response_model에 없는 키 제거
@@ -203,11 +207,12 @@ def process_response(
203
207
  print(f"[DEBUG] Removing key not in response model: {key}")
204
208
  result.pop(key)
205
209
  # 모델 검증 및 업데이트
206
- validated_result = response_model(**result).model_dump()
207
- print(f"[DEBUG] After validation: {validated_result}")
208
- result.update(validated_result)
209
-
210
- print(f"[DEBUG] Final result: {result}")
210
+ try:
211
+ validated_result = response_model(**result).model_dump()
212
+ result.update(validated_result)
213
+ except Exception as e:
214
+ import traceback
215
+
211
216
  return result
212
217
 
213
218
  ##################
@@ -465,17 +470,13 @@ async def list_entities(
465
470
  List[Dict[str, Any]]: 쿼리 결과 리스트.
466
471
  """
467
472
  try:
468
- query = select(model)
469
-
470
- # 명시적 조인 적용
473
+ # 기본 쿼리 생성
471
474
  if explicit_joins:
475
+ query = select(model, *explicit_joins)
472
476
  for join_target in explicit_joins:
473
477
  query = query.outerjoin(join_target)
474
-
475
- # 조인 로딩 적용
476
- if loading_joins:
477
- for join_option in loading_joins:
478
- query = query.options(join_option)
478
+ else:
479
+ query = select(model)
479
480
 
480
481
  # 필터 조건 적용
481
482
  if filters:
@@ -0,0 +1,2 @@
1
+ """버전 정보"""
2
+ __version__ = "0.2.133"
@@ -1,2 +0,0 @@
1
- """버전 정보"""
2
- __version__ = "0.2.131"
File without changes
File without changes
File without changes