fix: weapon_type filter uses subquery instead of rd table reference
The rd table is only available inside the CTE, not in the outer WHERE. Use EXISTS subquery against item_raw_data for skill-based weapon type filtering (same pattern as spell_contains fix). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9749eafde4
commit
7f7595b5b6
1 changed files with 5 additions and 9 deletions
|
|
@ -3245,15 +3245,11 @@ async def search_items(
|
||||||
# Weapons: ObjectClass 1 (MeleeWeapon), 9 (MissileWeapon), 31 (WandStaffOrb)
|
# Weapons: ObjectClass 1 (MeleeWeapon), 9 (MissileWeapon), 31 (WandStaffOrb)
|
||||||
if weapon_type:
|
if weapon_type:
|
||||||
wt = weapon_type.lower()
|
wt = weapon_type.lower()
|
||||||
# Skill-based: Heavy=44, Light=45, Finesse=46, TwoHanded=41
|
# Skill-based: use subquery against item_raw_data (rd not available in outer query)
|
||||||
if wt == 'heavy':
|
# Heavy=44, Light=45, Finesse=46, TwoHanded=41
|
||||||
conditions.append("(object_class = 1 AND (rd.int_values->>'218103840')::int = 44)")
|
skill_map = {'heavy': 44, 'light': 45, 'finesse': 46, 'two_handed': 41}
|
||||||
elif wt == 'light':
|
if wt in skill_map:
|
||||||
conditions.append("(object_class = 1 AND (rd.int_values->>'218103840')::int = 45)")
|
conditions.append(f"(object_class = 1 AND EXISTS (SELECT 1 FROM item_raw_data wrd WHERE wrd.item_id = db_item_id AND (wrd.int_values->>'218103840')::int = {skill_map[wt]}))")
|
||||||
elif wt == 'finesse':
|
|
||||||
conditions.append("(object_class = 1 AND (rd.int_values->>'218103840')::int = 46)")
|
|
||||||
elif wt == 'two_handed':
|
|
||||||
conditions.append("(object_class = 1 AND (rd.int_values->>'218103840')::int = 41)")
|
|
||||||
# Name-based missile sub-types
|
# Name-based missile sub-types
|
||||||
elif wt == 'bow':
|
elif wt == 'bow':
|
||||||
conditions.append("(object_class = 9 AND name ILIKE '%bow%' AND name NOT ILIKE '%crossbow%')")
|
conditions.append("(object_class = 9 AND name ILIKE '%bow%' AND name NOT ILIKE '%crossbow%')")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue