Skip to content

[langchain-db2] Changed behavior when searching for an empty table after updating ibm-db to version 3.2.7. #110

@Mateusz-Switala

Description

@Mateusz-Switala

After updating ibm-db to version 3.2.7, the behavior of DB2VS.similarity_search changed from returning an empty list to raising an error.

Examples

ibm-db==3.2.7

from langchain_db2 import DB2VS

db2_vs = DB2VS(
    table_name='empty_table',
    connection_args=db2_connection_args,
    embedding_function=embedding_func
    )

db2_vs.similarity_search("text")

# Output

2025-09-08 11:03:25,144 - ERROR - An unexpected error occurred: 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/Users/.../lib/python3.11/site-packages/langchain_db2/db2vs.py", line 57, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../lib/python3.11/site-packages/langchain_db2/db2vs.py", line 480, in similarity_search_by_vector_with_relevance_scores
    for result in results:
TypeError: 'NoneType' object is not iterable

ibm-db==3.2.6

from langchain_db2 import DB2VS

db2_vs = DB2VS(
    table_name='empty_table',
    connection_args=db2_connection_args,
    embedding_function=embedding_func
    )

db2_vs.similarity_search("text")

# []

@yiweiHeOSS Could you take a look at this?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions