question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Very long generated names for SQL-in-TS

See original GitHub issue

Example:

sql`
insert into users(email, stripe_id, password)
values($email, $stripe_id, $password)
returning *
`

Generated:

export interface ISqlSignupQueryInsertIntoUsersEmailStripeIdPasswordValuesEmailStripeIdPasswordReturningQuery {
  params: ISqlSignupQueryInsertIntoUsersEmailStripeIdPasswordValuesEmailStripeIdPasswordReturningParams;
  result: ISqlSignupQueryInsertIntoUsersEmailStripeIdPasswordValuesEmailStripeIdPasswordReturningResult;
}

That’s 92 characters.

I tried including a comment with @name but it didn’t have any effect. It would be great if it worked and allows users to give names to queries.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
chmlncommented, Aug 10, 2020

@adelsz thanks for the workaround! I played around with possible solutions a bit.

It looks like there is a hard requirement in the parser to have something of the form of

const query = sql`...`

Which means I can’t do

const insertUser = await sqlx(
    sql`
    insert into users(email, stripe_id, password)
    values($email, $stripe_id, $password)
    returning *
`,
    {
        email,
        password,
        stripe_id,
    }
);

I think it would be a nice usability improvement to make concise statements like mine possible. Splitting up is totally okay but introduces some redundancy imo.

Would you be open to allowing something like /* @name Signup */ in the sql template literals? I wouldn’t mind helping out and submitting a PR.

0reactions
adelszcommented, Jul 6, 2021

Sorry for the late reply @chmln. We can allow @name declarations in TS literals as a workaround for your specific usecase. Please feel free to open a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Table name length in sqlite affects performance. Why?
With the longer table names, the resulting empty database file is 4x larger, since the longer table names take up more space in...
Read more >
SQLite Generated Columns
By definition, generated columns are the columns of a table whose values are derived from an expression that involves other columns of the...
Read more >
SQLite Frequently Asked Questions
Short answer: A column declared INTEGER PRIMARY KEY will autoincrement. Longer answer: If you declare a column of a table to be INTEGER ......
Read more >
SQLite Keywords
The SQL standard specifies a large number of keywords which may not be used as the names of tables, indices, columns, databases, user-defined...
Read more >
Implementation Limits For SQLite
SQLite is able to limit the size of a database file to prevent the database file from growing too large and consuming too...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found