forked from vapor/postgres-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPostgresDialect.swift
54 lines (44 loc) · 1.33 KB
/
PostgresDialect.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
public struct PostgresDialect: SQLDialect {
public init() { }
public var name: String {
"postgresql"
}
public var identifierQuote: SQLExpression {
return SQLRaw("\"")
}
public func bindPlaceholder(at position: Int) -> SQLExpression {
return SQLRaw("$" + position.description)
}
public func literalBoolean(_ value: Bool) -> SQLExpression {
switch value {
case false:
return SQLRaw("false")
case true:
return SQLRaw("true")
}
}
public var autoIncrementClause: SQLExpression {
return SQLRaw("GENERATED BY DEFAULT AS IDENTITY")
}
public var supportsAutoIncrement: Bool {
true
}
public var supportsReturning: Bool {
true
}
public var enumSyntax: SQLEnumSyntax {
.typeName
}
public var triggerSyntax: SQLTriggerSyntax {
return .init(
create: [.supportsForEach, .postgreSQLChecks, .supportsCondition, .conditionRequiresParentheses, .supportsConstraints],
drop: [.supportsCascade, .supportsTableName]
)
}
public var alterTableSyntax: SQLAlterTableSyntax {
.init(
alterColumnDefinitionClause: SQLRaw("ALTER COLUMN"),
alterColumnDefinitionTypeKeyword: SQLRaw("SET DATA TYPE")
)
}
}