Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to update the data #280

Closed
Arunkumar-hockey opened this issue Jul 11, 2024 · 5 comments
Closed

Unable to update the data #280

Arunkumar-hockey opened this issue Jul 11, 2024 · 5 comments

Comments

@Arunkumar-hockey
Copy link

Arunkumar-hockey commented Jul 11, 2024

func (repo JourneyRepo) UpdateJourneyByID(c context.Context, journey models.Journey) (*models.Journey, error) {
	// API tracing enabling
	if span := tracing.TraceSpan(c, "journeyRepo.UpdateJourneyByID"); span != nil {
		defer span.End()
	}

	session := repo.GetScyllaDBConnection()

	// Start building the update query
	updStmt := qb.Update("journeys").
		Set("name", "status", "segment_id", "tags", "flow_json", "updated_by", "updated_at").
		Where(qb.Eq("id"), qb.Eq("client_ref_number"))

	// Convert to CQL statement
	update, names := updStmt.ToCql()

	// Create a map for the bind parameters
	bindMap := qb.M{
		"id":                journey.ID,
		"client_ref_number": journey.ClientRefNumber,
		"name":              journey.Name,
		"status":            journey.Status,
		"segment_id":        journey.SegmentId,
		"tags":              journey.Tags,
		"flow_json":         journey.FlowJSON,
		"updated_by":        journey.UpdatedBy,
		"updated_at":        journey.UpdatedAt,
	}

	// Execute the update query
	if err := gocqlx.Query(session.Query(update), names).BindMap(bindMap).ExecRelease(); err != nil {
		return nil, err
	}

	// Return the updated journey
	return &journey, nil
}

A error is coming "Cannot execute this query as it might involve data filtering and thus may have unpredictable performance. If you want to execute this query despite the performance unpredictability, use ALLOW FILTERING". Unable to call AllowFiltering(). function.

@sylwiaszunejko
Copy link
Collaborator

Please reformat your issue description, it seems to be broken and provide steps to reproduce your issue

@dkropachev
Copy link
Collaborator

dkropachev commented Sep 6, 2024

func (repo JourneyRepo) UpdateJourneyByID(c context.Context, journey models.Journey) (*models.Journey, error) {
	// API tracing enabling
	if span := tracing.TraceSpan(c, "journeyRepo.UpdateJourneyByID"); span != nil {
		defer span.End()
	}

	session := repo.GetScyllaDBConnection()

	// Start building the update query
	updStmt := qb.Update("journeys").
		Set("name", "status", "segment_id", "tags", "flow_json", "updated_by", "updated_at").
		Where(qb.Eq("id"), qb.Eq("client_ref_number"))

	// Convert to CQL statement
	update, names := updStmt.ToCql()

	// Create a map for the bind parameters
	bindMap := qb.M{
		"id":                journey.ID,
		"client_ref_number": journey.ClientRefNumber,
		"name":              journey.Name,
		"status":            journey.Status,
		"segment_id":        journey.SegmentId,
		"tags":              journey.Tags,
		"flow_json":         journey.FlowJSON,
		"updated_by":        journey.UpdatedBy,
		"updated_at":        journey.UpdatedAt,
	}

	// Execute the update query
	if err := gocqlx.Query(session.Query(update), names).BindMap(bindMap).ExecRelease(); err != nil {
		return nil, err
	}

	// Return the updated journey
	return &journey, nil
}

A error is coming "Cannot execute this query as it might involve data filtering and thus may have unpredictable performance. If you want to execute this query despite the performance unpredictability, use ALLOW FILTERING". Unable to call AllowFiltering(). function.

Just let you know that mostly it is because of problem on data layout.
But to make it happen you can add ALLOW FILTERING to the end of the query:

	// Execute the update query
	if err := gocqlx.Query(session.Query(update + ` ALLOW FILTERING`), names).BindMap(bindMap).ExecRelease(); err != nil {
		return nil, err
	}

But you are correct we should add this feature.

@dkropachev
Copy link
Collaborator

Question is answered, for add allow filtering api I have created separate issue.

@Arunkumar-hockey
Copy link
Author

Arunkumar-hockey commented Sep 7, 2024 via email

@dkropachev
Copy link
Collaborator

@Arunkumar-hockey , thanks, documentation issues will be addressed here, please feel free to add more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants