News for hackers. Stuff that matters.
Re:I don't want to learn your query language (2018) by BiteCode_dev on Wednesday March 10, 2021 @10:34AM (#26412288)
This is why good ORM like SQLAlchemy actually are split in 2 parts: the declarative layer, and the core layer.

The declarative layer gives you the handy ORM syntax for simple operations.

The core layer is lower level, and allows to composes all possible SQL operations you can dream, but from the comfort of your programming language, including typing, completion, and so on.

Does something like that exist for Go ? I don't know the golang ecosystem very well.

Re:I don't want to learn your query language (2018) by dgellow on Wednesday March 10, 2021 @11:18AM (#26412813)
My dream is to write actual SQL in the middle of my code, as a valid syntax and first-class construct. As I said, that's not really a realistic goal.

Do you have some examples of SQLAlchemy core layer you're talking about, just to have an idea of what you have in mind?

Re:I don't want to learn your query language (2018) by squaresmile on Wednesday March 10, 2021 @12:59PM (#26414064)
I couldn't find exactly an only Core example that you are looking for in the examples folder [0] so here is a more complicated tutorial query [1] and here's how I use Core in my project [2] (mostly short select statements so not really a comprehensive demonstration of SQLAlchemy Core's capabilities).

[0] https://github.com/sqlalchemy/sqlalchemy/tree/master/example...

[1] https://docs.sqlalchemy.org/en/14/core/tutorial.html#common-...

[2] https://github.com/atlasacademy/fgo-game-data-api/tree/maste...

Re:I don't want to learn your query language (2018) by dgellow on Wednesday March 10, 2021 @01:54PM (#26414665)
Thank you :)
Re:I don't want to learn your query language (2018) by lelanthran on Thursday March 11, 2021 @02:59AM (#26421483)
> My dream is to write actual SQL in the middle of my code, as a valid syntax and first-class construct. As I said, that's not really a realistic goal.

Sure, it is. See how regexes in some languages are first class datatypes, so you can have a regex literal in your code (with backreferences too, I believe).

There is no good reason that SQL statements can't also be a datatype, with SQL literals in the code like the way regexes do. I'm imagining something like this:

   sql_t stmt = /SELECT #1, #2 FROM #3, #4 WHERE #3.#1 = #4.#2/;
   sql_res_t res_cursor = sql_exec (stmt, t1_col1, t2_col2, T1, T2);
The stmt above is not a string, hence is part of the AST and can be checked at compile time. The execution might be a problem (returned columns have to be checked too).