Skip to content
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

Query templates #27

Merged
merged 8 commits into from
Nov 23, 2023
Merged

Query templates #27

merged 8 commits into from
Nov 23, 2023

Conversation

kayrein
Copy link
Collaborator

@kayrein kayrein commented Oct 11, 2023

Introduce support for text interpolation

@kayrein kayrein force-pushed the query_templates branch 2 times, most recently from 869994d to 4820f2c Compare October 11, 2023 20:35
@qustavo
Copy link
Owner

qustavo commented Oct 16, 2023

This is great, a long standing feature getting implemented!
I have a look at the implementation and although it looks correct to me, I have some concerns with the public API that I'd like to share.

  • Even though the dot.WithOptions(opts).Query(...) seems to be more ergonomic, I think that WithOptions should return an error when the parsing fails; as opposed to wait for lookupQuery. If my queries have an error I'd like to know as soon as possible.

  • I'm not sure about naming. Options suggest something that you can choose from, like a config. I'd use WithData, WithParams or even WithArgs

  • Finally, instead of receiving a map[string]interface{} (which now it looks like any is used instead of interface{}), I'd pass just any, which is what .Execute accepts.

WithOptions(...) -> WithData(...)
and take any rather than a map.
@kayrein
Copy link
Collaborator Author

kayrein commented Oct 19, 2023

In 522d695
I made it parse all the queries when you load them - so if you load your dotsql files at application start and have a syntax error in one of your queries it will fail at start rather than when you try to call the query. Which is pretty fast! I did add a test to assert this behaviour though.

But the WithData(...) call cannot fail because it doesn't yet know which query you're executing - it would have to try each query with that data.

Have acted on the other comments though :)

@kayrein
Copy link
Collaborator Author

kayrein commented Oct 30, 2023

Any thoughts @qustavo?

Copy link
Owner

@qustavo qustavo left a comment

Choose a reason for hiding this comment

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

sorry for the late review

dotsql.go Outdated Show resolved Hide resolved
dotsql.go Outdated Show resolved Hide resolved
dotsql.go Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
dotsql.go Outdated Show resolved Hide resolved
dotsql.go Outdated Show resolved Hide resolved
dotsql_test.go Outdated Show resolved Hide resolved
dotsql_test.go Outdated Show resolved Hide resolved
dotsql_test.go Outdated Show resolved Hide resolved
dotsql_test.go Outdated Show resolved Hide resolved
dotsql_test.go Outdated Show resolved Hide resolved
integration_test.go Outdated Show resolved Hide resolved
Copy link
Owner

@qustavo qustavo left a comment

Choose a reason for hiding this comment

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

looks really good now!
just added one more comment and I think we are good to go.
thanks!

dotsql.go Outdated Show resolved Hide resolved
@kayrein kayrein requested a review from qustavo November 13, 2023 11:46
Copy link
Owner

@qustavo qustavo left a comment

Choose a reason for hiding this comment

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

Code looks much cleaner now, thank for applying the changes.
I've added some test remarks.

dotsql_test.go Outdated Show resolved Hide resolved
integration_test.go Outdated Show resolved Hide resolved
integration_test.go Outdated Show resolved Hide resolved
dotsql_test.go Outdated Show resolved Hide resolved
dotsql_test.go Outdated Show resolved Hide resolved
@kayrein kayrein requested a review from qustavo November 17, 2023 20:15
@qustavo qustavo merged commit 5d06b89 into qustavo:master Nov 23, 2023
@qustavo
Copy link
Owner

qustavo commented Nov 23, 2023

@kayrein added you as a member, do you think you can cut a new release including this?

@kayrein kayrein deleted the query_templates branch November 24, 2023 19:07
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