You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm testing out a hosted MySQL instance that encrypts data at rest. I need to be able to do a plain-text search on one of my columns and, in order to do so, I need to execute a subquery so I'm actually comparing unencrypted text. Below is a working query--I would really appreciate some assistance with "sequelizing" it.
SELECT
id, ownerId, date, textFROM (
SELECT
id, owner_id AS ownerId, date_format(date, '%Y-%m-%d') ASdate, LOWER(text) AStextFROM entries
WHERE owner_id =2
) AS subQuery
WHEREtextLIKE'%hi%'
Here's my sequelize query as it stands. I need to get the above subquery into the below sequelize query. Any ideas? Thanks for the help!
This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂
Activity
mickhansen commentedon Feb 3, 2016
We don't support selecting from a user supplied subquery
jpodwys commentedon Feb 3, 2016
Is this something you'd like sequelize to support, or is it such an edge case that I might as well just use
.query?mickhansen commentedon Feb 3, 2016
Possibly, if we can come up with a good API for this
hartherbert commentedon May 5, 2019
cesumilo commentedon Apr 1, 2021
tonypee commentedon Mar 1, 2022
@mickhansen Would you consider something like:
(setup associations as normal)
When the 'subQuery' field is set, no table would be created, but the sql would be injected. And then to query:
So, basically a way of treating a sub query like a normal table?
resulting in something like
sanxin-lin commentedon Apr 28, 2022
7 years later? Any support for this?
ephys commentedon Apr 28, 2022
The comment from Mick from 6 years ago is still relevant, we need to come up with a good API design for it before we can implement it.
The solution @tonypee sounds more like a solution to support View Tables (#7197) than subqueries.
The solution should probably just be a
fromparameter. But we need to make sure it works well with the other available options.Consider upvoting the initial post to indicate that this feature is desired, or opening a pull request that implements it.
github-actions commentedon May 13, 2022
This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂
kmind-set commentedon Jun 1, 2022
This is a workaround a came up with using queryGenerator and a temp Model:
https://github.com/kmind-set/sequelize-solutions