mirror of
https://github.com/maplibre/martin.git
synced 2024-12-20 05:11:57 +03:00
rewrite tilesets query using pg_catalog
This commit is contained in:
parent
2ca5715fcb
commit
680cc507a3
@ -45,7 +45,6 @@ pub fn chain(conn_string: String, cache_size: usize) -> iron::Chain {
|
|||||||
let conn = pool.get().unwrap();
|
let conn = pool.get().unwrap();
|
||||||
let tilesets = tileset::get_tilesets(conn).unwrap();
|
let tilesets = tileset::get_tilesets(conn).unwrap();
|
||||||
chain.link(Read::<tileset::Tilesets>::both(tilesets));
|
chain.link(Read::<tileset::Tilesets>::both(tilesets));
|
||||||
|
|
||||||
chain.link(Read::<db::DB>::both(pool));
|
chain.link(Read::<db::DB>::both(pool));
|
||||||
},
|
},
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
|
@ -108,11 +108,22 @@ fn value_to_hashmap(value: serde_json::Value) -> HashMap<String, String> {
|
|||||||
|
|
||||||
pub fn get_tilesets(conn: PostgresConnection) -> Result<HashMap<String, Tileset>, Box<Error>> {
|
pub fn get_tilesets(conn: PostgresConnection) -> Result<HashMap<String, Tileset>, Box<Error>> {
|
||||||
let query = "
|
let query = "
|
||||||
|
WITH columns AS (
|
||||||
|
SELECT
|
||||||
|
ns.nspname AS table_schema,
|
||||||
|
class.relname AS table_name,
|
||||||
|
attr.attname AS column_name,
|
||||||
|
trim(leading '_' from tp.typname) AS type_name
|
||||||
|
FROM pg_attribute attr
|
||||||
|
JOIN pg_catalog.pg_class AS class ON class.oid = attr.attrelid
|
||||||
|
JOIN pg_catalog.pg_namespace AS ns ON ns.oid = class.relnamespace
|
||||||
|
JOIN pg_catalog.pg_type AS tp ON tp.typelem = attr.atttypid
|
||||||
|
WHERE NOT attr.attisdropped AND attr.attnum > 0)
|
||||||
SELECT
|
SELECT
|
||||||
f_table_schema, f_table_name, f_geometry_column, srid, type,
|
f_table_schema, f_table_name, f_geometry_column, srid, type,
|
||||||
json_object_agg(columns.column_name, columns.udt_name) as properties
|
jsonb_object_agg(columns.column_name, columns.type_name) as properties
|
||||||
FROM geometry_columns
|
FROM geometry_columns
|
||||||
LEFT JOIN information_schema.columns AS columns ON
|
LEFT JOIN columns ON
|
||||||
geometry_columns.f_table_schema = columns.table_schema AND
|
geometry_columns.f_table_schema = columns.table_schema AND
|
||||||
geometry_columns.f_table_name = columns.table_name AND
|
geometry_columns.f_table_name = columns.table_name AND
|
||||||
geometry_columns.f_geometry_column != columns.column_name
|
geometry_columns.f_geometry_column != columns.column_name
|
||||||
|
Loading…
Reference in New Issue
Block a user