aiteamutils 0.2.129__py3-none-any.whl → 0.2.131__py3-none-any.whl

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.
aiteamutils/database.py CHANGED
@@ -11,7 +11,7 @@ from typing import (
11
11
  )
12
12
  from sqlalchemy.ext.asyncio import AsyncSession
13
13
  from sqlalchemy import select, and_, or_
14
- from sqlalchemy.orm import DeclarativeBase, joinedload, selectinload
14
+ from sqlalchemy.orm import DeclarativeBase, joinedload, selectinload, contains_eager
15
15
  from sqlalchemy.exc import SQLAlchemyError
16
16
  from datetime import datetime
17
17
  from contextlib import asynccontextmanager
@@ -151,21 +151,30 @@ def process_response(
151
151
  if not entity:
152
152
  return None
153
153
 
154
+ print(f"\n[DEBUG] Processing entity: {entity.__class__.__name__}")
155
+ print(f"[DEBUG] Entity dict: {entity.__dict__}")
156
+
154
157
  # 모든 필드 처리
155
158
  result = process_columns(entity)
159
+ print(f"[DEBUG] After process_columns: {result}")
156
160
 
157
161
  # Relationship 처리 (이미 로드된 관계만 처리)
158
162
  for relationship in entity.__mapper__.relationships:
163
+ print(f"\n[DEBUG] Processing relationship: {relationship.key}")
159
164
  if not relationship.key in entity.__dict__:
165
+ print(f"[DEBUG] Relationship {relationship.key} not in entity.__dict__")
160
166
  continue
161
167
 
162
168
  try:
163
169
  value = getattr(entity, relationship.key)
170
+ print(f"[DEBUG] Relationship value: {value}")
171
+
164
172
  # response_model이 있는 경우 해당 필드의 annotation type을 가져옴
165
173
  nested_response_model = None
166
174
  if response_model and relationship.key in response_model.model_fields:
167
175
  field_info = response_model.model_fields[relationship.key]
168
176
  nested_response_model = field_info.annotation
177
+ print(f"[DEBUG] Found nested response model for {relationship.key}: {nested_response_model}")
169
178
 
170
179
  if value is not None:
171
180
  if isinstance(value, list):
@@ -177,20 +186,28 @@ def process_response(
177
186
  result[relationship.key] = process_response(value, nested_response_model)
178
187
  else:
179
188
  result[relationship.key] = None
180
- except Exception:
189
+ print(f"[DEBUG] After processing relationship {relationship.key}: {result[relationship.key]}")
190
+ except Exception as e:
191
+ print(f"[DEBUG] Error processing relationship {relationship.key}: {str(e)}")
181
192
  result[relationship.key] = None
182
193
 
194
+ print(f"\n[DEBUG] Before response model processing: {result}")
183
195
  # response_model이 있는 경우 필터링
184
196
  if response_model:
197
+ print(f"[DEBUG] Response model fields: {response_model.model_fields}")
185
198
  # 현재 키 목록을 저장
186
199
  current_keys = list(result.keys())
187
200
  # response_model에 없는 키 제거
188
201
  for key in current_keys:
189
202
  if key not in response_model.model_fields:
203
+ print(f"[DEBUG] Removing key not in response model: {key}")
190
204
  result.pop(key)
191
205
  # 모델 검증 및 업데이트
192
- result.update(response_model(**result).model_dump())
206
+ validated_result = response_model(**result).model_dump()
207
+ print(f"[DEBUG] After validation: {validated_result}")
208
+ result.update(validated_result)
193
209
 
210
+ print(f"[DEBUG] Final result: {result}")
194
211
  return result
195
212
 
196
213
  ##################
@@ -448,17 +465,17 @@ async def list_entities(
448
465
  List[Dict[str, Any]]: 쿼리 결과 리스트.
449
466
  """
450
467
  try:
451
- # 명시적 조인이 있는 경우
468
+ query = select(model)
469
+
470
+ # 명시적 조인 적용
452
471
  if explicit_joins:
453
- query = select(model, *explicit_joins)
454
472
  for join_target in explicit_joins:
455
473
  query = query.outerjoin(join_target)
456
- # 명시적 조인이 없는 경우
457
- else:
458
- query = select(model)
459
- if loading_joins:
460
- for join_option in loading_joins:
461
- query = query.options(join_option)
474
+
475
+ # 조인 로딩 적용
476
+ if loading_joins:
477
+ for join_option in loading_joins:
478
+ query = query.options(join_option)
462
479
 
463
480
  # 필터 조건 적용
464
481
  if filters:
@@ -485,8 +502,7 @@ async def list_entities(
485
502
  query = query.limit(limit).offset(skip)
486
503
 
487
504
  result = await session.execute(query)
488
-
489
- return result.scalars().unique().all()
505
+ return result.unique().scalars().all()
490
506
  except SQLAlchemyError as e:
491
507
  raise CustomException(
492
508
  ErrorCode.DB_READ_ERROR,
@@ -503,17 +519,17 @@ async def get_entity(
503
519
  loading_joins: Optional[List[Any]] = None
504
520
  ) -> ModelType:
505
521
  try:
506
- # 명시적 조인이 있는 경우
522
+ query = select(model)
523
+
524
+ # 명시적 조인 적용
507
525
  if explicit_joins:
508
- query = select(model, *explicit_joins)
509
526
  for join_target in explicit_joins:
510
527
  query = query.outerjoin(join_target)
511
- # 명시적 조인이 없는 경우
512
- else:
513
- query = select(model)
514
- if loading_joins:
515
- for join_option in loading_joins:
516
- query = query.options(join_option)
528
+
529
+ # 조인 로딩 적용
530
+ if loading_joins:
531
+ for join_option in loading_joins:
532
+ query = query.options(join_option)
517
533
 
518
534
  if conditions:
519
535
  for key, value in conditions.items():
aiteamutils/version.py CHANGED
@@ -1,2 +1,2 @@
1
1
  """버전 정보"""
2
- __version__ = "0.2.129"
2
+ __version__ = "0.2.131"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiteamutils
3
- Version: 0.2.129
3
+ Version: 0.2.131
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
@@ -4,12 +4,12 @@ aiteamutils/base_repository.py,sha256=vzBw3g3jCJetTDblZvZenEGXk89Qu_65_02C7QTcf8
4
4
  aiteamutils/base_service.py,sha256=nHikjwGp29QrQPr2W8Ye9sKxmVS_8prRG3Nu42TU1Ms,10670
5
5
  aiteamutils/cache.py,sha256=07xBGlgAwOTAdY5mnMOQJ5EBxVwe8glVD7DkGEkxCtw,1373
6
6
  aiteamutils/config.py,sha256=YdalpJb70-txhGJAS4aaKglEZAFVWgfzw5BXSWpkUz4,3232
7
- aiteamutils/database.py,sha256=9E5vFC22qeAhU-M4bfzNO53rg43y3CSAsSqrwHmEOHI,20175
7
+ aiteamutils/database.py,sha256=uurxHBsAPM0LgPNsolN6jyvSAog0bA5OjdzoRxT8qaI,21070
8
8
  aiteamutils/enums.py,sha256=7WLqlcJqQWtETAga2WAxNp3dJTQIAd2TW-4WzkoHHa8,2498
9
9
  aiteamutils/exceptions.py,sha256=pgf3ersezObyl17wAO3I2fb8m9t2OzWDX1mSjwAWm2Y,16035
10
10
  aiteamutils/security.py,sha256=McUl3t5Z5SyUDVUHymHdDkYyF4YSeg4g9fFMML4W6Kw,11630
11
11
  aiteamutils/validators.py,sha256=msOrha36xWsapm4VAh63YmFq1GVyC9tzZcjXYFCEZ_g,11949
12
- aiteamutils/version.py,sha256=d_-Dlw9uKxvmVtrtYblYVCPX-bJvQt2CYRY9_LVZUJE,43
13
- aiteamutils-0.2.129.dist-info/METADATA,sha256=VXFPjrbhCzEIQw3ZGSkV4VrsqTAfoH-02cfYsgCx3sI,1719
14
- aiteamutils-0.2.129.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
- aiteamutils-0.2.129.dist-info/RECORD,,
12
+ aiteamutils/version.py,sha256=C-W4DcR9CDTfhqYUftv2T9XZS_FvRrzHTFjRmRf5eko,43
13
+ aiteamutils-0.2.131.dist-info/METADATA,sha256=QferQh8AsHLp7sUc5rNKSzWwQl7r5R-5eMvdg-Weg-U,1719
14
+ aiteamutils-0.2.131.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
+ aiteamutils-0.2.131.dist-info/RECORD,,