Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
salamsp opened this issue Feb 8, 2022 · 5 comments
Open

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

salamsp opened this issue Feb 8, 2022 · 5 comments
Labels

Comments

@salamsp
Copy link

salamsp commented Feb 8, 2022

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
Copy link
Member

jmafc commented Feb 8, 2022

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 jmafc added the dbtoyaml label Aug 20, 2022
@jmafc
Copy link
Member

jmafc commented Aug 30, 2022

@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
Copy link
Author

salamsp commented Aug 30, 2022 via email

@jmafc
Copy link
Member

jmafc commented Aug 30, 2022

Sorry to hear that. Stay well.

@salamsp
Copy link
Author

salamsp commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants