pretty-print sql

Issue #497 resolved
Former user created an issue

The idea is that: * each SQL important operator/keyword start on newline * nesting is made visible by identation (like in python)

some details: * compound ops - union/except/etc - are treated with somewhat medium indent - not inside but not outside either * SELECT has no newline prepended * don't know if INSERT/UPDATE/DELETE would need identation except in their WHERE clause

Comments (8)

  1. Mike Bayer repo owner

    the "indentlevel" setting in the accept_visitor breaks encapsulation. the object being visited should make no assumptions about its visitor, all indent counting should be in the compiler itself.

  2. Former user Account Deleted

    (original author: sdobrev) hmmm - keeping track of recursion level in the visitor.. How about moving it into some .enter/leave() methods of visitor? and either havbing them empty in the root Visitor, or their usage again put in try: except ?

  3. Mike Bayer repo owner
    • changed component to sql
    • changed milestone to 0.4.xx

    the tabbing looks a little deep to me. also if/when we integrate this, we have to go through and ensure that all the tests which test for specific SQL are normalizing whitespace. for the main unit tests this is probably already the case but theres also two doctests in doc/build.

  4. Former user Account Deleted

    too deep: you mean 4 spaces too much? may put that 4 as class or module variable; then people can set it to their preferred tab-width, or 0 to get all flush-to-left-aligned. or maybe ask the group how much they like the result? -- svil

  5. Log in to comment