Topology Maps - Regexp with comma failed #485

Closed
opened 2025-12-29 16:22:35 +01:00 by adam · 0 comments
Owner

Originally created by @kryskool on GitHub (Oct 22, 2016).

Hi

Thanks for this great app.

I found an issue with this Regexp when i would like to find Switch1 to Switch999

Switch[0-9]{1,3}

When the ligne is split with comma to compose the topology map, it failed with this message

Exception Type: DataError
Exception Value: ERREUR:  expression rationnelle invalide : braces {} not balanced

params (u'(Switch){1',)
self    <django.db.backends.utils.CursorDebugWrapper object at 0xb4906a6c>

sql u'SELECT (CAST(SUBSTRING(dcim_device.name FROM \'(\\d+)$\') AS integer)) AS "_dcim_device_name3", (SUBSTRING(dcim_device.name FROM \'^\\d*(.*?)\\d*$\')) AS "_dcim_device_name2", (CAST(SUBSTRING(dcim_device.name FROM \'^(\\d+)\') AS integer)) AS "_dcim_device_name1", "dcim_device"."id", "dcim_device"."created", "dcim_device"."last_updated", "dcim_device"."device_type_id", "dcim_device"."device_role_id", "dcim_device"."tenant_id", "dcim_device"."platform_id", "dcim_device"."name", "dcim_device"."serial", "dcim_device"."asset_tag", "dcim_device"."rack_id", "dcim_device"."position", "dcim_device"."face", "dcim_device"."status", "dcim_device"."primary_ip4_id", "dcim_device"."primary_ip6_id", "dcim_device"."comments" FROM "dcim_device" WHERE "dcim_device"."name"::text ~ %s ORDER BY "_dcim_device_name1" ASC, "_dcim_device_name2" ASC, "_dcim_device_name3" ASC'

I think the comma must be replace by semicolon ; as the line separator (because semicolon is a reserve character in SQL and not use as part of the regexp)

A migration script can migrate all existings regexp with no problem

Regards,

Originally created by @kryskool on GitHub (Oct 22, 2016). Hi Thanks for this great app. I found an issue with this Regexp when i would like to find **Switch1** to **Switch999** ``` Switch[0-9]{1,3} ``` When the ligne is split with comma to compose the topology map, it failed with this message ``` Exception Type: DataError Exception Value: ERREUR: expression rationnelle invalide : braces {} not balanced params (u'(Switch){1',) self <django.db.backends.utils.CursorDebugWrapper object at 0xb4906a6c> sql u'SELECT (CAST(SUBSTRING(dcim_device.name FROM \'(\\d+)$\') AS integer)) AS "_dcim_device_name3", (SUBSTRING(dcim_device.name FROM \'^\\d*(.*?)\\d*$\')) AS "_dcim_device_name2", (CAST(SUBSTRING(dcim_device.name FROM \'^(\\d+)\') AS integer)) AS "_dcim_device_name1", "dcim_device"."id", "dcim_device"."created", "dcim_device"."last_updated", "dcim_device"."device_type_id", "dcim_device"."device_role_id", "dcim_device"."tenant_id", "dcim_device"."platform_id", "dcim_device"."name", "dcim_device"."serial", "dcim_device"."asset_tag", "dcim_device"."rack_id", "dcim_device"."position", "dcim_device"."face", "dcim_device"."status", "dcim_device"."primary_ip4_id", "dcim_device"."primary_ip6_id", "dcim_device"."comments" FROM "dcim_device" WHERE "dcim_device"."name"::text ~ %s ORDER BY "_dcim_device_name1" ASC, "_dcim_device_name2" ASC, "_dcim_device_name3" ASC' ``` I think the comma must be replace by semicolon **;** as the line separator (because semicolon is a reserve character in SQL and not use as part of the regexp) A migration script can migrate all existings regexp with no problem Regards,
adam added the type: bug label 2025-12-29 16:22:35 +01:00
adam closed this issue 2025-12-29 16:22:35 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#485