Skip to content

support for qm.Comment query mod #872

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

Merged
merged 3 commits into from
Dec 16, 2020
Merged

support for qm.Comment query mod #872

merged 3 commits into from
Dec 16, 2020

Conversation

Pilatuz
Copy link
Contributor

@Pilatuz Pilatuz commented Dec 6, 2020

This simple query mod adds custom comment just before main query.

For example:

q := shop.Customers(
  qm.Comment("shop.getAllCustomers"),
  qm.Select("id", "name"),
  qm.From("customers"),
)

will be:

-- shop.getAllCustomers
SELECT id, name FROM customers

these comments might be very useful for query analysis at database layer - we can easily find function/method related to particular query.

@aarondl
Copy link
Member

aarondl commented Dec 16, 2020

I'm not opposed to this. Code seems reasonable, you've included tests, it's non-breaking and barely affects users who don't use it. Thank you for the great PR.

@aarondl aarondl merged commit 6ed1a1c into volatiletech:dev Dec 16, 2020
gaiottino added a commit to gaiottino/sqlboiler that referenced this pull request Aug 23, 2021
https://google.github.io/sqlcommenter/ makes it possible to add tracing comments that can be interpreted by e.g. GCPs query analyser.

volatiletech#872 added support for comments but they are prepended on a separate line and sqlcommenter requires the form `/* … */` to be added on the same line as the query which is why I’ve added this PR and the `qm.AppendComment` function.

For example:
```
q := shop.Customers(
  qm.Comment("shop.getAllCustomers"),
  qm.Select("id", "name"),
  qm.From("customers"),
)
```
will be:
```
SELECT id, name FROM customers; /* shop.getAllCustomers /*
```
gaiottino added a commit to gaiottino/sqlboiler that referenced this pull request Aug 23, 2021
https://google.github.io/sqlcommenter/ makes it possible to add tracing comments that can be interpreted by e.g. GCPs query analyser.

volatiletech#872 added support for comments but they are prepended on a separate line and sqlcommenter requires the form `/* … */` to be added on the same line as the query which is why I’ve added this PR and the `qm.AppendComment` function.

For example:
```
q := shop.Customers(
  qm.AppendComment("shop.getAllCustomers"),
  qm.Select("id", "name"),
  qm.From("customers"),
)
```
will be:
```
SELECT id, name FROM customers; /* shop.getAllCustomers /*
```
gaiottino added a commit to gaiottino/sqlboiler that referenced this pull request Aug 23, 2021
https://google.github.io/sqlcommenter/ makes it possible to add tracing comments that can be interpreted by e.g. GCPs query analyser.

volatiletech#872 added support for comments but they are prepended on a separate line and sqlcommenter requires the form `/* … */` to be added on the same line as the query which is why I’ve added this PR and the `qm.AppendComment` function.

For example:
```
q := shop.Customers(
  qm.AppendComment("shop.getAllCustomers"),
  qm.Select("id", "name"),
  qm.From("customers"),
)
```
will be:
```
SELECT id, name FROM customers; /* shop.getAllCustomers /*
```
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 this pull request may close these issues.

2 participants