pg-schema-diff icon indicating copy to clipboard operation
pg-schema-diff copied to clipboard

Create Go script that can replace preceding tabs with spaces in SQL string literals

Open ammiranda opened this issue 1 year ago • 5 comments

Related to #67, this issue is a follow-up to the PR resolving #67 which will add a Go based script that can be run as needed to correct the whitespace for the string literals.

The desired feature set should include:

  • Re-writes the acceptance tests to have tab-less multi-line strings
  • Preferably has a--fix option, such that there is basically a validation/dry-run mode and a write mode
  • Is called from the makefile lint and lint_fix targets (like go_lint, sql_lint, etc)

ammiranda avatar Jul 20 '24 15:07 ammiranda

@bplunkett-stripe Feel free to update the issue as needed.

ammiranda avatar Jul 20 '24 15:07 ammiranda

Looks right to me!

Don't worry about making the "dry-run" mode too complicated, i.e., printing out line numbers. Just printing out the file name is fine.

bplunkett-stripe avatar Jul 22 '24 16:07 bplunkett-stripe

You still planning on picking this up @ammiranda? Checking because I might take at a pass at it soon.

bplunkett-stripe avatar Sep 05 '24 07:09 bplunkett-stripe

@bplunkett-stripe I was planning on it, but I think I need a bit more direction on how to implement it. Like how to make it invocable from the command line via the Makefile and how to read the --fix flag for it. I'm guessing the flag could be read using the flags package but I'm unsure.

ammiranda avatar Sep 05 '24 09:09 ammiranda

Yes, you can use the same cobra/flags pkg, similar to the pg-schema-diff command. I would define the script under a file like scripts/acceptance_test_sql_linter/main.go. You could then use go run to call it from the makefile, passing the appropriate parameters.

bplunkett-stripe avatar Sep 08 '24 23:09 bplunkett-stripe