AdrienVH / carthapirates

CarthaPirates est une application utilisée dans le cadre des cours d'Algorithmie et de Programmation assurés au sein du Master 2 Carthagéo
0 stars 0 forks source link

ROW_NUMBER retourne une string (et non un int) #18

Open AdrienVH opened 1 year ago

AdrienVH commented 1 year ago

Devrait retourner un bigint selon la doc : https://www.postgresql.org/docs/current/functions-window.html Mais le JSON retourné par l'API contient une string...

AdrienVH commented 1 year ago
const sql = `
SELECT id, id_bateau, date, geom, ROW_NUMBER () OVER (PARTITION BY id_bateau ORDER BY id ASC) AS ordre
FROM trajets
WHERE id_bateau = :idBateau AND geom IS NOT NULL;
`
const trajets = await sequelize.query(sql, { replacements: { idBateau }, type: QueryTypes.SELECT })
console.log(trajets)
[
  {
    id: 10,
    id_bateau: 0,
    date: '2022-12-14',
    geom: { crs: [Object], type: 'LineString', coordinates: [Array] },
    ordre: '1'
  },
  {
    id: 11,
    id_bateau: 0,
    date: '2022-12-14',
    geom: { crs: [Object], type: 'LineString', coordinates: [Array] },
    ordre: '2'
  }
]