-
Notifications
You must be signed in to change notification settings - Fork 970
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: drop trigram index on identifiers (#3827)
- Loading branch information
Showing
8 changed files
with
53 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
4 changes: 4 additions & 0 deletions
4
...ence/sql/migrations/sql/20240318143139000000_drop_identity_search_index.postgres.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CREATE EXTENSION IF NOT EXISTS pg_trgm; | ||
CREATE EXTENSION IF NOT EXISTS btree_gin; | ||
|
||
CREATE INDEX identity_credential_identifiers_nid_identifier_gin ON identity_credential_identifiers USING GIN (nid, identifier gin_trgm_ops); |
1 change: 1 addition & 0 deletions
1
...stence/sql/migrations/sql/20240318143139000000_drop_identity_search_index.postgres.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP INDEX identity_credential_identifiers_nid_identifier_gin; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright © 2024 Ory Corp | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package x | ||
|
||
import "strings" | ||
|
||
func EscapeLikePattern(s string) string { | ||
return strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(s, "\\", "\\\\"), "%", "\\%"), "_", "\\_") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright © 2024 Ory Corp | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package x | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestEscapeLikePattern(t *testing.T) { | ||
for name, tc := range map[string]struct { | ||
input string | ||
expected string | ||
}{ | ||
"empty": { | ||
input: "", | ||
expected: "", | ||
}, | ||
"no escape": { | ||
input: "foo", | ||
expected: "foo", | ||
}, | ||
"escape": { | ||
input: "foo%bar_baz\\", | ||
expected: "foo\\%bar\\_baz\\\\", | ||
}, | ||
} { | ||
t.Run(name, func(t *testing.T) { | ||
require.Equal(t, tc.expected, EscapeLikePattern(tc.input)) | ||
}) | ||
} | ||
} |