fix/filtros-leyendas
This commit is contained in:
@@ -13,6 +13,7 @@ router = TenantCRUDRoutes(
|
||||
tags=["a76.general_catalogs.legends"],
|
||||
resource_name="Legend",
|
||||
enable_list=True,
|
||||
enable_filters=True,
|
||||
list_permissions=["cat_legends.view"],
|
||||
get_permissions=["cat_legends.view"],
|
||||
create_permissions=["cat_legends.create"],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from typing import List, Optional, Tuple, Dict, Any
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import cast, String, select
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from fastapi import HTTPException
|
||||
import logging
|
||||
@@ -28,7 +28,11 @@ class LegendService:
|
||||
|
||||
if filters:
|
||||
if filters.get("code"):
|
||||
query = query.filter(Legend.code.ilike(f"%{filters['code']}%"))
|
||||
code_str = str(filters["code"]).strip()
|
||||
if code_str:
|
||||
query = query.filter(
|
||||
cast(Legend.code, String).ilike(f"%{code_str}%")
|
||||
)
|
||||
if filters.get("description"):
|
||||
query = query.filter(
|
||||
Legend.description.ilike(f"%{filters['description']}%")
|
||||
|
||||
Reference in New Issue
Block a user