I did that myself back in the day. Not overly complicated, but a SQL builder.
I think it’s because SQL is sort-of awkward. For basic uses you can take a SQL query string and substitute some parameters in that string. But, that one query isn’t going to cover all your use cases. So, then you have at least 2 queries which are fairly similar but not similar enough that it makes sense just to do string substitutions. Two strings that are fairly similar but distinct suggests that you should refactor it. But, maybe you only make a very simple query builder. Then you have 5 queries and your query builder doesn’t quite cover the latest version, so you refactor it again.
But, instead of creating a whole query builder, it’s often better to have a lot of SQL repetition in the codebase. It looks ugly, but it’s probably much more maintainable.
I did that myself back in the day. Not overly complicated, but a SQL builder.
I think it’s because SQL is sort-of awkward. For basic uses you can take a SQL query string and substitute some parameters in that string. But, that one query isn’t going to cover all your use cases. So, then you have at least 2 queries which are fairly similar but not similar enough that it makes sense just to do string substitutions. Two strings that are fairly similar but distinct suggests that you should refactor it. But, maybe you only make a very simple query builder. Then you have 5 queries and your query builder doesn’t quite cover the latest version, so you refactor it again.
But, instead of creating a whole query builder, it’s often better to have a lot of SQL repetition in the codebase. It looks ugly, but it’s probably much more maintainable.