Skip to content

Key Contains Special Characters - ValueError: Unexpected character . in alphanum string #28

@sarath-mec

Description

@sarath-mec

Describe the bug

ValueError: Unexpected character . in alphanum string

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:291, in TableDiffer._parse_key_range_result(self, key_types, key_range)
    [290](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:290) try:
--> [291](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:291)     min_key = Vector(key_type.make_value(mn) for key_type, mn in safezip(key_types, min_key_values))
    [292](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:292)     max_key = Vector(key_type.make_value(mx) + 1 for key_type, mx in safezip(key_types, max_key_values))

File ~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:291, in <genexpr>(.0)
    [290](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:290) try:
--> [291](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:291)     min_key = Vector(key_type.make_value(mn) for key_type, mn in safezip(key_types, min_key_values))
    [292](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:292)     max_key = Vector(key_type.make_value(mx) + 1 for key_type, mx in safezip(key_types, max_key_values))

File ~/miniconda3/envs/tools/lib/python3.12/site-packages/sqeleton/abcs/database_types.py:116, in String_Alphanum.make_value(self, value)
    [115](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/sqeleton/abcs/database_types.py:115) def make_value(self, value):
--> [116](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/sqeleton/abcs/database_types.py:116)     return self.python_type(value)

File ~/miniconda3/envs/tools/lib/python3.12/site-packages/sqeleton/utils.py:222, in ArithAlphanumeric.__init__(self, s, max_len)
    [221](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/sqeleton/utils.py:221)     if ch not in alphanums:
--> [222](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/sqeleton/utils.py:222)         raise ValueError(f"Unexpected character {ch} in alphanum string")
    [224](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/sqeleton/utils.py:224) self._str = s

ValueError: Unexpected character . in alphanum string

The above exception was the direct cause of the following exception:

ValueError                                Traceback (most recent call last)
Cell In[6], [line 1](vscode-notebook-cell:?execution_count=6&line=1)
----> [1](vscode-notebook-cell:?execution_count=6&line=1) for sign, value in diff_tables(table1=oracle_tbl,table2=postgres_tbl):
      [2](vscode-notebook-cell:?execution_count=6&line=2)     print(sign, value)

File ~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:91, in DiffResultWrapper.__iter__(self)
     [89](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:89) def __iter__(self):
     [90](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:90)     yield from self.result_list
---> [91](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:91)     for i in self.diff:
     [92](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:92)         self.result_list.append(i)
     [93](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:93)         yield i

File ~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:179, in TableDiffer._diff_tables_wrapper(self, table1, table2, info_tree)
    [174](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:174)     table1, table2 = self._threaded_call(
    [175](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:175)         "with_schema", [table1, table2], allow_empty_table=self.allow_empty_tables
    [176](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:176)     )
    [177](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:177)     self._validate_and_adjust_columns(table1, table2)
--> [179](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:179)     yield from self._diff_tables_root(table1, table2, info_tree)
    [180](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:180) finally:
    [181](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:181)     info_tree.aggregate_info()

File ~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:187, in TableDiffer._diff_tables_root(self, table1, table2, info_tree)
    [186](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:186) def _diff_tables_root(self, table1: TableSegment, table2: TableSegment, info_tree: InfoTree) -> DiffResult:
--> [187](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:187)     return self._bisect_and_diff_tables(table1, table2, info_tree)

File ~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:226, in TableDiffer._bisect_and_diff_tables(self, table1, table2, info_tree)
    [224](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:224) # Start with the first completed value, so we don't waste time waiting
    [225](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:225) try:
--> [226](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:226)     min_key1, max_key1 = self._parse_key_range_result(key_types1, next(key_ranges))
    [227](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:227) except EmptyTable:
    [228](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:228)     if not self.allow_empty_tables:

File ~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:294, in TableDiffer._parse_key_range_result(self, key_types, key_range)
    [292](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:292)     max_key = Vector(key_type.make_value(mx) + 1 for key_type, mx in safezip(key_types, max_key_values))
    [293](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:293) except (TypeError, ValueError) as e:
--> [294](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:294)     raise type(e)(f"Cannot apply {key_types} to '{min_key_values}', '{max_key_values}'.") from e
    [296](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/smks/~/miniconda3/envs/tools/lib/python3.12/site-packages/reladiff/diff_tables.py:296) return min_key, max_key

ValueError: Cannot apply [String_VaryingAlphanum(), String_VaryingAlphanum()] to '('FEMALE_FIRST', 'A.J.')', '('MALE_FIRST', 'Zuttah')'.

Describe the environment

The key specified contains . character. Can we include string.punctuation also here instead of - and _.

f there is any reason why this is not preferred Since it uses ASCII map for splitting keys, I, let me know

https://github.com/erezsh/sqeleton/blob/master/sqeleton/utils.py#L146

# -- Alphanumerics --

alphanums = " -" + string.digits + string.ascii_uppercase + "_" + string.ascii_lowercase

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions