node.js - Sequelize WHERE sequelize.fn(...) AND something='something' ordering issue -
i have sequelize findone function looks select row given point intersects polygon (col 'geom') , status = 'active'.
var point = sequelize.fn('st_geomfromtext', 'point(' + lng + ' ' + lat +')', 4326); var intersects = sequelize.fn('st_intersects', sequelize.col('geom'), point); geocounty.findone({ attributes: ['id', 'name' ], where: { status: 'active', $and: intersects }, plain: true })
as of right now, works fine. produces sql looks like:
select "id", "name" "geocounty" "geocounty" "geocounty"."status" = 'active' , (st_intersects("geom", st_geomfromtext('point(-98.025006 43.714735)', 4326))) limit 1;
what want is:
select "id", "name" "geocounty" "geocounty" (st_intersects("geom", st_geomfromtext('point(-98.025006 43.714735)', 4326))) , "geocounty"."status" = 'active' limit 1;
which st_intersects clause comes first , and status='active' comes after.
my questions are:
1. there sort of performance penalty executing query first way work? 2. there way structure clause in sequelize?
this not work:
geocounty.findone({ attributes: ['id', 'name' ], where: { intersects, $and: { status: 'active' } }, plain: true })
it produces sql:
select "id", "name" "geocounty" "geocounty" "geocounty"."intersects" = st_intersects("geom", st_geomfromtext('point(-98.025006 43.714735)', 4326)) , ("geocounty"."status" = 'active') limit 1;
there no geocounty.intersects...
Comments
Post a Comment