@@ -152,7 +152,6 @@ querySchemaCache conf@AppConfig{..} = do
152152 reps <- SQL. statement conf $ dataRepresentations prepared
153153 mHdlers <- SQL. statement conf $ mediaHandlers prepared
154154 tzones <- SQL. statement mempty $ timezones prepared
155- hasPgis <- SQL. statement conf $ postgisFunc prepared
156155 _ <-
157156 let sleepCall = SQL. Statement " select pg_sleep($1 / 1000.0)" (param HE. int4) HD. noResult prepared in
158157 whenJust configInternalSCSleep (`SQL.statement` sleepCall) -- only used for testing
@@ -165,7 +164,7 @@ querySchemaCache conf@AppConfig{..} = do
165164 , dbRelationships = getOverrideRelationshipsMap rels cRels
166165 , dbRoutines = funcs
167166 , dbRepresentations = reps
168- , dbMediaHandlers = HM. union mHdlers $ initialMediaHandlers hasPgis -- the custom handlers will override the initial ones
167+ , dbMediaHandlers = HM. union mHdlers initialMediaHandlers -- the custom handlers will override the initial ones
169168 , dbTimezones = tzones
170169 }
171170 where
@@ -1049,14 +1048,12 @@ allViewsKeyDependencies =
10491048 having ncol = array_length(array_agg(row(col.attname, view_columns) order by pks_fks.ord), 1)
10501049 |]
10511050
1052- initialMediaHandlers :: Bool -> MediaHandlerMap
1053- initialMediaHandlers hasPostgisFunc =
1051+ initialMediaHandlers :: MediaHandlerMap
1052+ initialMediaHandlers =
10541053 HM. insert (RelAnyElement , MediaType. MTAny ) (BuiltinOvAggJson , MediaType. MTApplicationJSON ) $
10551054 HM. insert (RelAnyElement , MediaType. MTApplicationJSON ) (BuiltinOvAggJson , MediaType. MTApplicationJSON ) $
10561055 HM. insert (RelAnyElement , MediaType. MTTextCSV ) (BuiltinOvAggCsv , MediaType. MTTextCSV ) $
1057- (if hasPostgisFunc
1058- then HM. insert (RelAnyElement , MediaType. MTGeoJSON ) (BuiltinOvAggGeoJson , MediaType. MTGeoJSON )
1059- else mempty )
1056+ HM. insert (RelAnyElement , MediaType. MTGeoJSON ) (BuiltinOvAggGeoJson , MediaType. MTGeoJSON )
10601057 HM. empty
10611058
10621059mediaHandlers :: Bool -> SQL. Statement AppConfig MediaHandlerMap
@@ -1142,35 +1139,6 @@ timezones = SQL.Statement sql HE.noParams decodeTimezones
11421139 decodeTimezones :: HD. Result TimezoneNames
11431140 decodeTimezones = S. fromList <$> HD. rowList (column HD. text)
11441141
1145-
1146- -- Find the postgis function that has the signature:
1147- -- st_asgeojson(record,...) returns text
1148- postgisFunc :: Bool -> SQL. Statement AppConfig Bool
1149- postgisFunc = SQL. Statement sql params decoder
1150- where
1151- params =
1152- (map escapeIdent . toList . configDbSchemas >$< arrayParam HE. text) <>
1153- (map escapeIdent . toList . configDbExtraSearchPath >$< arrayParam HE. text)
1154- decoder = HD. singleRow (column HD. bool)
1155- sql = encodeUtf8 [trimming |
1156- SELECT
1157- exists(
1158- SELECT
1159- 1
1160- FROM pg_catalog.pg_proc AS p
1161- JOIN pg_catalog.pg_depend AS d
1162- ON d.objid = p.oid
1163- AND d.deptype = 'e'
1164- JOIN pg_catalog.pg_extension AS e
1165- ON e.oid = d.refobjid
1166- WHERE p.pronamespace = ANY($$1::regnamespace[] || $$2::regnamespace[])
1167- AND p.proname = 'st_asgeojson'
1168- AND e.extname = 'postgis'
1169- AND p.proargtypes[0] = 'record'::regtype
1170- AND pg_get_function_result(p.oid) = 'text'
1171- );
1172- |]
1173-
11741142param :: HE. Value a -> HE. Params a
11751143param = HE. param . HE. nonNullable
11761144
0 commit comments