I have a problem using a function stored in sql server within an annotate in a django query (Django 3.2.7).
This is the function call in django:
def informacion_proveedor(codigo_integracion):
params = [codigo_integracion]
with connections['default'].cursor() as cursor:
query = "SELECT dbo.ufn_InformacionProveedor(%s)"
result = cursor.execute(query, params)
return result.fetchone()[0]
This is the query (It is in a file set as maganer of the model ):
def reporte_orden_compra(self, id_comprador, lista_proveedores):
query = self.filter(IdProveedor__in=lista_proveedores, activo=1)\
.annotate( plan_tarifario=informacion_proveedor(codigo_integracion=F('IdProveedor__CodigoIntegracion')))
and I get this error
('Invalid parameter type. param-index=0 param-type=F', 'HY105')
however, I can execute it correctly when I pass it a normal string.