Skip to content

Commit 3a3ffba

Browse files
planetMDXRoland Ambs
and
Roland Ambs
authored
Fix Field-Initializers protection (#5)
* set new init-methods for Fields to public * trim lines * remove code causing warning * style changes Co-authored-by: Roland Ambs <[email protected]>
1 parent cc3b0b1 commit 3a3ffba

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

Sources/ClickHouseVapor/ClickHouseColumnConvertible.swift

+10-7
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public final class Field<Value: ClickHouseDataType>: ClickHouseColumnConvertible
8989
self
9090
}
9191

92-
92+
9393
fileprivate init(
9494
key: String,
9595
isPrimary: Bool = false,
@@ -104,6 +104,7 @@ public final class Field<Value: ClickHouseDataType>: ClickHouseColumnConvertible
104104
self.columnMetadata = columnMetadata
105105
self.wrappedValue = []
106106
}
107+
107108
public init(
108109
key: String,
109110
isPrimary: Bool = false,
@@ -119,7 +120,7 @@ public final class Field<Value: ClickHouseDataType>: ClickHouseColumnConvertible
119120
}
120121
}
121122

122-
extension Field where Value == String {
123+
public extension Field where Value == String {
123124
convenience init(
124125
key: String,
125126
isPrimary: Bool = false,
@@ -130,7 +131,8 @@ extension Field where Value == String {
130131
self.init(key: key, isPrimary: isPrimary, isOrderBy: isOrderBy, isLowCardinality: isLowCardinality, columnMetadata: .fixedStringLength(fixedStringLen))
131132
}
132133
}
133-
extension Field where Value == ClickHouseDateTime {
134+
135+
public extension Field where Value == ClickHouseDateTime {
134136
convenience init(
135137
key: String,
136138
isPrimary: Bool = false,
@@ -140,9 +142,8 @@ extension Field where Value == ClickHouseDateTime {
140142
) {
141143
self.init(key: key, isPrimary: isPrimary, isOrderBy: isOrderBy, isLowCardinality: isLowCardinality, columnMetadata: .dateTimeTimeZone(timeZone))
142144
}
143-
144145
}
145-
extension Field where Value == ClickHouseDateTime64 {
146+
public extension Field where Value == ClickHouseDateTime64 {
146147
convenience init(
147148
key: String,
148149
isPrimary: Bool = false,
@@ -153,6 +154,7 @@ extension Field where Value == ClickHouseDateTime64 {
153154
) {
154155
self.init(key: key, isPrimary: isPrimary, isOrderBy: isOrderBy, isLowCardinality: isLowCardinality, columnMetadata: .dateTime64Precision(precision, timeZone))
155156
}
157+
156158
convenience init(
157159
key: String,
158160
isPrimary: Bool = false,
@@ -162,7 +164,7 @@ extension Field where Value == ClickHouseDateTime64 {
162164
fatalError("missing precision for DateTime64")
163165
}
164166
}
165-
extension Field where Value == ClickHouseEnum8 {
167+
public extension Field where Value == ClickHouseEnum8 {
166168
convenience init(
167169
key: String,
168170
isPrimary: Bool = false,
@@ -182,7 +184,7 @@ extension Field where Value == ClickHouseEnum8 {
182184
fatalError("missing enum-mapping for enum8")
183185
}
184186
}
185-
extension Field where Value == ClickHouseEnum16 {
187+
public extension Field where Value == ClickHouseEnum16 {
186188
convenience init(
187189
key: String,
188190
isPrimary: Bool = false,
@@ -192,6 +194,7 @@ extension Field where Value == ClickHouseEnum16 {
192194
) {
193195
self.init(key: key, isPrimary: isPrimary, isOrderBy: isOrderBy, isLowCardinality: isLowCardinality, columnMetadata: .enum16Map(mapping))
194196
}
197+
195198
convenience init(
196199
key: String,
197200
isPrimary: Bool = false,

Sources/ClickHouseVapor/ClickHouseEngine.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ extension ClickHouseTypeName {
117117
return true
118118
case .nullable(let type):
119119
return type.supportsLowCardinality
120-
case .array(let type):
120+
case .array:
121121
return false
122122
case .boolean:
123123
return false

Tests/ClickHouseVaporTests/ClickHouseVaporTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class TestModel: ClickHouseModel {
5454
@Field(key: "datt64", precision: 3)
5555
var datt64: [ ClickHouseDateTime64 ]
5656

57-
@Field(key: "datt64z", precision: 3,timeZone: "'GMT'")
57+
@Field(key: "datt64z", precision: 3, timeZone: "'GMT'")
5858
var datt64z: [ ClickHouseDateTime64 ]
5959

6060
@Field(key: "en8", mapping: ["a": 0, "b": 1])

0 commit comments

Comments
 (0)