Skip to content

Conversation

@w20k
Copy link

@w20k w20k commented Jun 9, 2025

GORM Raw SQL Method Incorrectly Handles PostgreSQL Full-Text Search Operators

PostgreSQL full-text search operator @@ is not supported in GORM Raw SQL queries with parameterized values due to incorrect parameter binding detection.

// This query contains the @@ operator in the SELECT clause
		err := DB.Raw(`
			SELECT id, name, 
			       to_tsvector('english', name) @@ plainto_tsquery('english', $1) as matches
			FROM users
		`, searchTerm).Scan(&results).Error

Link: go-gorm/gorm#7481

…h with various scenarios and workarounds to address known @@ operator issues;
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

Successfully merging this pull request may close these issues.

1 participant