Skip to content

Commit 227474f

Browse files
committed
fix: build correct model
1 parent 70ca9da commit 227474f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/charms/data_platform_libs/v1/data_interfaces.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,22 +2505,22 @@ def _is_pg_plugin_enabled(plugin: str, connection_string: str) -> bool:
25052505
)
25062506
return False
25072507

2508-
def is_postgresql_plugin_enabled(self, plugin: str, relation_id: int = 0) -> bool:
2508+
def is_postgresql_plugin_enabled(self, plugin: str, relation_index: int = 0) -> bool:
25092509
"""Returns whether a plugin is enabled in the database.
25102510
25112511
Args:
25122512
plugin: name of the plugin to check.
2513-
relation_id: Optional index to check the database (default: 0 - first relation).
2513+
relation_index: Optional index to check the database (default: 0 - first relation).
25142514
"""
25152515
if not psycopg2:
25162516
return False
25172517

25182518
# Can't check a non existing relation.
2519-
if len(self.relations) <= relation_id:
2519+
if len(self.relations) <= relation_index:
25202520
return False
25212521

2522-
relation_id = self.relations[relation_id].id
2523-
model = self.interface.build_model(relation_id=relation_id)
2522+
relation = self.relations[relation_index]
2523+
model = self.interface.build_model(relation_id=relation.id, component=relation.app)
25242524
for request in model.requests:
25252525
if request.endpoints and request.username and request.password:
25262526
host = request.endpoints.split(":")[0]

0 commit comments

Comments
 (0)