1
0
forked from MTSR/mapserver
mapserver/mapobjectdb/postgres/sql.go

59 lines
1.3 KiB
Go
Raw Normal View History

2019-03-21 17:07:09 +03:00
package postgres
const getMapDataPosQuery = `
select o.uid, o.type, o.mtime,
2019-03-21 17:07:09 +03:00
o.x, o.y, o.z,
o.posx, o.posy, o.posz,
oa.key, oa.value
from objects o
left join object_attributes oa on o.uid = oa.object_uid
2019-03-21 17:07:09 +03:00
where o.type = $1
and o.posx >= $2 and o.posy >= $3 and o.posz >= $4
and o.posx <= $5 and o.posy <= $6 and o.posz <= $7
order by o.uid
2020-01-19 17:34:20 +03:00
limit $8
2019-03-21 17:07:09 +03:00
`
const getMapDataWithAttributeLikePosQuery = `
select o.uid, o.type, o.mtime,
o.x, o.y, o.z,
o.posx, o.posy, o.posz,
oa.key, oa.value
from objects o
left join object_attributes oa on o.uid = oa.object_uid
where o.uid in (
select object_uid from object_attributes where key = $8 and value ilike $9
)
and o.type = $1
and o.posx >= $2 and o.posy >= $3 and o.posz >= $4
and o.posx <= $5 and o.posy <= $6 and o.posz <= $7
order by o.uid
2020-01-19 17:34:20 +03:00
limit $10
`
2019-03-21 17:07:09 +03:00
const removeMapDataQuery = `
delete from objects where posx = $1 and posy = $2 and posz = $3
`
const addMapDataQuery = `
insert into
objects(uid, x,y,z,posx,posy,posz,type,mtime)
values($1, $2, $3, $4, $5, $6, $7, $8, $9)
2019-03-21 17:07:09 +03:00
`
const addMapDataAttributeQuery = `
insert into
object_attributes(object_uid, key, value)
2019-03-21 17:07:09 +03:00
values($1, $2, $3)
`
const getSettingQuery = `
select value from settings where key = $1
`
const setSettingQuery = `
insert into settings(key, value)
values($1, $2)
on conflict(key)
do update set value = EXCLUDED.value
`