Repository navigation
Keep LLM sample data text when only prompt_section_truncate is set - #2468
Merged
Merged
Conversation
Contributor
|
@goranai your PRs are really appreciated. Do you plan to make more? Contact me by email if you want to join the dbcli developer's Slack. |
Contributor
|
Released in https://github.com/dbcli/mycli/releases/tag/v2.32.1 ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #2467.
With only
prompt_section_truncateset in the[llm]section,\llmsent every text and binary value of the sample rows as an empty string. The myclirc suggestsprompt_section_truncate = 1000000by itself, andprompt_field_truncatedefaults toNone, which the config reader turns into0.truncate_list_elementsthen started its loop withwidth = 0, so every value was cut tox[:0].Now, when no field limit is set, the width starts at the longest text value, but never above the section limit. The existing loop shrinks it in steps of 100 until the row fits
prompt_section_truncate, so the section cap still works. Starting no higher than the section limit also keeps a very large blob from looping for a long time.Reproduced on
main(d226c7b) without a MySQL server, by callingsql_using_llmwith a stub cursor and a spy ontruncate_list_elements. Before:sample_data = {'users': [('id', 1), ('name', ''), ('note', '')]}. After:('name', 'alice'), ('note', 'hello world').Behavior changes:
0and the section limit is above0. Other combinations return the same rows as before.Tests:
test_truncate_list_elements_and_table_lineshas new cases and fails onmain, passes with the fix.mycli_test/pytests/test_special_llm.py: 30 passed. I also compared the fixed function withmainand with a property check on 120000 random rows. Nothing changed when the field limit is set or the section limit is 0, and no row broke the property (text cut to one width, the row fits, and the next wider step would not).ruff checkandruff format --checkpass.mypyreports 4 errors that are also onmain(Windows only:pwd,signal.killpg). On Windows the whole suite shows 86 failures with and without this change.Validated with Claude Opus 5.5.
Checklist
changelog.mdfile.mycli/AUTHORS.txtfile (or it's already there).