perseas / Pyrseas

Provides utilities for Postgres database schema versioning.
https://perseas.github.io/
BSD 3-Clause "New" or "Revised" License
395 stars 67 forks source link

Multiline Strings (source: |2) Output Unstable #238

Open salamsp opened 2 years ago

salamsp commented 2 years ago

I have Python 3.9 installed on my PC, but command

dbtoyaml --multiple-files db_development

produced output source: |2 and usual source: "\n<>... in the same call. Is it possible to setup this explicitly?

jmafc commented 2 years ago

I'm not sure I follow exactly, but let me try. I assume you have two or more functions in your database and, I'm guessing, one of the function's source was output different than the other (and further, perhaps you prefer one style over the other). If that's the case, and IIRC that's a "feature" of the YAML output processor, i.e., it uses one style based on the length of the text or some other parameter. On one of my test databases, I see three "text styles":

 function ...:
   language: sql
   source: |-
      SELECT CASE WHEN ...
      ELSE ...
...
 function ...:
   language: plpgsql
   source: "\ndeclare ..."
...
  view ...:
    definition: |2-
      SELECT ( ...

In fact all of the views use the ": |2-" which IIRC means the indentation is two spaces. The SQL functions, which use ":|-" have no indentation (or arbitrary indentation. The PLPGSQL functions use a single string enclosed in double quotes, probably because they start with a newline character and it would be difficult for YAML (which in essence uses newlines to replace the "}," delimiters that you find in JSON) to parse something like the following:

  source: |-

     declare ...
jmafc commented 2 years ago

@salamsp Unless you have some other comments, I believe my discussion above shows that the YAML multiline string output is not unstable, so I'd like to close this issue. Let me know.

salamsp commented 2 years ago

At the moment I have no possebility to check situation because of war in Ukraine.

Tanks, S.Salamatin

On Tue, Aug 30, 2022, 15:09 Joe Abbate @.***> wrote:

@salamsp https://github.com/salamsp Unless you have some other comments, I believe my discussion above shows that the YAML multiline string output is not unstable, so I'd like to close this issue. Let me know.

— Reply to this email directly, view it on GitHub https://github.com/perseas/Pyrseas/issues/238#issuecomment-1231645072, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB252MRBOJTBTN3UB5OGEWTV3YBWZANCNFSM5N3ODR6Q . You are receiving this because you were mentioned.Message ID: @.***>

jmafc commented 2 years ago

Sorry to hear that. Stay well.

salamsp commented 1 year ago

Thank you.

On Tue, Aug 30, 2022, 17:37 Joe Abbate @.***> wrote:

Sorry to hear that. Stay well.

— Reply to this email directly, view it on GitHub https://github.com/perseas/Pyrseas/issues/238#issuecomment-1231836306, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB252MUIIPIOT4PRQ6N4BETV3YTCPANCNFSM5N3ODR6Q . You are receiving this because you were mentioned.Message ID: @.***>