You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am updating the availability in the following manner:
(node_obj is py2neo Node object that is directly linked to Node 35682)
local_links = graph.relationships.match((node_obj,))
int_nodes = [link.nodes[1]
for link in local_links]
for interface in int_nodes:
interface['available'] = False
graph.push(interface)
The result from this code is: (_35682:LinkId {available: false})
All other data or attributes are wiped in the neo4j database for this node.
Anytime I run through the process by hand and view the results and objects the code works as expected. Only faults when all lines run together.
I have worked around this issue with the following update :
local_links = graph.relationships.match((node_obj,))
int_nodes = [link.nodes[1]
for link in local_links]
for interface in int_nodes:
graph.pull(interface)
interface['available'] = False
graph.push(interface)
Not sure if this is expected behavior, I'm fairly new to this library but seems odd that data is loss with no exceptions or warnings. Any guidance is appreciated.
Hit issue with version: py2neo (4.3.0)
The text was updated successfully, but these errors were encountered:
To avoid this issue, you should ensure that all attributes of the node are loaded before updating it. You can do this by explicitly pulling the node data from the database before making any changes. Your workaround using graph.pull(interface) is correct, but let's refine it a bit:
from py2neo import Graph
# Assuming `graph` is your Graph object and `node_obj` is the node you're starting from
local_links = graph.relationships.match((node_obj,))
int_nodes = [link.nodes[1] for link in local_links]
for interface in int_nodes:
# Pull the latest data from the database to ensure all attributes are loaded
graph.pull(interface)
# Update the 'available' attribute
interface['available'] = False
# Push the updated node back to the database
graph.push(interface)
Explanation of the Solution:
graph.pull(interface): This ensures that the interface object has all the latest attributes from the database.
interface['available'] = False: This updates the available attribute.
graph.push(interface): This pushes the updated node back to the database, ensuring that all attributes are preserved.
I have nodes with a few attributes for example:
(_35682:LinkId {available: true, interface: '0/0/44', ip: '1.1.1.1', visible: true, x: 5, y: 5})
I am updating the availability in the following manner:
(node_obj is py2neo Node object that is directly linked to Node 35682)
The result from this code is:
(_35682:LinkId {available: false})
All other data or attributes are wiped in the neo4j database for this node.
Anytime I run through the process by hand and view the results and objects the code works as expected. Only faults when all lines run together.
I have worked around this issue with the following update :
Not sure if this is expected behavior, I'm fairly new to this library but seems odd that data is loss with no exceptions or warnings. Any guidance is appreciated.
Hit issue with version: py2neo (4.3.0)
The text was updated successfully, but these errors were encountered: