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

Should the builder types be immutable? #213

Open
guregu opened this issue Feb 14, 2023 · 0 comments
Open

Should the builder types be immutable? #213

guregu opened this issue Feb 14, 2023 · 0 comments

Comments

@guregu
Copy link
Owner

guregu commented Feb 14, 2023

This is a question for v2.

Currently the builder types like *Query and *Update are mutable. This works similar to the standard library text/template package where they return themselves for convenience.

Some other packages (like goqu for example) use immutable types instead. The advantage of this method is that you can create base queries and easily extend them.

The disadvantage of switching is it would break any v1 code that relies on the mutability.
Alternatively we could ditch the builder pattern. Functional parameters are the current best practice but we have a lot of disparate parameters so it would probably be annoying to work with 🤔

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

No branches or pull requests

1 participant