▲ | never_inline 3 days ago | ||||||||||||||||||||||||||||||||||||||||
How do you do conditional filters in pure SQL from a backend Java / Python app, without doing string concatenation? Not a fan of all the proxy object circus ORMs do but I'd leave row-> domain object mapping and filter building to some library. Sweet spot is probably something akin to Android Room / Micronaut Data JDBC. | |||||||||||||||||||||||||||||||||||||||||
▲ | minitech 3 days ago | parent | next [-] | ||||||||||||||||||||||||||||||||||||||||
Query builders that operate at the SQL level. (A popular example of that in Python is SQLAlchemy Core, but there are better ways to do it, especially in better-typed languages.) | |||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||
▲ | foobazgt 3 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||
JOOQ (http://jooq.org) is pretty fantastic for this, and it's my go-to for working with RDBMs' on the JVM. It provides a DSL-like API that lets you write pretty much any SQL you need in a type-safe way (without string concatenation). | |||||||||||||||||||||||||||||||||||||||||
▲ | crazygringo 3 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||
What's wrong with string concatenation? | |||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||
▲ | sgarland 3 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||
SQL has CASE statements, if you’d really like to have all branching logic in pure SQL. | |||||||||||||||||||||||||||||||||||||||||
▲ | paulddraper 3 days ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||||||||
String concatenation | |||||||||||||||||||||||||||||||||||||||||
|