fix(tradein-estimator): restore CAST in IS NOT NULL predicates (revert audit #9, prod fix) #518
1 changed files with 4 additions and 4 deletions
|
|
@ -881,13 +881,13 @@ def _fetch_analogs(
|
||||||
-- без типа → PostgreSQL "could not determine data type of parameter"
|
-- без типа → PostgreSQL "could not determine data type of parameter"
|
||||||
-- (AmbiguousParameter). Явный тип снимает неоднозначность.
|
-- (AmbiguousParameter). Явный тип снимает неоднозначность.
|
||||||
+ CASE
|
+ CASE
|
||||||
WHEN :target_year IS NOT NULL
|
WHEN CAST(:target_year AS integer) IS NOT NULL
|
||||||
AND year_built IS NOT NULL
|
AND year_built IS NOT NULL
|
||||||
THEN abs(year_built - CAST(:target_year AS integer)) / 12.0
|
THEN abs(year_built - CAST(:target_year AS integer)) / 12.0
|
||||||
ELSE 0
|
ELSE 0
|
||||||
END
|
END
|
||||||
+ CASE
|
+ CASE
|
||||||
WHEN :target_house_type IS NOT NULL
|
WHEN CAST(:target_house_type AS text) IS NOT NULL
|
||||||
AND house_type IS NOT NULL
|
AND house_type IS NOT NULL
|
||||||
AND house_type <> CAST(:target_house_type AS text)
|
AND house_type <> CAST(:target_house_type AS text)
|
||||||
THEN 1.5
|
THEN 1.5
|
||||||
|
|
@ -900,13 +900,13 @@ def _fetch_analogs(
|
||||||
ST_Distance(geom::geography, ST_MakePoint(:lon, :lat)::geography)
|
ST_Distance(geom::geography, ST_MakePoint(:lon, :lat)::geography)
|
||||||
/ 1000.0
|
/ 1000.0
|
||||||
+ CASE
|
+ CASE
|
||||||
WHEN :target_year IS NOT NULL
|
WHEN CAST(:target_year AS integer) IS NOT NULL
|
||||||
AND year_built IS NOT NULL
|
AND year_built IS NOT NULL
|
||||||
THEN abs(year_built - CAST(:target_year AS integer)) / 12.0
|
THEN abs(year_built - CAST(:target_year AS integer)) / 12.0
|
||||||
ELSE 0
|
ELSE 0
|
||||||
END
|
END
|
||||||
+ CASE
|
+ CASE
|
||||||
WHEN :target_house_type IS NOT NULL
|
WHEN CAST(:target_house_type AS text) IS NOT NULL
|
||||||
AND house_type IS NOT NULL
|
AND house_type IS NOT NULL
|
||||||
AND house_type <> CAST(:target_house_type AS text)
|
AND house_type <> CAST(:target_house_type AS text)
|
||||||
THEN 1.5
|
THEN 1.5
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue