SQLDatabase drop the column names in the result. (#15361)

Fix for the following bug:
https://github.com/langchain-ai/langchain/issues/15360

---------

Co-authored-by: dudu butbul <100126964+dudu-upstream@users.noreply.github.com>
This commit is contained in:
dudub12
2024-01-03 01:29:25 +02:00
committed by GitHub
parent 07d294b5ec
commit 7e6b0056b8
2 changed files with 21 additions and 7 deletions

View File

@@ -120,10 +120,16 @@ def test_sql_database_run() -> None:
conn.execute(stmt)
db = SQLDatabase(engine)
command = "select user_id, user_name, user_bio from user where user_id = 13"
output = db.run(command)
partial_output = db.run(command)
user_bio = "That is my Bio " * 19 + "That is my..."
expected_output = f"[(13, 'Harrison', '{user_bio}')]"
assert output == expected_output
expected_partial_output = f"[(13, 'Harrison', '{user_bio}')]"
assert partial_output == expected_partial_output
full_output = db.run(command, include_columns=True)
expected_full_output = (
"[{'user_id': 13, 'user_name': 'Harrison', 'user_bio': '%s'}]" % user_bio
)
assert full_output == expected_full_output
def test_sql_database_run_update() -> None: