Skip to content

Commit

Permalink
Add some descriptions
Browse files Browse the repository at this point in the history
...
  • Loading branch information
helje5 committed Dec 2, 2024
1 parent ef8581a commit 1c7a662
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Sources/ZeeQL/Access/Database.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* ds.findByMatchingAll("lastname", "Duck", "firstname", "Donald")
*
*/
open class Database : EquatableType, Equatable {
open class Database : EquatableType, Equatable, SmartDescription {

open var log : ZeeQLLogger = globalZeeQLLogger
public let adaptor : Adaptor
Expand Down Expand Up @@ -119,6 +119,16 @@ open class Database : EquatableType, Equatable {
public static func ==(lhs: Database, rhs: Database) -> Bool {
return lhs.isEqual(to: rhs)
}


// MARK: - Description

open func appendToDescription(_ ms: inout String) {
ms += " \(adaptor)"
if let typeLookupContext = typeLookupContext {
ms += " types=\(typeLookupContext)"
}
}
}

/**
Expand Down Expand Up @@ -149,7 +159,9 @@ public protocol ObjectTypeLookupContext {
* ]))
*
*/
public struct StaticObjectTypeLookupContext : ObjectTypeLookupContext {
public struct StaticObjectTypeLookupContext : ObjectTypeLookupContext,
SmartDescription
{

@usableFromInline
let types : [ String : DatabaseObject.Type ]
Expand All @@ -174,4 +186,9 @@ public struct StaticObjectTypeLookupContext : ObjectTypeLookupContext {
public func lookupObjectType(name: String) -> DatabaseObject.Type? {
return types[name]
}

public func appendToDescription(_ ms: inout String) {
if types.isEmpty { ms += " EMPTY!" }
else { ms += " #types=\(types.count)" }
}
}

0 comments on commit 1c7a662

Please sign in to comment.