dbcli / litecli

CLI for SQLite Databases with auto-completion and syntax highlighting
https://litecli.com
BSD 3-Clause "New" or "Revised" License
2.12k stars 68 forks source link

Incomplete, multi-line CREATE TABLE with .schema #58

Closed elig0n closed 5 years ago

elig0n commented 5 years ago

Under regular sqlite3 .schema command displays my database schema properly. But under litecli a multi-line CREATE TABLE is cut weirdly only after a few column description lines. No special character I detected at the cut point (I've checked with an hex editor). Each indented line is using only spaces.

Example:

exampledb.sqlite3> .schema
sql
CREATE TABLE example_table ( col0_name TEXT,
                                            col1_name TEXT,
                                            col2_name TEXT,
                                            c
<null>
CREATE TABLE .... [one-liners, all displayed alright]

Tried with several \T options and with different less pager options and cat.

Queries are fine and everything else works alright though.

amjith commented 5 years ago

I'm not able to reproduce this locally. Do you have the exact create statement that you used?

Perhaps you can paste the output of .schema from the sqlite3 cli.

elig0n commented 5 years ago

@amjith Please try with this: https://pastebin.com/raw/Uyrs2hfA

amjith commented 5 years ago

I'm able to reproduce it. Thank you for your example. Trying to figure out the fix now.

amjith commented 5 years ago

@tsroten I found an interesting issue with cli_helpers that I'm not sure how to solve.

One of the preprocessors applied by tabulate_adapter is truncate_string.

But in this specific issue where the CREATE TABLE statement is mutli-line there result can often be longer than the 500 characters but it is broken up into multiple lines using \n characters.

Ideally, I would want to override the default preprocessors for the tabulate adapter when I know that there is a reason to do so. But with the way the code is structured, I can specify additional preprocessors but I can't override the existing ones.

So I'm wondering what would be the best way to proceed?

tsroten commented 5 years ago

@amjith I can definitely see a use case for disabling preprocessors in general. There is a way to disable the truncate_string preprocessor, which is to pass max_field_width=None as a keyword argument when you call format_output(). Would that work?

amjith commented 5 years ago

I'll give that a shot. Thank you for the tip.

On Sun, May 26, 2019, 05:12 Thomas Roten notifications@github.com wrote:

@amjith https://github.com/amjith I can definitely see a use case for disabling preprocessors in general. There is a way to disable the truncate_string preprocessor, which is to pass max_field_width=None as a keyword argument when you call format_output(). Would that work?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dbcli/litecli/issues/58?email_source=notifications&email_token=AAAMA3DUBL6ESQ3Y6COIJ5TPXJ5BDA5CNFSM4HOHUYBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWIEO4Y#issuecomment-495994739, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAMA3C2J6XT3U75CM25PD3PXJ5BDANCNFSM4HOHUYBA .

amjith commented 5 years ago

This is now fixed in cli_helpers and released. Please upgrade cli_helpers by running:

pip install -U cli_helpers