-
Notifications
You must be signed in to change notification settings - Fork 51
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
Help converting a function from non-baby squeel #55
Comments
I'm happy to help, but I'll need a little information than "it didn't work". Did it throw an error? If so, could you provide a backtrace? If not, what SQL was generated? If |
Thanks @rzane - I should've been a little more descriptive there. It seems to be a syntax error. Where the old sqeel way worked for the query (but it broke my caching), this suggested baby_squeel syntax seems to not be executing the same query and so I get an arel error. The main error is: The full backtrace is:
|
Okay, so when you're saying: where.has { st_intersects(:latlon, addressable) } That actually translates to: func = Arel::Nodes::NamedFunction.new('st_intersects', [:latlon, addressable])
func.to_sql # Boom! Arel doesn't know how to translate After reviewing RGeo, it seems they're extending Arel::Attributes::Attribute to tech it how to understand this RGeo object. So, I think the right way to write this query would be like so: where.has { latlon.st_intersects(addressable) } This is the same as saying: MyModel.where MyModel.arel_table[:latlon].st_intersects(addressable) |
Thanks again! I actually kept running into the same RGeo / areal error with that suggested syntax but I did find some good old, bare non-squeel or baby_squeel (but horribly ugly) syntax that does work. For the moment, I'm back making forward progress! But for future seekers, maybe we can crack the case of baby_squeel equivalent syntax of this working code. Or perhaps this might actually even be an RGeo issue...
|
How can I get an instance of whatever |
@Siggs2000 - you've probably already gone through this, but when I first did a big ol' migration on a 7,000 commit application from squeel to baby_squeel I got a lot of help from the wiki that @rzane put together. https://github.com/rzane/baby_squeel/wiki/Migrating-from-Squeel If that doesn't help, please do add to the wiki once you've found resolution! |
I have a very similar problem, in squeel this worked:
So I tried your suggestion @rzane
|
I eventually worked out that I could use baby_squeel if I did this:
So I think this is a rgeo-activerecord issue not baby_squeel. Which is why this issue is closed I guess! |
Yeah, sorry for closing. I don't think this is a baby squeel issue, but it would be cool to get it working. It seems like it should be doable 🤷♂️ . I personally don't use RGeo though, so I won't be of much help. If someone figures out a nice, clean solution, it would be cool to add it to the docs. |
I'm tired of battling squeel and was happy to find this! But I'm completely stumped on converting this function into baby_squeel.
In my model, I have this function (it uses some postgis stuff from the rgeo gem)
I was hoping to just change
where
towhere.has
but that didn't seem to work. Thanks in advance for any help on this!I'm running rails 4.2.7
The text was updated successfully, but these errors were encountered: