Re: Connection-Pooling Compile-Time ORM
Can't help myself: const data: SqlQuery = sqls: SELECT Pet.name FROM Pet INNER JOIN House ON House.id = Pet.houseId WHERE House.country = "CA" Run That would be really clean.
Re: Connection-Pooling Compile-Time ORM
To followup on @Variount 's question. Is the ORM goal to be something like: type Pet = object {. tableName: "pets" .} name: string age: int {. fieldName: "age_years" .} const data: SqlQuery = sqls: select Pet.* `from` Pet where Peg.age = 4 Run
Re: Connection-Pooling Compile-Time ORM
As to case, in this particular application, one could have a version that supports the typical styling guidelines for SQL statements. SELECT blah FROM xyz WHERE zin=4 Run could be DSL'd as: const data: SqlQuery = sqls: SELECT "blah" FROM "users" WHERE "zin = 4" Run It would avoid the use of backticks and have a certain visual appeal to SQL coders. But then you would be violating nim's case guidelines. Sometimes one can't win. :-)
Re: Connection-Pooling Compile-Time ORM
Ok, but the general idea is the same, of using an underscore to differentiate code from the typical meaning. To me it's easier to read than those quotes the DSL currently uses.
Re: Connection-Pooling Compile-Time ORM
Python code usually uses a _leading_ underscore to mark an identifier "private" and _trailing_ underscores to distinguish identifiers from keywords. [https://www.python.org/dev/peps/pep-0008/#descriptive-naming-styles](https://www.python.org/dev/peps/pep-0008/#descriptive-naming-styles)
Re: Connection-Pooling Compile-Time ORM
While this is a neat use of templates to create an SQL DSL, where does the ORM part come in? I don't see any place to automatically load values into an object/ref, aside from the procedures returning sequences.
Re: Connection-Pooling Compile-Time ORM
What does a multi-line where clause look like? I couldn't find an example, especially of a complex where clause, possibly using exists as one of the lines. It's a pity the from keyword needs to be in single quotation marks. I was trying to think of an alternative (e.g. source), but then it wouldn't have the same syntax as SQL. A leading underscore would be better IMHO: _from. Python uses leading underscores in this situation.
Re: Connection-Pooling Compile-Time ORM
I envy your productivity and inventiveness.
Connection-Pooling Compile-Time ORM
[https://juancarlospaco.github.io/nim-gatabase](https://juancarlospaco.github.io/nim-gatabase) * `0` Dependency, uses `system.nim` only, everything is done via `template` and `macro`, Docs, Examples, CI, etc etc (`db_postgres` for Postgres but Optional) * Running compile-time and JavaScript: [https://github.com/juancarlospaco/nim-gatabase/runs/820885295#step:13:49](https://github.com/juancarlospaco/nim-gatabase/runs/820885295#step:13:49) * Running static connection Array 100 Postgres: [https://github.com/juancarlospaco/nim-gatabase/runs/820885295#step:14:102](https://github.com/juancarlospaco/nim-gatabase/runs/820885295#step:14:102) :)