Skip to content

Commit 7fec41a

Browse files
authored
feat(connections): add CockroachDB/ScyllaDB/Turso constants to TableProModels.DatabaseType for desktop parity (#1494)
1 parent 2559641 commit 7fec41a

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

Packages/TableProCore/Sources/TableProModels/DatabaseType.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public struct DatabaseType: Hashable, Codable, Sendable, RawRepresentable {
2626
public static let dynamodb = DatabaseType(rawValue: "DynamoDB")
2727
public static let bigquery = DatabaseType(rawValue: "BigQuery")
2828
public static let libsql = DatabaseType(rawValue: "libSQL")
29+
public static let cockroachdb = DatabaseType(rawValue: "CockroachDB")
30+
public static let scylladb = DatabaseType(rawValue: "ScyllaDB")
31+
public static let turso = DatabaseType(rawValue: "Turso")
2932

3033
public static let allKnownTypes: [DatabaseType] = [
3134
.mysql, .mariadb, .postgresql, .sqlite, .redis, .mongodb,

Packages/TableProCore/Tests/TableProModelsTests/DatabaseTypeTests.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,30 @@ struct DatabaseTypeTests {
6464
set.insert(DatabaseType(rawValue: "MySQL"))
6565
#expect(set.count == 2)
6666
}
67+
68+
@Test("Desktop-recognized constants have correct raw values")
69+
func desktopConstants() {
70+
#expect(DatabaseType.cockroachdb.rawValue == "CockroachDB")
71+
#expect(DatabaseType.scylladb.rawValue == "ScyllaDB")
72+
#expect(DatabaseType.turso.rawValue == "Turso")
73+
}
74+
75+
@Test("Desktop-recognized constants stay out of the built-in allKnownTypes list")
76+
func desktopConstantsNotInAllKnownTypes() {
77+
#expect(!DatabaseType.allKnownTypes.contains(.cockroachdb))
78+
#expect(!DatabaseType.allKnownTypes.contains(.scylladb))
79+
#expect(!DatabaseType.allKnownTypes.contains(.turso))
80+
}
81+
82+
@Test("Decodes a persisted connection type string")
83+
func decodesPersistedTypeString() throws {
84+
let decoded = try JSONDecoder().decode(DatabaseType.self, from: Data("\"MySQL\"".utf8))
85+
#expect(decoded == .mysql)
86+
}
87+
88+
@Test("Decodes an unknown persisted type string without loss")
89+
func decodesUnknownPersistedTypeString() throws {
90+
let decoded = try JSONDecoder().decode(DatabaseType.self, from: Data("\"FutureDB\"".utf8))
91+
#expect(decoded.rawValue == "FutureDB")
92+
}
6793
}

0 commit comments

Comments
 (0)