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

Raw() parameters name uniqueness #10806

Open
18 tasks
alexey-pelykh opened this issue Mar 30, 2024 · 0 comments
Open
18 tasks

Raw() parameters name uniqueness #10806

alexey-pelykh opened this issue Mar 30, 2024 · 0 comments

Comments

@alexey-pelykh
Copy link
Contributor

Feature Description

Consider the following example:

{
  someFieldA: Raw((columnAlias) => `${columnAlias} = :param`, { param: 5 }),
  someFieldB: Raw((columnAlias) => `${columnAlias} = :param`, { param: 0 }),
}

In this case it's a design restriction that param has to be named uniquely every time manually.

The Solution

It would be nice to have a signature that allows to do the following:

{
  someFieldA: Raw((columnAlias) => `${columnAlias} = :${columnAlias}`, (columnAlias) => ({ [`${columnAlias}`]: 5 })),
  someFieldB: Raw((columnAlias) => `${columnAlias} = :${columnAlias}`, (columnAlias) => ({ [`${columnAlias}`]: 0 })),
}

This would allow an elegant way to avoid naming collision in decoupled code.

Considered Alternatives

Alternative, we can consider the following approach:

{
  someFieldA: Raw((columnAlias) => `${columnAlias} = :{0}`, [ 5 ]),
  someFieldB: Raw((columnAlias) => `${columnAlias} = :{0}`, [ 0 ]),
}

where {0} and so on would be automatically replaced with auto-generated param names.

Additional Context

No response

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, but I don't know how to start. I would need guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant