Coder Social home page Coder Social logo

Comments (3)

jtdaugherty avatar jtdaugherty commented on May 18, 2024

I added some test cases to cover the two behaviors you mentioned, but it turns out neither is a bug. Both arise from how the underlying YAML parser treats the input data.

The first issue, that of inline comments causing trouble, is due to the fact that YAML parsers do "scalar folding" of values, converting newlines to spaces, unless explicitly told that values are to be treated as literals. The reason is that in YAML, indentation indicates an increase in structure depth, and the content at that depth is the interpreted as a YAML tree, and a literal is usually not what the subsequent tree value is intended to represent. So to fix this, you have to put a pipe following the key name and colon. It also turns out the old me that wrote this code knew about this confusion and even added a note to the README about it. So an example is

foo: |
  bar
  baz

and in that example, the newline in between bar and baz will be preserved. For dbmigrations, this is almost always what you want.

As for the second behavior, since YAML uses colons as delimiters to separate keys and values, and because dashes have special meaning to denote the beginning of a node in a list, the parser interpretes "-- foo:" as YAML. Again, this arises from the lack of a pipe specifying that the value is a literal. If you add that, the problem goes away.

The other advantage to doing this in both cases is that the structure of the SQL is preserved, and that will prevent the lack of newlines from confusing the SQL parser in the database engine.

from dbmigrations.

jtdaugherty avatar jtdaugherty commented on May 18, 2024

I also updated the migration serialization to emit ASCII literal markings by default in 9692cc9, so that should reduce the chance of this being bothersome.

from dbmigrations.

creswick avatar creswick commented on May 18, 2024

whoa! That's a somewhat unfortunate confluence of features, and an interesting problem to think about...

from dbmigrations.

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.