Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Question: Any raw sql in ts files are accepted? #62

Closed
PorcoRosso85 opened this issue May 27, 2024 · 9 comments
Closed

Feature Question: Any raw sql in ts files are accepted? #62

PorcoRosso85 opened this issue May 27, 2024 · 9 comments
Labels
enhancement New feature or request

Comments

@PorcoRosso85
Copy link

PorcoRosso85 commented May 27, 2024

Hi.
I found this explaination:

https://marketplace.visualstudio.com/items?itemName=senken.sqlsurge


Supporting raw SQL query

[Prisma in TypeScript
SQLx in Rust


This means that we should use prisma if we want to make ts file autocompleted by vscode?

@senkenn
Copy link
Owner

senkenn commented May 27, 2024

@PorcoRosso85 Thank you for issue!!!!!!!!

Any raw sql in ts files are accepted?

Yes!!! I'm planning it in TODOs.

- [ ] Support to custom raw SQL queries, not just Prisma and SQLx

sqlsurge use AST to extract raw SQLs, so it is possible to support any ORM libraries or user-defined functions.

I'm considering the vscode settings. For example, there is a code like this,

const result = fooQueryFunc(connection, "SELECT name FROM users WHERE id = 123");

And settings.json,

"sqlsurge.custom": {
  "language": "typescript",
  "function": "fooQueryFunc",
  "templateLiteral": false,
  "argNum": 1 // 0-indexed
}

It would also be possible to handle cases where SQL is split like this,

const baseSql = "SELECT name FROM users";
const condition1 = "WHERE id = 1";
const condition2 = "WHERE id = 2";
const result = fooQueryFunc(connection, baseSql + condition);

I'll support it in the future.

@senkenn
Copy link
Owner

senkenn commented May 27, 2024

@PorcoRosso85
I'd like to ask you as a reference, which library are you using? Or your own functions?

@senkenn senkenn added the enhancement New feature or request label May 27, 2024
@PorcoRosso85
Copy link
Author

Own functions, maybe. No orm library.

I'm writing raw sql files as both of DDL and DML,
these files are for 'sqlc comilation for typescript' and 'sqldef migration'

I'm searching one like yours that supports us to write type safed sql in ts file.

@senkenn
Copy link
Owner

senkenn commented May 28, 2024

This feature will take time, but I'll do my best to release it soon!

@PorcoRosso85
Copy link
Author

By the way,
https://github.com/sqls-server/sqls

will sqls server work any database server if these are live? Do yo know?
https://github.com/sqls-server/sqls?tab=readme-ov-file#support-rdbms

@senkenn
Copy link
Owner

senkenn commented May 29, 2024

@PorcoRosso85
I checked MySQL, Postgres only, sorry.

@PorcoRosso85
Copy link
Author

@senkenn

Enough.

If we use postgres, is what we only have to do is connecting live postgres server for sqls to suggest auto completion?

sqlsurge doesn't require these as sqls doc explaining?

MySQL(Go-MySQL-Driver)
PostgreSQL(pgx)
SQLite3(go-sqlite3)
MSSQL(go-mssqldb)
H2(pgx)
Vertica(vertica-sql-go)

@senkenn
Copy link
Owner

senkenn commented May 29, 2024

@PorcoRosso85 Yes, connection only.

@senkenn
Copy link
Owner

senkenn commented May 29, 2024

@PorcoRosso85 I created new issue about this: #66

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants