mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
DatabaseValue.negated: prefer 1 to NOT 0
This commit is contained in:
1 parent
45fd6f89c0
commit
9ae2de6dc1
1 file changed
+23
@@ -219,6 +219,29 @@ extension DatabaseValue : SQLExpression {
|
||||
return DatabaseQueue().inDatabase { String.fetchOne($0, "SELECT QUOTE(?)", arguments: [self])! }
|
||||
}
|
||||
}
|
||||
|
||||
/// This property is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
///
|
||||
/// # Low Level Query Interface
|
||||
///
|
||||
/// See SQLExpression.negated
|
||||
public var negated: SQLExpression {
|
||||
switch storage {
|
||||
case .null:
|
||||
return SQLExpressionUnary(.not, self)
|
||||
case .int64(let int64):
|
||||
return (int64 == 0).databaseValue
|
||||
case .double(let double):
|
||||
return (double == 0.0).databaseValue
|
||||
case .string:
|
||||
return SQLExpressionUnary(.not, self)
|
||||
case .blob:
|
||||
return SQLExpressionUnary(.not, self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user