Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Unable to resolve column 'flight_id' #2952

Closed
hdsuperman opened this issue Jan 8, 2025 · 1 comment · Fixed by #2956
Closed

DOC: Unable to resolve column 'flight_id' #2952

hdsuperman opened this issue Jan 8, 2025 · 1 comment · Fixed by #2956

Comments

@hdsuperman
Copy link

hdsuperman commented Jan 8, 2025

Issue with current documentation:

example code:

" \"SELECT flight_id FROM tickets WHERE ticket_no = ? AND passenger_id = ?\",\n",

@tool
def cancel_ticket(ticket_no: str, *, config: RunnableConfig) -> str:
    """Cancel the user's ticket and remove it from the database."""
    configuration = config.get("configurable", {})
    passenger_id = configuration.get("passenger_id", None)
    if not passenger_id:
        raise ValueError("No passenger ID configured.")
    conn = sqlite3.connect(db)
    cursor = conn.cursor()

    cursor.execute(
        "SELECT flight_id FROM ticket_flights WHERE ticket_no = ?", (ticket_no,)
    )
    existing_ticket = cursor.fetchone()
    if not existing_ticket:
        cursor.close()
        conn.close()
        return "No existing ticket found for the given ticket number."

    # Check the signed-in user actually has this ticket
    cursor.execute(
        "SELECT flight_id FROM tickets WHERE ticket_no = ? AND passenger_id = ?",
        (ticket_no, passenger_id),
    )
    current_ticket = cursor.fetchone()
    if not current_ticket:
        cursor.close()
        conn.close()
        return f"Current signed-in passenger with ID {passenger_id} not the owner of ticket {ticket_no}"

    cursor.execute("DELETE FROM ticket_flights WHERE ticket_no = ?", (ticket_no,))
    conn.commit()

    cursor.close()
    conn.close()
    return "Ticket successfully cancelled."

'flight_id' do not exist in table 'tickets'

fix:

 "SELECT flight_id FROM tickets WHERE ticket_no = ? AND passenger_id = ?"

 change to:

 "SELECT * FROM tickets WHERE ticket_no = ? AND passenger_id = ?"

Idea or request for content:

No response

@vbarda
Copy link
Collaborator

vbarda commented Jan 8, 2025

Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants