Home / Function/ test_sanitize_for_postgres() — langchain Function Reference

test_sanitize_for_postgres() — langchain Function Reference

Architecture documentation for the test_sanitize_for_postgres() function in test_strings.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  c262266f_452d_8ccc_b50b_df8fffc441a9["test_sanitize_for_postgres()"]
  9be82f42_d737_5877_175a_d8f44b4fa567["test_strings.py"]
  c262266f_452d_8ccc_b50b_df8fffc441a9 -->|defined in| 9be82f42_d737_5877_175a_d8f44b4fa567
  style c262266f_452d_8ccc_b50b_df8fffc441a9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/utils/test_strings.py lines 11–32

def test_sanitize_for_postgres() -> None:
    """Test sanitizing text for PostgreSQL compatibility."""
    # Test with NUL bytes
    text_with_nul = "Hello\x00world\x00test"
    expected = "Helloworldtest"
    assert sanitize_for_postgres(text_with_nul) == expected

    # Test with replacement character
    expected_with_replacement = "Hello world test"
    assert sanitize_for_postgres(text_with_nul, " ") == expected_with_replacement

    # Test with text without NUL bytes
    clean_text = "Hello world"
    assert sanitize_for_postgres(clean_text) == clean_text

    # Test empty string
    assert not sanitize_for_postgres("")

    # Test with multiple consecutive NUL bytes
    text_with_multiple_nuls = "Hello\x00\x00\x00world"
    assert sanitize_for_postgres(text_with_multiple_nuls) == "Helloworld"
    assert sanitize_for_postgres(text_with_multiple_nuls, "-") == "Hello---world"

Domain

Subdomains

Frequently Asked Questions

What does test_sanitize_for_postgres() do?
test_sanitize_for_postgres() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/utils/test_strings.py.
Where is test_sanitize_for_postgres() defined?
test_sanitize_for_postgres() is defined in libs/core/tests/unit_tests/utils/test_strings.py at line 11.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free