I'm using GeoCoder for location based queries. The .Near method from GeoCoder adds a Distance & Bearing column to the select clause which is useful for where and order clauses.
Those columns are fine, but it also adds the current model.* which I'm trying to avoid with a specific column list in the select statement.
The following query and image show the extra additions, the red is what I wish to remove, the yellow is added by GeoCoder, but I'm ok with that.
sql = Shift.scoped
.select("CAST('#{region.name}' AS character(50)) as region, staffrooms.name as staffroom_name, staffrooms.staffroom_type, shifts.id, shifts.title, shifts.shift_type, shifts.status, shifts.location, shifts.uuid")
.visible
.jobs
.joins(:posted_shortlists)
.near([region.latitude, region.longitude], 50)
sql = sql.where("staffrooms.staffroom_type = ?", staffroom_type) if staffroom_type
sql = sql.reorder("staffrooms.name")
How do I remove the shifts.* from the query, my current technique is here, but it seems a bit dodgy to me and does not allow the query to remain as a Relation
sql = sql.gsub("shifts.*, ", "")