Skip to content

Re-use bindings when values are identical #338

@tantaman

Description

@tantaman

If I have the query:

sql`SELECT * FROM foo WHERE a = ${some_big_value} OR b = ${some_big_value}`

it should ideally generate:

{
  text: `SELECT * FROM foo WHERE a = $1 OR b = $1,
  values: [some_big_value]
}

rather than

{
  text: `SELECT * FROM foo WHERE a = $1 OR b = $2,
  values: [some_big_value, some_big_value]
}

I've implemented this via my own formatFunction here: rocicorp/mono#4112

but seems like this should be an option in the library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions