mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-28 04:24:20 +00:00
Documentation WIP
This commit is contained in:
1 parent
24e55d97a4
commit
beea0299fa
5 files changed
+29
-19
No files matched your search
@@ -45,6 +45,9 @@ public enum DatabaseValue : Equatable {
|
||||
/// The BLOB storage class, wrapping a Blob.
|
||||
case Blob(GRDB.Blob)
|
||||
|
||||
|
||||
// MARK: - DatabaseValueConvertible Values
|
||||
|
||||
/**
|
||||
Returns the wrapped value.
|
||||
|
||||
@@ -123,3 +126,20 @@ public func ==(lhs: DatabaseValue, rhs: DatabaseValue) -> Bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/// A Database Blob
|
||||
public struct Blob {
|
||||
|
||||
/// The data. Its length is guaranteed to be greater than zero.
|
||||
public let data: NSData
|
||||
|
||||
/// Creates a Blob from NSData. Returns nil if and only if *data* is nil or
|
||||
/// zero-length (SQLite can't store empty blobs).
|
||||
public init?(_ data: NSData?) {
|
||||
if let data = data where data.length > 0 {
|
||||
self.data = data
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,20 +196,7 @@ extension String: DatabaseValueConvertible {
|
||||
}
|
||||
|
||||
/// Blob is convertible to and from DatabaseValue.
|
||||
public struct Blob : DatabaseValueConvertible {
|
||||
|
||||
/// The data. Its length is guaranteed to be greater than zero.
|
||||
public let data: NSData
|
||||
|
||||
/// Create a Blob from NSData. Returns nil if and only if *data* is nil or
|
||||
/// empty (SQLite can't store empty blobs).
|
||||
public init?(_ data: NSData?) {
|
||||
if let data = data where data.length > 0 {
|
||||
self.data = data
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
extension Blob : DatabaseValueConvertible {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ A row is the result of a database query.
|
||||
*/
|
||||
public struct Row: CollectionType {
|
||||
|
||||
// MARK: - DatabaseValueConvertible value
|
||||
// MARK: - DatabaseValueConvertible Values
|
||||
|
||||
/**
|
||||
Returns the value at given index.
|
||||
|
||||
@@ -144,10 +144,12 @@ public class Statement {
|
||||
// MARK: - SQLite identifier quoting
|
||||
|
||||
extension String {
|
||||
/// Returns the receiver, quoted for safe insertion in an SQL query as an
|
||||
/// identifier.
|
||||
///
|
||||
/// db.execute("SELECT * FROM \(tableName.quotedDatabaseIdentifier)")
|
||||
/**
|
||||
Returns the receiver, quoted for safe insertion as an identifier in an SQL
|
||||
query.
|
||||
|
||||
db.execute("SELECT * FROM \(tableName.quotedDatabaseIdentifier)")
|
||||
*/
|
||||
public var quotedDatabaseIdentifier: String {
|
||||
// See https://www.sqlite.org/lang_keywords.html
|
||||
return "\"\(self)\""
|
||||
|
||||
@@ -8,6 +8,7 @@ Release Notes
|
||||
- `Blob.init?(NSData?)`.
|
||||
- `RowModel.isEdited`.
|
||||
- `RowModel.copyDatabaseValuesFrom(_:)`
|
||||
- `DatabaseValue` adopts Equatable.
|
||||
|
||||
**Breaking changes**
|
||||
|
||||
|
||||
Reference in new issue
Block a user