On Monday, September 10, 2018 at 7:54:19 AM UTC-7, Matthew Curtice wrote:
>
> We have been unable to upgrade for a while, and now that we finally got
> the chance to go from 5.3 to the latest, below change from 5.8 has broken
> several queries we have. Here's the basics of what we are doing:
>
> person_1 = Person.from_self(:alias => :person_1).
> where(...some conditions...)
>
> person_2 = Person.from_self(:alias => :person_2).
> where(...some_conditions...).
> exclude(Sequel[:person_2][:id] => person_1.select(Sequel[:person_1][:id
> ]))
>
>
> Because the from_self query is now cached, the second query now uses
> person_1 as the alias, which breaks everything.
>
> It does not seem like there is an option to turn the caching off. I would
> rather not monkey patch around this, especially because I recognize the
> performance gain this will bring. Is there a way of aliasing a table other
> than using from_self? What the #as function does for a column would
> fulfill our needs if it could also be applied to a table. I have never
> liked using from_self for this purpose, but I've never found a better way
> to do it.
>
If you want to alias a table without using a subquery, use Dataset#from,
not #from_self:
Person.from{people.as(:person_1)}
However, the caching of from_self datasets with different aliases is a bug,
it should not have broken your code. As the release notes stated,
from_self should only be cached without options, not if options were
given. I'll fix that in the next release.
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.