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

sql() params don't work in fields or tables list #77

Open
Suor opened this issue Oct 2, 2015 · 3 comments
Open

sql() params don't work in fields or tables list #77

Suor opened this issue Oct 2, 2015 · 3 comments

Comments

@Suor
Copy link
Contributor

Suor commented Oct 2, 2015

select('id', 'title', sql('ts_rank(tsv, plainto_tsquery($))', search))
    .from('place').where(...)
// SELECT id, title, ts_rank(tsv, plainto_tsquery($)) FROM place ...

select().from('place', sql('plainto_tsquery($) as query', search))
    .where(sql('tsv @@ query'))
// SELECT * FROM place, plainto_tsquery($) as query WHERE tsv @@ plainto_tsquery
@Suor
Copy link
Contributor Author

Suor commented Aug 13, 2017

Any news on this?

@prust
Copy link
Collaborator

prust commented Aug 14, 2017

@Suor: I recently went through the open issues & marked some easy ones as good first bug and bigger or non-backwards compatible ones with the 3.0 milestone. This is the only one that didn't fall into either camp.

I suspect it's not trivial, but not super-hard either, and I was hoping to make time to tackle it within the next few months. If you have time and inclination before then, a pull request would be welcome -- or if you just want to do some initial digging and see where the problem is or where the code will likely need to be changed.

@w33ble
Copy link

w33ble commented May 18, 2022

I just ran in to this when trying to do substitutions for selects with postgis. I don't know if it's any easier, but a utility function to just do a simple value replacement would be a workable alternative.

To use the the original example, I was thinking something like this, where sql.replace just does the string substitutions (without messing with the value indexes).

select('id', 'title', replace('ts_rank(tsv, plainto_tsquery($))', search))
    .from('place').where(...)

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

No branches or pull requests

3 participants