Giter Site home page Giter Site logo

Comments (5)

sd2k avatar sd2k commented on June 10, 2024 2

Thanks @zhiburt!

I did a little investigation into psql's formatting:

postgres=# insert into test values (0, 'this is a short string
postgres'# with a newline', 'a really really really really really really really really really really really really really really really really really really really really really really really really really long string');
INSERT 0 1
postgres=# select * from test;
-[ RECORD 1 ]-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
a | 0
b | this is a short string                                                                                                                                                                      +
  | with a newline
c | a really really really really really really really really really really really really really really really really really really really really really really really really really long string

So it looks like psql follows your second example 🙂


Edit: just saw your new comment, that looks ace! I can think of a couple of potentially useful customizations:

  1. removing the quotes around each field (perhaps that should just be the default behaviour, to match psql?)
  2. setting the max width for the second column
  3. configuring whether the second column should wrap if it exceeds the max width, rather than truncating

Actually for 3. I was about to create a separate issue to enable wrapping in the default Table layout - I'll do that separately.

So cool that you got this done so quickly!

from tabled.

zhiburt avatar zhiburt commented on June 10, 2024 1

Hi @sd2k,
thank you for making this proposal.

I think it might be useful.
I'll try to work on this.

One question got to my mind though:
what happens if a value is multiline string?

There could be used {:?} to have a one line with escaped symbols.

-[ RECORD 1 ]-
first  | "Hello\nWorld"

Or we could expand | rows like this.

-[ RECORD 1 ]-
first  | Hello
       | World

from tabled.

zhiburt avatar zhiburt commented on June 10, 2024 1

I've updated #21 so it now has a methods for max width.

But I started to feel that maybe its too much of customization :( as we do a couple of allocation because of this.

Are you satisfied with how it looks?

The names of methods a bit worry me 😞

from tabled.

zhiburt avatar zhiburt commented on June 10, 2024

Please take a look at example

And is there any modificators I should add for such a type? Like custom width, custom space, a way to put a custom RECORD name or something.

from tabled.

zhiburt avatar zhiburt commented on June 10, 2024

It turns out that the format isn't as plain.

There's a + sign and the length of ------ in header pattern must be the same for all records.
All of this requires allocations which makes me sad 😞

from tabled.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.