Skip to content

Commit 02f88fb

Browse files
committed
restore some collation nuances that were lost in the merge
1 parent b32efc1 commit 02f88fb

16 files changed

+60
-60
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import MongoDB
2+
3+
public
4+
protocol DatabaseCollation
5+
{
6+
static
7+
var spec:Mongo.Collation { get }
8+
}

Sources/UnidocDB/DatabaseModel.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,11 @@ import MongoQL
44
public
55
protocol DatabaseModel:Identifiable<Mongo.Database>, Equatable, Sendable
66
{
7-
static
8-
var collation:Mongo.Collation { get }
9-
107
init(id:Mongo.Database)
118

129
func setup(with session:Mongo.Session) async throws
1310
}
1411
extension DatabaseModel
15-
{
16-
@inlinable public static
17-
var collation:Mongo.Collation
18-
{
19-
.init(locale: "simple", normalization: true) // normalize unicode on insert
20-
}
21-
}
22-
extension DatabaseModel
2312
{
2413
public static
2514
func setup(as id:Mongo.Database, in pool:__owned Mongo.SessionPool) async -> Self

Sources/UnidocDB/DatabaseQuery.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import BSONDecoding
22
import MongoDB
33

44
public
5-
protocol DatabaseQuery<Database, Output>:Sendable
5+
protocol DatabaseQuery<Collation, Output>:Sendable
66
{
7-
associatedtype Database:DatabaseModel
7+
associatedtype Collation:DatabaseCollation
88
associatedtype Output:BSONDocumentDecodable
99

1010
func build(pipeline:inout Mongo.Pipeline)
@@ -19,7 +19,7 @@ extension DatabaseQuery
1919
{
2020
.init(self.origin, pipeline: .init(with: self.build(pipeline:)))
2121
{
22-
$0[.collation] = Database.collation
22+
$0[.collation] = Collation.spec
2323
$0[.hint] = self.hint
2424
}
2525
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import MongoDB
2+
3+
@frozen public
4+
struct SimpleCollation:DatabaseCollation
5+
{
6+
@inlinable public static
7+
var spec:Mongo.Collation
8+
{
9+
.init(locale: "simple", normalization: true) // normalize unicode on insert
10+
}
11+
}

Sources/UnidocDB/Packages/UnidocDatabase.Editions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extension UnidocDatabase.Editions:DatabaseCollection
3535
[
3636
.init
3737
{
38-
$0[.collation] = UnidocDatabase.collation
38+
$0[.collation] = SimpleCollation.spec
3939

4040
$0[.unique] = true
4141
$0[.name] = "package,name"

Sources/UnidocDB/Packages/UnidocDatabase.Graphs.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extension UnidocDatabase.Graphs:DatabaseCollection
4343
},
4444
.init
4545
{
46-
$0[.collation] = UnidocDatabase.collation
46+
$0[.collation] = SimpleCollation.spec
4747

4848
$0[.unique] = true // for now...
4949
$0[.name] = "metadata_package,version"

Sources/UnidocDB/Volumes/UnidocDatabase.Groups.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ extension UnidocDatabase.Groups:DatabaseCollection
2525
static
2626
let indexes:[Mongo.CreateIndexStatement] =
2727
[
28-
// .init
29-
// {
30-
// $0[.unique] = true
31-
// $0[.name] = "id,latest"
32-
// $0[.key] = .init
33-
// {
34-
// $0[Volume.Group[.id]] = (+)
35-
// $0[Volume.Group[.latest]] = (-)
36-
// }
37-
// },
3828
.init
3929
{
4030
$0[.unique] = false

Sources/UnidocDB/Volumes/UnidocDatabase.Names.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extension UnidocDatabase.Names:DatabaseCollection
5757
$0[.unique] = true
5858
$0[.name] = "package,patch"
5959

60-
$0[.collation] = UnidocDatabase.collation
60+
$0[.collation] = VolumeCollation.spec
6161
$0[.key] = .init
6262
{
6363
$0[Volume.Names[.package]] = (+)
@@ -73,7 +73,7 @@ extension UnidocDatabase.Names:DatabaseCollection
7373
$0[.unique] = true
7474
$0[.name] = "package,version"
7575

76-
$0[.collation] = UnidocDatabase.collation
76+
$0[.collation] = VolumeCollation.spec
7777
$0[.key] = .init
7878
{
7979
$0[Volume.Names[.package]] = (+)

Sources/UnidocDB/Volumes/UnidocDatabase.Vertices.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extension UnidocDatabase.Vertices:DatabaseCollection
3939
$0[.unique] = true
4040
$0[.name] = "zone,stem,hash"
4141

42-
$0[.collation] = UnidocDatabase.collation
42+
$0[.collation] = VolumeCollation.spec
4343
$0[.key] = .init
4444
{
4545
$0[Volume.Vertex[.zone]] = (+)
@@ -58,7 +58,7 @@ extension UnidocDatabase.Vertices:DatabaseCollection
5858
$0[.unique] = true
5959
$0[.name] = "hash,id"
6060

61-
$0[.collation] = UnidocDatabase.collation
61+
$0[.collation] = VolumeCollation.spec
6262
$0[.key] = .init
6363
{
6464
$0[Volume.Vertex[.hash]] = (+)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import MongoDB
2+
3+
@frozen public
4+
struct VolumeCollation:DatabaseCollation
5+
{
6+
@inlinable public static
7+
var spec:Mongo.Collation
8+
{
9+
.init(locale: "en", // casing is a property of english, not unicode
10+
caseLevel: false, // url paths are case-insensitive
11+
normalization: true, // normalize unicode on insert
12+
strength: .secondary) // diacritics are significant
13+
}
14+
}

0 commit comments

Comments
 (0)