Skip to content

add "Code generated by sqlc. DO NOT EDIT." header comment #9

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

Closed
yshrsmz opened this issue Jan 19, 2024 · 3 comments · Fixed by #17
Closed

add "Code generated by sqlc. DO NOT EDIT." header comment #9

yshrsmz opened this issue Jan 19, 2024 · 3 comments · Fixed by #17

Comments

@yshrsmz
Copy link
Contributor

yshrsmz commented Jan 19, 2024

to prevent devs from editing the generated file.

@yshrsmz
Copy link
Contributor Author

yshrsmz commented Jan 19, 2024

I can achieve this behavior by just modifying here

   const printer = createPrinter({ newLine: NewLineKind.LineFeed });
-  let output = "";
+  let output = "// Code generated by sqlc. DO NOT EDIT.\n\n";
   for (let node of nodes) {
     output += printer.printNode(EmitHint.Unspecified, node, resultFile);
     output += "\n\n";
   }
   return output;

But I'm not sure if it's OK or should be handled in another place.

@tamsanh
Copy link

tamsanh commented Jan 26, 2024

Might be better off somewhere that has access to the configuration, so that a user can either turn that comment on or off or can supply their own header, like a copyright string.

@kyleconroy
Copy link
Contributor

The Go code generator adds the header by default and you can't turn it off. I think it's a good idea to always add it.

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

Successfully merging a pull request may close this issue.

3 participants