lovasoa / SQLpage

SQL-only webapp builder, empowering data analysts to build websites and applications quickly
https://sql.datapage.app
MIT License
1.29k stars 69 forks source link

Invalid GeoJSON object #129

Closed cornerot closed 9 months ago

cornerot commented 9 months ago

Hi!

I get "Invalid GeoJSON object" error when running the map example from the tutorial: 2023-11-10T18:29:08,833894328+03:00

cat map.sql

select
    'map'   as component,
    'Paris' as title,
    11      as zoom,
    48.85   as latitude,
    2.34    as longitude,
    400     as height;
select
    'Notre Dame'             as title,
    'building-castle'        as icon,
    'indigo'                 as color,
    48.853                   as latitude,
    2.3498                   as longitude,
    'A beautiful cathedral.' as description_md,
    'https://en.wikipedia.org/wiki/Notre-Dame_de_Paris' as link;
select
    'Eiffel Tower' as title,
    'tower'        as icon,
    'yellow'       as color,
    48.8584        as latitude,
    2.2945         as longitude,
    'A tall tower. [Wikipedia](https://en.wikipedia.org/wiki/Eiffel_Tower)' as description_md;
select
    'Tower to Cathedral'      as title,
    JSON('{"type":"LineString","coordinates":[[2.2945,48.8584],[2.3498,48.8530]]}') as geojson,
    'teal'                    as color,
    'A nice 45 minutes walk.' as description;
lovasoa commented 9 months ago

Hi ! Which database are you using ? Does it work when passing the json object as a string ('{"type":"LineString","coordinates":[[2.2945,48.8584],[2.3498,48.8530]]} as geojson) ?

cornerot commented 9 months ago

I don't use a database. Just created the sql file from the tutorial. The error is the same as with

JSON('{"type":"LineString","coordinates":[[2.2945,48.8584],[2.3498,48.8530]]}') as geojson

or

'{"type":"LineString","coordinates":[[2.2945,48.8584],[2.3498,48.8530]]}' as geojson
lovasoa commented 9 months ago

Thank you for the precision. SQLPage is always connected to a database, but if you haven't explicitly configured any database connection, then you are using the default embedded SQLite database.

The bug only happens with databases that do not have native json objects. I can reproduce it locally; I'll fix it and release a new version shortly. Thanks for the report !

lovasoa commented 9 months ago

v0.15.2 was just released with the fix : https://github.com/lovasoa/SQLpage/releases/tag/v0.15.2