JourneyToSilius commented on issue #1635:
URL: https://github.com/apache/age/issues/1635#issuecomment-2146281375
@NathanFrund here is a demo implementation of how I did it in Go:
```
func (s *store) CreateUniquePropertyFunction() error {
queryFormat := `CREATE OR REPLACE FUNCTION
graph.aggregated.get_vertex_address(properties agtype)
RETURNS agtype
AS
$BODY$
SELECT graph.ag_catalog.agtype_access_operator($1, '"address"');
$BODY$
LANGUAGE sql
IMMUTABLE;`
_, err := s.AgePoolConnector.Pool.Exec(context.Background(),
queryFormat)
if err != nil {
return fmt.Errorf("failed to execute query: %v", err)
}
return nil
}
func (s *store) CreateUniqueVertexConstraint() error {
queryFormat := `CREATE UNIQUE INDEX idx_v2vertex_address_constraint ON
graph.aggregated.v2vertex(get_vertex_address(properties));`
_, err := s.AgePoolConnector.Pool.Exec(context.Background(),
queryFormat)
if err != nil {
return handleQueryError(err)
}
return nil
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]