sql-cli 1.69.1

SQL query tool for CSV/JSON with both interactive TUI and non-interactive CLI modes - perfect for exploration and automation
Documentation
�

�R�h�,���dZddlZddlmcmZddlZddlZddl	m
Z
ddlmZddl
ZGd�d�Zedk(rej"edg�yy)	z,
Comprehensive tests for SQL string methods
�N)�Path)�StringIOc���eZdZdZed��Zdedefd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z y) �TestStringMethodsz8Comprehensive test suite for string method functionalityc�*�tt�jj|_t	|jdzdzdz�|_t|j
�j
�s%tjgd�|jd��yy)zSetup test environment�target�releasezsql-cli)�cargo�buildz	--releaseT)�cwd�checkN)	r�__file__�parent�project_root�str�sql_cli�exists�
subprocess�run)�clss �?/home/me/dev/sql-cli/tests/test_string_methods_comprehensive.py�setup_classzTestStringMethods.setup_classss�� ��>�0�0�7�7����#�*�*�X�5�	�A�I�M�N����C�K�K� �'�'�)��N�N�:�!�.�.�d�
<�*��csv_file�queryc��|jt|jdz|z�d|ddg}tj|ddd��}|j
dk7rd	|jfS|jj�r8tjt|jj���d	fStj�d	fS)
zHelper to run a SQL query�dataz-qz-o�csvT�)�capture_output�text�timeoutrN)
rrrrr�
returncode�stderr�stdout�strip�pd�read_csvr�	DataFrame)�selfrr�cmd�results     r�	run_queryzTestStringMethods.run_querys���
�L�L���!�!�F�*�X�5�6��%��%�	
������D�t�Q�O������!�����&�&��=�=��� ��;�;�x��
�
�(;�(;�(=�>�?��E�E��|�|�~�t�#�#rc���|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}||dd
k(djd}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	||ddk(djd}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	||ddk(djd}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	y)z/Test Trim() removes leading and trailing spaces�test_simple_strings.csvzPSELECT id, name.Trim() as trimmed FROM test_simple_strings WHERE id IN (4, 7, 8)���==�z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)s�len�df��py0�py1�py3�py6�assert %(py8)s�py8N�id��trimmedr�David�z%(py1)s == %(py4)s�r8�py4�assert %(py6)sr:��Grace��Henry�r-r4�
@pytest_ar�_call_reprcompare�@py_builtins�locals�_should_repr_global_name�	_saferepr�AssertionError�_format_explanation�iloc�r*r5�_�@py_assert2�@py_assert5�@py_assert4�@py_format7�@py_format9�@py_assert0�@py_assert3�@py_format5s           r�test_trim_removes_both_spacesz/TestStringMethods.test_trim_removes_both_spaces-s������8�q�s���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������"�T�(�a�-� ��+�0�0��3�>�w�>�3�w�>�>�>�>�3�w�>�>�>�3�>�>�>�w�>�>�>�>�>�>�>��"�T�(�a�-� ��+�0�0��3�>�w�>�3�w�>�>�>�>�3�w�>�>�>�3�>�>�>�w�>�>�>�>�>�>�>��"�T�(�a�-� ��+�0�0��3�>�w�>�3�w�>�>�>�>�3�w�>�>�>�3�>�>�>�w�>�>�>�>�>�>�>rc�h�|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|jdd
}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	y)z,Test TrimStart() removes only leading spacesr/zLSELECT id, name.TrimStart() as trimmed FROM test_simple_strings WHERE id = 7�r1r3r4r5r6r;r<Nrr?rFrArBrDr:rIrSs           r�%test_trimstart_removes_leading_spacesz7TestStringMethods.test_trimstart_removes_leading_spaces6s�����8�m�o���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������w�w�q�z�)�$�/��/�$��/�/�/�/�$��/�/�/�$�/�/�/��/�/�/�/�/�/�/rc�h�|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|jdd
}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	y)z+Test TrimEnd() removes only trailing spacesr/zJSELECT id, name.TrimEnd() as trimmed FROM test_simple_strings WHERE id = 8r_r1r3r4r5r6r;r<Nrr?rHrArBrDr:rIrSs           r�$test_trimend_removes_trailing_spacesz6TestStringMethods.test_trimend_removes_trailing_spaces=s�����8�k�m���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������w�w�q�z�)�$�/��/�$��/�/�/�/�$��/�/�/�$�/�/�/��/�/�/�/�/�/�/rc��|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}||dd
k(djd}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	||ddk(djd}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	y)z4Test Length() counts all characters including spacesr/zQSELECT id, name, name.Length() as len FROM test_simple_strings WHERE id IN (1, 4)�r1r3r4r5r6r;r<Nr=r_rrrArBrDr:r>�	rIrSs           r�test_length_counts_charactersz/TestStringMethods.test_length_counts_charactersEsz�����8�r�t���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������"�T�(�a�-� ��'�,�,�Q�/�4�1�4�/�1�4�4�4�4�/�1�4�4�4�/�4�4�4�1�4�4�4�4�4�4�4��"�T�(�a�-� ��'�,�,�Q�/�4�1�4�/�1�4�4�4�4�/�1�4�4�4�/�4�4�4�1�4�4�4�4�4�4�4rc	��|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|d}|j}	|	�}t|�}
hd
�}|
|k(}|s�tjd|fd|
|f�dt	j
�vstjt�rtjt�ndtj|�tj|	�tj|�tj|
�tj|�d�z}
dd|
iz}ttj|���dx}x}	x}x}
x}}y)z)Test Length() can be used in WHERE clauser/z@SELECT id, name FROM test_simple_strings WHERE name.Length() > 6r>r1r3r4r5r6r;r<Nr=>r0r>rErG�zd%(py8)s
{%(py8)s = %(py0)s(%(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s.tolist
}()
})
} == %(py11)s�set�r7�py2rCr:r<�py11�assert %(py13)s�py13�r-r4rJrKrLrMrNrOrPrQ�tolistri�r*r5rTrUrVrWrXrY�@py_assert1r[�@py_assert7�@py_assert10�@py_assert9�@py_format12�@py_format14s               r�test_length_in_wherez&TestStringMethods.test_length_in_whereMsW�����8�a�c���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������d�8�5�8�?�?�5�?�$�5�s�$�%�5��5�%��5�5�5�5�%��5�5�5�5�5�5�s�5�5�5�s�5�5�5�8�5�5�5�?�5�5�5�$�5�5�5�%�5�5�5��5�5�5�5�5�5�5�5rc�h�|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|jdd
}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	y)z*Test IndexOf() finds position of substringr/zTSELECT id, email, email.IndexOf('@') as at_pos FROM test_simple_strings WHERE id = 1r_r1r3r4r5r6r;r<Nr�at_posrrArBrDr:rIrSs           r�test_indexof_finds_substringz.TestStringMethods.test_indexof_finds_substringUs�����8�u�w���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������w�w�q�z�(�#�(�q�(�#�q�(�(�(�(�#�q�(�(�(�#�(�(�(�q�(�(�(�(�(�(�(rc�r�|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|jdd
}d}	|	}||k(}|sltjd|fd||f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}x}	}y)z2Test IndexOf() returns -1 when substring not foundr/zOSELECT id, name, name.IndexOf('x') as pos FROM test_simple_strings WHERE id = 1r_r1r3r4r5r6r;r<Nr�pos)z%(py1)s == -%(py4)srBzassert %(py7)s�py7rI)r*r5rTrUrVrWrXrYrZr[�@py_format6�@py_format8s            r�test_indexof_returns_minus_onez0TestStringMethods.test_indexof_returns_minus_one\s�����8�p�r���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������w�w�q�z�%� �&�Q�&�Q�B�&� �B�&�&�&�&� �B�&�&�&� �&�&�&�Q�&�&�&�&�&�&�&rc�h�|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|jdd
}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	y)z0Test IndexOf() in WHERE clause to filter resultsr/zCSELECT id FROM test_simple_strings WHERE email.IndexOf('gmail') > 0r_r1r3r4r5r6r;r<Nrr=rrArBrDr:rIrSs           r�test_indexof_in_wherez'TestStringMethods.test_indexof_in_wherecs�����8�d�f���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������w�w�q�z�$��$�1�$��1�$�$�$�$��1�$�$�$��$�$�$�1�$�$�$�$�$�$�$rc	��|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|d}|j}	|	�}t|�}
hd
�}|
|k(}|s�tjd|fd|
|f�dt	j
�vstjt�rtjt�ndtj|�tj|	�tj|�tj|
�tj|�d�z}
dd|
iz}ttj|���dx}x}	x}x}
x}}y)z-Test Contains() checks for substring presencer/zBSELECT id FROM test_simple_strings WHERE email.Contains('example')r>r1r3r4r5r6r;r<Nr=>r_r>rE�
rhrirjrmrnrorqs               r�test_contains_finds_substringz/TestStringMethods.test_contains_finds_substringksW�����8�c�e���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������d�8�6�8�?�?�6�?�$�6�s�$�%�6��6�%��6�6�6�6�%��6�6�6�6�6�6�s�6�6�6�s�6�6�6�8�6�6�6�?�6�6�6�$�6�6�6�%�6�6�6��6�6�6�6�6�6�6�6rc	��|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|d}|j}	|	�}t|�}
hd
�}|
|k(}|s�tjd|fd|
|f�dt	j
�vstjt�rtjt�ndtj|�tj|	�tj|�tj|
�tj|�d�z}
dd|
iz}ttj|���dx}x}	x}x}
x}}y)z>Test Contains() - appears to be case-insensitive based on logsr/zBSELECT id FROM test_simple_strings WHERE status.Contains('active')rEr1r3r4r5r6r;r<Nr=>r_rdr0rrErGrerhrirjrmrnrorqs               r�test_contains_case_sensitivez.TestStringMethods.test_contains_case_sensitivers]�����8�c�e���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������d�8�>�8�?�?�>�?�$�>�s�$�%�>�)>�>�%�)>�>�>�>�>�%�)>�>�>�>�>�>�>�s�>�>�>�s�>�>�>�8�>�>�>�?�>�>�>�$�>�>�>�%�>�>�>�)>�>�>�>�>�>�>�>�>rc�h�|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|jdd
}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	y)z&Test StartsWith() checks string prefixr/z?SELECT id FROM test_simple_strings WHERE code.StartsWith('ABC')r_r1r3r4r5r6r;r<Nrr=rArBrDr:rIrSs           r�test_startswith_prefix_checkz.TestStringMethods.test_startswith_prefix_check{s�����8�`�b���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������w�w�q�z�$��$�1�$��1�$�$�$�$��1�$�$�$��$�$�$�1�$�$�$�$�$�$�$rc	��|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|d}|j}	|	�}t|�}
hd
�}|
|k(}|s�tjd|fd|
|f�dt	j
�vstjt�rtjt�ndtj|�tj|	�tj|�tj|
�tj|�d�z}
dd|
iz}ttj|���dx}x}	x}x}
x}}y)z2Test StartsWith() - appears to be case-insensitiver/z?SELECT id FROM test_simple_strings WHERE status.StartsWith('a')�r1r3r4r5r6r;r<Nr=>r_r0rr�rErerhrirjrmrnrorqs               r�test_startswith_case_sensitivez0TestStringMethods.test_startswith_case_sensitive�s]�����8�`�b���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������d�8�;�8�?�?�;�?�$�;�s�$�%�;�);�;�%�);�;�;�;�;�%�);�;�;�;�;�;�;�s�;�;�;�s�;�;�;�8�;�;�;�?�;�;�;�$�;�;�;�%�;�;�;�);�;�;�;�;�;�;�;�;rc	��|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|d}|j}	|	�}t|�}
dd
h}|
|k(}|s�tjd|fd|
|f�dt	j
�vstjt�rtjt�ndtj|�tj|	�tj|�tj|
�tj|�d�z}
dd|
iz}ttj|���dx}x}	x}x}
x}}y)z$Test EndsWith() checks string suffixr/z?SELECT id FROM test_simple_strings WHERE email.EndsWith('.org')rdr1r3r4r5r6r;r<Nr=rErhrirjrmrnrorqs               r�test_endswith_suffix_checkz,TestStringMethods.test_endswith_suffix_check�s[�����8�`�b���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������d�8�/�8�?�?�/�?�$�/�s�$�%�/�!�Q��/�%��/�/�/�/�%��/�/�/�/�/�/�s�/�/�/�s�/�/�/�8�/�/�/�?�/�/�/�$�/�/�/�%�/�/�/��/�/�/�/�/�/�/�/rc	��|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|d}|j}	|	�}t|�}
d
dh}|
|k(}|s�tjd|fd|
|f�dt	j
�vstjt�rtjt�ndtj|�tj|	�tj|�tj|
�tj|�d�z}
dd|
iz}ttj|���dx}x}	x}x}
x}}y)z/Test EndsWith() on strings with trailing spacesr/z<SELECT id FROM test_simple_strings WHERE name.EndsWith('  ')rdr1r3r4r5r6r;r<Nr=r>rGrhrirjrmrnrorqs               r�test_endswith_with_spacesz+TestStringMethods.test_endswith_with_spaces�s[�����8�]�_���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������d�8�/�8�?�?�/�?�$�/�s�$�%�/�!�Q��/�%��/�/�/�/�%��/�/�/�/�/�/�s�/�/�/�s�/�/�/�8�/�/�/�?�/�/�/�$�/�/�/�%�/�/�/��/�/�/�/�/�/�/�/rc�h�|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|jdd
}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	y)z#Test combining Trim() with Length()r/zTSELECT id, name.Trim().Length() as trimmed_len FROM test_simple_strings WHERE id = 4r_r1r3r4r5r6r;r<Nr�trimmed_lenrrArBrDr:rIrSs           r�test_trim_then_lengthz'TestStringMethods.test_trim_then_length�s�����8�u�w���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������w�w�q�z�-�(�-�A�-�(�A�-�-�-�-�(�A�-�-�-�(�-�-�-�A�-�-�-�-�-�-�-rc��|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|jdd
}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	|jdd}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	|jdd}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	y)z-Test multiple string methods in single SELECTr/z�SELECT id, name.Trim() as trimmed, email.IndexOf('@') as at_pos, code.Length() as code_len FROM test_simple_strings WHERE id = 1r_r1r3r4r5r6r;r<Nrr?�AlicerArBrDr:rzr�code_lenr�rIrSs           r�&test_multiple_string_methods_in_selectz8TestStringMethods.test_multiple_string_methods_in_select�s������8� b�c���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������w�w�q�z�)�$�/��/�$��/�/�/�/�$��/�/�/�$�/�/�/��/�/�/�/�/�/�/��w�w�q�z�(�#�(�q�(�#�q�(�(�(�(�#�q�(�(�(�#�(�(�(�q�(�(�(�(�(�(�(��w�w�q�z�*�%�*��*�%��*�*�*�*�%��*�*�*�%�*�*�*��*�*�*�*�*�*�*rc�h�|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|jdd
}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	y)z7Test string methods combined with arithmetic operationsr/z\SELECT id, name.Length() + email.Length() as total_len FROM test_simple_strings WHERE id = 1r_r1r3r4r5r6r;r<Nr�	total_len�rArBrDr:rIrSs           r�"test_string_method_with_arithmeticz4TestStringMethods.test_string_method_with_arithmetic�s�����8�}����A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������w�w�q�z�+�&�,�"�,�&�"�,�,�,�,�&�"�,�,�,�&�,�,�,�"�,�,�,�,�,�,�,rc��y)z2Test string methods on empty strings if they existN�)r*s r�test_method_on_empty_stringz-TestStringMethods.test_method_on_empty_string�s��	
rc�N�|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}y)z8Test string methods with special characters in argumentsr/z<SELECT id FROM test_simple_strings WHERE email.Contains('.')r�r1r3r4r5r6r;r<N)
r-r4rJrKrLrMrNrOrPrQ)r*r5rTrUrVrWrXrYs        r�#test_method_with_special_charactersz5TestStringMethods.test_method_with_special_characters�s������8�]�_���A��2�w��"��w�"�}����w�"�������s����s�������2����2����w����"�������rc�h�|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|jdd
}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	y)z Test chaining two string methodsr/zOSELECT id, name.Trim().Length() as result FROM test_simple_strings WHERE id = 4r_r1r3r4r5r6r;r<Nrr,rrArBrDr:rIrSs           r�test_simple_method_chainingz-TestStringMethods.test_simple_method_chaining�s�����8�p�r���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������w�w�q�z�(�#�(�q�(�#�q�(�(�(�(�#�q�(�(�(�#�(�(�(�q�(�(�(�(�(�(�(rc��|jdd�\}}|rtjd�yt|�}d}||k(}|s�t	j
d|fd||f�dt
j�vst	jt�rt	jt�nddt
j�vst	j|�rt	j|�ndt	j|�t	j|�d	�z}d
d|iz}tt	j|���dx}x}}|jd
d}d}	||	k(}|slt	j
d|fd||	f�t	j|�t	j|	�d�z}
dd|
iz}tt	j|���dx}x}}	y)zTest chaining three methodsr/z[SELECT id, name.Trim().TrimStart().Length() as result FROM test_simple_strings WHERE id = 4z(Triple method chaining not yet supportedr_r1r3r4r5r6r;r<Nrr,rrArBrDr:)
r-�pytest�skipr4rJrKrLrMrNrOrPrQrR)r*r5�errrUrVrWrXrYrZr[r\s           r�test_triple_method_chainingz-TestStringMethods.test_triple_method_chaining�s���.�.�!:� }����C���K�K�B�C��r�7��a��7�a�<����7�a�������3����3�������r����r����7����a���������7�7�1�:�h�'�,�1�,�'�1�,�,�,�,�'�1�,�,�,�'�,�,�,�1�,�,�,�,�,�,�,rc�h�|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|jdd
}d}	||	k(}|sltjd|fd||	f�tj|�tj|	�d�z}
dd|
iz}ttj|���dx}x}}	y)z%Test string methods in WHERE with ANDr/zXSELECT id FROM test_simple_strings WHERE name.StartsWith('A') AND email.EndsWith('.com')r_r1r3r4r5r6r;r<Nrr=rArBrDr:rIrSs           r�test_string_methods_with_andz.TestStringMethods.test_string_methods_with_and�s�����8�y�{���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������w�w�q�z�$��$�1�$��1�$�$�$�$��1�$�$�$��$�$�$�1�$�$�$�$�$�$�$rc	��|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|d}|j}	|	�}t|�}
d
dh}|
|k(}|s�tjd|fd|
|f�dt	j
�vstjt�rtjt�ndtj|�tj|	�tj|�tj|
�tj|�d�z}
dd|
iz}ttj|���dx}x}	x}x}
x}}y)z$Test string methods in WHERE with ORr/zUSELECT id FROM test_simple_strings WHERE name.StartsWith('A') OR name.StartsWith('B')rdr1r3r4r5r6r;r<Nr=r_rhrirjrmrnrorqs               r�test_string_methods_with_orz-TestStringMethods.test_string_methods_with_or�s[�����8�v�x���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������d�8�/�8�?�?�/�?�$�/�s�$�%�/�!�Q��/�%��/�/�/�/�%��/�/�/�/�/�/�s�/�/�/�s�/�/�/�8�/�/�/�?�/�/�/�$�/�/�/�%�/�/�/��/�/�/�/�/�/�/�/rc	��|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}|d}|j}	|	�}t|�}
hd
�}|
|k(}|s�tjd|fd|
|f�dt	j
�vstjt�rtjt�ndtj|�tj|	�tj|�tj|
�tj|�d�z}
dd|
iz}ttj|���dx}x}	x}x}
x}}y)z$Test string methods with != operatorr/z;SELECT id FROM test_simple_strings WHERE name.Length() != 5rGr1r3r4r5r6r;r<Nr=>rdr0r>rrErGrer�rhrirjrmrnrorqs               r�!test_string_method_with_not_equalz3TestStringMethods.test_string_method_with_not_equal�s]�����8�\�^���A��2�w��!��w�!�|����w�!�������s����s�������2����2����w����!���������d�8�B�8�?�?�B�?�$�B�s�$�%�B�)B�B�%�)B�B�B�B�B�%�)B�B�B�B�B�B�B�s�B�B�B�s�B�B�B�8�B�B�B�?�B�B�B�$�B�B�B�%�B�B�B�)B�B�B�B�B�B�B�B�Brc���|jdd�\}}t|�}d}||k(}|s�tjd|fd||f�dt	j
�vstjt�rtjt�nddt	j
�vstj|�rtj|�ndtj|�tj|�d�z}d	d
|iz}ttj|���dx}x}}d}|d
}	|	j}||v}|s�tjd|fd||f�tj|�tj|	�tj|�d�z}d	d
|iz}ttj|���dx}x}x}	}d}|d
}	|	j}||v}|s�tjd|fd||f�tj|�tj|	�tj|�d�z}d	d
|iz}ttj|���dx}x}x}	}y)z*Test string method performance on all rowsr/z6SELECT name.Trim() as trimmed FROM test_simple_stringsr�r1r3r4r5r6r;r<Nr@r?)�in)z.%(py1)s in %(py6)s
{%(py6)s = %(py4)s.values
})r8rCr:rF)r-r4rJrKrLrMrNrOrPrQ�values)
r*r5rTrUrVrWrXrYrZr[s
          r�test_string_method_on_all_rowsz0TestStringMethods.test_string_method_on_all_rows�st�����8�W�Y���A��2�w��"��w�"�}����w�"�������s����s�������2����2����w����"���������.�"�Y�-�.�-�.�.�.�w�.�.�.�.�.�w�.�.�.�.�w�.�.�.�-�.�.�.�.�.�.�.�.�.�.�.��.�"�Y�-�.�-�.�.�.�w�.�.�.�.�.�w�.�.�.�.�w�.�.�.�-�.�.�.�.�.�.�.�.�.�.�.rN)!�__name__�
__module__�__qualname__�__doc__�classmethodrrr-r]r`rbrfrxr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrs���B��<��<�$�#�$�c�$�&?�0�0�5�6�)�'�%�7�?�%�<�0�0�.�+�-�
�
�)�	-�%�0�C�/rr�__main__z-v)r��builtinsrL�_pytest.assertion.rewrite�	assertion�rewriterJrr��pathlibr�ior�pandasr'rr��mainrr�rr�<module>r�sO������
����c/�c/�J�z���F�K�K��4� �!�r