#!/usr/bin/env python3
"""Test script to verify the SQL fix"""
import sys
import os

# Add project root to path
sys.path.insert(0, os.path.abspath('.'))

from lawrisk.services.licensing_repo import filter_permits_advanced

try:
    print("Testing filter_permits_advanced function...")
    result = filter_permits_advanced(
        region_id=None,
        theme_id=None,
        department_id=None,
        search_text=None,
        limit=5,
        offset=0
    )
    print(f"Success! Found {len(result.get('permits', []))} permits")
    print(f"Total: {result.get('pagination', {}).get('total', 0)}")
    for permit in result.get('permits', [])[:3]:
        print(f"  - {permit['name']}")
except Exception as e:
    print(f"Error: {e}")
    import traceback
    traceback.print_exc()
