Skip to content

Instantly share code, notes, and snippets.

@jhawthorn
Last active March 9, 2016 00:36
Show Gist options
  • Save jhawthorn/2ac7344d7c27ee4a47ec to your computer and use it in GitHub Desktop.
Save jhawthorn/2ac7344d7c27ee4a47ec to your computer and use it in GitHub Desktop.
SELECT DISTINCT "spree_shipping_methods".*
FROM "spree_shipping_methods"
INNER JOIN "spree_shipping_method_categories"
ON "spree_shipping_method_categories"."shipping_method_id" =
"spree_shipping_methods"."id"
INNER JOIN "spree_ship ping_method_zones"
ON "spree_shipping_method_zones"."shipping_method_id" =
"spree_shipping_methods"."id"
INNER JOIN "spree_zones"
ON "spree_zones"."id" = "spree_shipping_method_zones"."zone_id"
LEFT OUTER JOIN "spree_zone_members"
ON "spree_zone_members"."zone_id" = "spree_zones"."id"
LEFT OUTER JOIN "spree_shipping_method_stock_locations"
ON "spree_shipping_methods"."id" =
"spree_shipping_method_stock_locations"."shipping_method_id"
WHERE "spree_shipping_methods"."deleted_at" IS NULL
AND "spree_shipping_method_categories"."shipping_category_id" = 1
AND ( "spree_shipping_methods"."available_to_all" = 't'
OR "spree_shipping_method_stock_locations"."stock_location_id" = 1
)
AND ( ( spree_zone_members.zoneable_type = 'Spree::State'
AND spree_zone_members.zoneable_id IN ( 3561 ) )
OR ( spree_zone_members.zoneable_type = 'Spree::Country'
AND spree_zone_members.zoneable_id IN ( 232 ) ) )
GROUP BY spree_shipping_methods.id
HAVING Count(DISTINCT "spree_shipping_method_categories"."id") = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment