rusackas opened a new pull request, #42645:
URL: https://github.com/apache/superset/pull/42645

   ### SUMMARY
   
   `Db2EngineSpec.get_table_comment` indexes into the returned comment with 
`comment[0]`, based on a comment saying "Ibm Db2 return comments as tuples, so 
we need to get the first element."
   
   That was true for older `ibm_db_sa`, but it was fixed upstream in 
[ibmdb/python-ibmdbsa#135](https://github.com/ibmdb/python-ibmdbsa/pull/135) 
(merged 2023-07-04, first released in `v0.4.1`): `get_table_comment` now 
returns a plain string, not a tuple.
   
   Superset's own dependency pin (`ibm-db-sa<=0.4.4, >=0.4.4` in 
`pyproject.toml`) already requires that fixed version. So today, `comment[0]` 
is indexing into a plain string and returning only its **first character** — 
every DB2 table comment gets silently truncated to one character, with no error 
(the `except IndexError` only fires when the comment is empty).
   
   ### BEFORE/AFTER
   
   Before:
   ```python
   comment = None
   try:
       table_comment = inspector.get_table_comment(table.table, table.schema)
       comment = table_comment.get("text")
       return comment[0]
   except IndexError:
       return comment
   ```
   A table comment of `"Customer records"` returns `"C"`.
   
   After:
   ```python
   comment = None
   try:
       table_comment = inspector.get_table_comment(table.table, table.schema)
       return table_comment.get("text")
   ```
   Returns the full `"Customer records"`.
   
   ### TESTING INSTRUCTIONS
   
   ```bash
   pytest tests/unit_tests/db_engine_specs/test_db2.py -v
   ```
   
   Updated `test_get_table_comment` to mock the current (string-returning) 
`ibm_db_sa` shape instead of the old tuple shape. Confirmed the updated test 
fails against the pre-fix code (returns `"T"` instead of the full string) and 
passes with the fix.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to