Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Squeel breaks AR Hash conditions #116

Closed
dnagir opened this issue Apr 19, 2012 · 3 comments
Closed

Squeel breaks AR Hash conditions #116

dnagir opened this issue Apr 19, 2012 · 3 comments

Comments

@dnagir
Copy link

dnagir commented Apr 19, 2012

Before adding squeel I had this query:

Property.joins(:reservations).
  where(properties: {status: :reserved}).
  where(reservations: {status: :active, reservation_type: :online_payment, reservation_fee_received: false}).
  where("reservations.fee_due_at < ?", DateTime.now)

it breaks now with:

ActiveRecord::StatementInvalid:
       PG::Error: ERROR:  column properties.reserved does not exist
       LINE 1: ...= "properties"."id" WHERE "properties"."status" = "propertie...
                                                                    ^
       : SELECT properties.id FROM "properties" INNER JOIN "reservations" ON "reservations"."property_id" = "properties"."id" WHERE "properties"."status" = "properties"."reserved" AND (("reservations"."status" = "reservations"."active" AND "reservations"."reservation_type" = "reservations"."online_payment" AND "reservations"."reservation_fee_received" = 'f')) AND (reservations.fee_due_at < '2012-04-21 06:22:20')

Apparently, squeel seems to bea bit intrusive changing some of the AR behaviour.

I guess there's something to do with the nested Hash conditions.

But hey, apart from this it was a drop-in add-on for AR. I must have been lucky :)

@ernie
Copy link
Contributor

ernie commented Apr 19, 2012

It's not the hash conditions but the symbol values. If you change them
to strings you should be fine.

Sent from my iPhone

On Apr 19, 2012, at 1:25 AM, Dmytrii Nagirniak
[email protected]
wrote:

Before adding squeel I had this query:

Property.joins(:reservations).
 where(properties: {status: :reserved}).
 where(reservations: {status: :active, reservation_type: :online_payment, reservation_fee_received: false}).
 where("reservations.fee_due_at < ?", DateTime.now)

it breaks now with:

ActiveRecord::StatementInvalid:
      PG::Error: ERROR:  column properties.reserved does not exist
      LINE 1: ...= "properties"."id" WHERE "properties"."status" = "propertie...
                                                                   ^
      : SELECT properties.id FROM "properties" INNER JOIN "reservations" ON "reservations"."property_id" = "properties"."id" WHERE "properties"."status" = "properties"."reserved" AND (("reservations"."status" = "reservations"."active" AND "reservations"."reservation_type" = "reservations"."online_payment" AND "reservations"."reservation_fee_received" = 'f')) AND (reservations.fee_due_at < '2012-04-21 06:22:20')

Apparently, squeel seems to bea bit intrusive changing some of the AR behaviour.

I guess there's something to do with the nested Hash conditions.

But hey, apart from this it was a drop-in add-on for AR. I must have been lucky :)


Reply to this email directly or view it on GitHub:
#116

@dnagir
Copy link
Author

dnagir commented Apr 19, 2012

Gosh. The same thing again :(
Those #67, #75 keep popping again and again.

Thanks and sorry for the "invalid" issue.

@ernie
Copy link
Contributor

ernie commented Apr 19, 2012

good call. I'm actually gonna get this on the common issues wiki.

@ernie ernie closed this as completed Apr 19, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants