Skip to content

Conversation

@begelundmuller
Copy link
Contributor

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!
@begelundmuller begelundmuller self-assigned this Dec 9, 2025

// ToLiteral converts a Go value to its corresponding SQL literal representation.
// It handles primitive types and lists. All other types are emitted as JSON-encoded strings.
func ToLiteral(val any) string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some common cases can be handled without reflection. Reference :

func ConvertAssign(dest, src any) error {
// Common cases, without reflect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Anshul. It's a good point and would certainly speed up the code. But this code is not currently expected to be in any hot path (unlike ConvertAssign, which certainly is in the hot path), so I will omit this optimization for now to keep the surface area and chance of edge cases limited.

@begelundmuller begelundmuller merged commit b4ced5f into main Dec 10, 2025
13 checks passed
@begelundmuller begelundmuller deleted the begelundmuller/metrics-expression-to-metrics-sql-generate-correct-SQL-values branch December 10, 2025 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants