sqlparser icon indicating copy to clipboard operation
sqlparser copied to clipboard

visitor for alternative formatting/validation

Open emicklei opened this issue 9 years ago • 5 comments

hi,

I propose to write an enchancement to this package that allows me to write tools such as a better formatter and validator to work with the ast nodes. I think a simple visitor pattern implementation will do.

func (node Select) Accept(v Visitor) { v.VisitSelect(node) }

If you argee with the feature and implementation then I will create a PR for it.

emicklei avatar Mar 13 '16 21:03 emicklei

Sure. That would be more than welcome!

xwb1989 avatar Mar 13 '16 21:03 xwb1989

See https://github.com/emicklei/sqlparser/blob/visit/ast_visit.go for the initial setup.

emicklei avatar Mar 14 '16 16:03 emicklei

Looks good. Looking forward to your PR.

xwb1989 avatar Mar 15 '16 00:03 xwb1989

@emicklei did you have a chance to create the PR? would love to see this feature too :-)

matthewmueller avatar Jan 20 '17 10:01 matthewmueller

@matthewmueller current state is still work-in-progress. I soon realized that the language is very very rich and therefore had many many nodes to handle. So I started to wonder if the approach taken is the correct one. Maybe I should spent some time on a code generator instead that emits all the boilerplate.

emicklei avatar Jan 21 '17 16:01 emicklei