Spaces:
Restarting
Restarting
Update main.py
Browse files2358 unmodified lines23592360236123622363236423652366236723682369237023712372237323742375237623772378237923802358 unmodified lines_, org_id, _ = user_dataclient = get_supabase()# Formulate the sub-clauses for the query stringfilter_str = f"description.ilike.%{q}%,item_code.ilike.%{q}%,product_group.ilike.%{q}%"# We pass 'or' as the column target name, 'eq' as the base operator matching condition,# and the parenthesized string as the matching criteria.query = (client.table("inventory").select("*, location_stocks!left(location_id, quantity, reserved_quantity)", count="exact").eq("org_id", org_id).filter("or", "eq", f"({filter_str})"))if location_id is not None:query = query.eq("location_stocks.location_id", location_id)# Apply range parameters and execute smoothlyresult = await run_sync_db_call(query.range(offset, offset + limit - 1).execute)2358 unmodified lines23592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832358 unmodified lines_, org_id, _ = user_dataclient = get_supabase()# Formulate the sub-clauses for the query string cleanlyfilter_str = f"description.ilike.%{q}%,item_code.ilike.%{q}%,product_group.ilike.%{q}%"# 1. Build the base query structurequery = (client.table("inventory").select("*, location_stocks!left(location_id, quantity, reserved_quantity)", count="exact").eq("org_id", org_id))# 2. Force append the raw query parameter directly into the request payload.# This completely eliminates SDK translation errors.query.params["or"] = f"({filter_str})"# 3. Add conditional location constraints if providedif location_id is not None:query = query.eq("location_stocks.location_id", location_id)# Execute pagination range smoothlyresult = await run_sync_db_call(query.range(offset, offset + limit - 1).execute)
main.py+8-5