<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>throwaway858</author><text>Here is another TypeScript library for validating types of SQL queries: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;MedFlyt&amp;#x2F;mfsqlchecker&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;MedFlyt&amp;#x2F;mfsqlchecker&lt;/a&gt;&lt;p&gt;It uses the actual PostgreSQL parser against your project&amp;#x27;s database schema to give 100% accurate results. Guarantees that all of your queries are valid, and that all input and output types are correct (and will also auto-generate&amp;#x2F;quickfix the output types for you in VSCode)</text><parent_chain><item><author>nikeee</author><text>I&amp;#x27;m not a fan of the idea of leveraging TS types at runtime. This is just a lock-in to TS, even if type annotations become a thing in JS.
I don&amp;#x27;t like ORMs that use runtime types either. Most of the time, I want to write raw SQL.&lt;p&gt;So as an experiment, I created a library that statically types raw SQL:&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;nikeee&amp;#x2F;sequelts&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;nikeee&amp;#x2F;sequelts&lt;/a&gt;&lt;p&gt;The idea is to parse the SQL queries using TS&amp;#x27;s type system. The parsed query is combined with the database schema and therefore, we know what type the query will return.&lt;p&gt;This is especially useful due to TS&amp;#x27;s structural type system.
It&amp;#x27;s also zero-overhead due to the entire functionality being just TS types, which vanish as soon as we compile. It therefore also works JS-only.&lt;p&gt;However, it&amp;#x27;s just a proof of concept. I&amp;#x27;m working on an ANTLR target for TS types, so that the SQL parser can be generated.
A game changer will also be the integration with sql-template-tags [1] (which would make this actually usable).&lt;p&gt;This is just for selecting data. Time will tell if it&amp;#x27;s feasible to also type-check mutating queries.&lt;p&gt;The primary use-cases will target SQLite&amp;#x2F;D1.&lt;p&gt;[1]: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.npmjs.com&amp;#x2F;package&amp;#x2F;sql-template-tag&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.npmjs.com&amp;#x2F;package&amp;#x2F;sql-template-tag&lt;/a&gt;</text></item></parent_chain></comment><story><title>Deepkit – High-Performance TypeScript Framework</title><url>https://deepkit.io/</url></story>
<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>seer</author><text>Hah a few months back I released &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;ivank&amp;#x2F;potygen&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;ivank&amp;#x2F;potygen&lt;/a&gt;&lt;p&gt;Similar idea - statically typing queries. Mine was mostly me playing around with recursive decent parsers seeing if I can actually parse SQL with it, and it seems to work OK, at least for Postgres.&lt;p&gt;It does require a &amp;quot;build&amp;quot; pass to generate the types, but I&amp;#x27;ve added some additional bells and whistles like auto formatters and on hover info about columns &amp;#x2F; views &amp;#x2F; tables etc. Once you have the sql AST its pretty easy to build a lot of cool stuff around it.&lt;p&gt;It&amp;#x27;s all pure TS and doesn&amp;#x27;t use parser generators like ANTLR. We&amp;#x27;ve been using it in prod for a while now and seem to be working alright - its mostly types anyway, but does have a runtime component, since sql parameters in node Postgres are too basic for our use case.&lt;p&gt;It all started from the amazing &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;dmaevsky&amp;#x2F;rd-parse&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;dmaevsky&amp;#x2F;rd-parse&lt;/a&gt; which showed me that you could build crazy complex parsers with like 100-200 lines of code.</text><parent_chain><item><author>nikeee</author><text>I&amp;#x27;m not a fan of the idea of leveraging TS types at runtime. This is just a lock-in to TS, even if type annotations become a thing in JS.
I don&amp;#x27;t like ORMs that use runtime types either. Most of the time, I want to write raw SQL.&lt;p&gt;So as an experiment, I created a library that statically types raw SQL:&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;nikeee&amp;#x2F;sequelts&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;nikeee&amp;#x2F;sequelts&lt;/a&gt;&lt;p&gt;The idea is to parse the SQL queries using TS&amp;#x27;s type system. The parsed query is combined with the database schema and therefore, we know what type the query will return.&lt;p&gt;This is especially useful due to TS&amp;#x27;s structural type system.
It&amp;#x27;s also zero-overhead due to the entire functionality being just TS types, which vanish as soon as we compile. It therefore also works JS-only.&lt;p&gt;However, it&amp;#x27;s just a proof of concept. I&amp;#x27;m working on an ANTLR target for TS types, so that the SQL parser can be generated.
A game changer will also be the integration with sql-template-tags [1] (which would make this actually usable).&lt;p&gt;This is just for selecting data. Time will tell if it&amp;#x27;s feasible to also type-check mutating queries.&lt;p&gt;The primary use-cases will target SQLite&amp;#x2F;D1.&lt;p&gt;[1]: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.npmjs.com&amp;#x2F;package&amp;#x2F;sql-template-tag&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.npmjs.com&amp;#x2F;package&amp;#x2F;sql-template-tag&lt;/a&gt;</text></item></parent_chain></comment><story><title>Deepkit – High-Performance TypeScript Framework</title><url>https://deepkit.io/</url></story>