from Hacker News

Embedding Lua in Sqleibniz with Rust

by xnacly on 12/18/24, 11:33 PM with 2 comments

  • by emmanueloga_ on 12/19/24, 3:25 AM

    Nice project! I was recently exploring LSPs for SQL. I have an idea to extend their functionality beyond static analysis into runtime data assistance, blending both static and runtime checks.

    For example, given these files:

        -- file1.sql
        INSERT INTO authors (id, name) VALUES (42, 'Lolo'), (43, 'Tony');
        
        -- file2.sql
        INSERT INTO posts (id, title, content) VALUES (17, 'Post Title', 'Post Content');
        
        -- file3.sql
        INSERT INTO author_posts (author_id, post_id) VALUES (42, 17);
    
    Imagine an LSPd that scans files, parses incomplete or broken SQL, and suggests data in real-time. For instance, while typing `VALUES (` in file3.sql, it would auto-complete `(42, 'Lolo') or (43, 'Tony')`, inferred from file1.sql.

    There are a lot of caveats (like handling insertions, deletions, or the order of operations), but even partially reliable, plausible suggestions would provide enough value.

    In my current project, I generate TypeScript for static checks and validate insertions at build time. However, an LSP like this could streamline the data insertion process and reduce the need for admin dashboards.

    I’m not aware of any existing LSP servers that function this way. I’m interested in exploring this concept for Kuzu/Cypher since my project data is graph-like, but the idea should be applicable to any data store.

  • by lovasoa on 12/19/24, 3:25 PM

    All I want for Christmas is a good LSP for SQL ! Ideally one that would be customizable enough to allow SQLPage functions and parameters.