Skip to content

Commit

Permalink
error source + metadata updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 committed Feb 24, 2018
1 parent 3235a8e commit 726bbf4
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 16 deletions.
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Qutheory, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 7 additions & 7 deletions Package.swift
Expand Up @@ -8,17 +8,17 @@ let package = Package(
.library(name: "FluentPostgreSQL", targets: ["FluentPostgreSQL"]),
],
dependencies: [
// Swift Promises, Futures, and Streams.
.package(url: "https://github.com/vapor/async.git", "1.0.0-beta.1"..<"1.0.0-beta.2"),
// Promises and reactive-streams in Swift built for high-performance and scalability.
.package(url: "https://github.com/vapor/async.git", from: "1.0.0-rc"),

// Core extensions, type-aliases, and functions that facilitate common tasks.
.package(url: "https://github.com/vapor/core.git", "3.0.0-beta.1"..<"3.0.0-beta.2"),
// 🌎 Utility package containing tools for byte manipulation, Codable, OS APIs, and debugging.
.package(url: "https://github.com/vapor/core.git", from: "3.0.0-rc"),

// Swift ORM framework (queries, models, and relations) for building NoSQL and SQL database integrations.
.package(url: "https://github.com/vapor/fluent.git", "3.0.0-beta.3"..<"3.0.0-beta.4"),
.package(url: "https://github.com/vapor/fluent.git", from: "3.0.0-rc"),

// Pure Swift, async/non-blocking client for PostgreSQL.
.package(url: "https://github.com/vapor/postgresql.git", "1.0.0-beta.3"..<"1.0.0-beta.4"),
// 🐘 Non-blocking, event-driven Swift client for PostgreSQL.
.package(url: "https://github.com/vapor/postgresql.git", from: "1.0.0-rc"),
],
targets: [
.target(name: "FluentPostgreSQL", dependencies: ["Async", "CodableKit", "Fluent", "FluentSQL", "PostgreSQL"]),
Expand Down
22 changes: 20 additions & 2 deletions README.md
@@ -1,2 +1,20 @@
# fluent-postgresql
Swift ORM for PostgreSQL (built on top of Fluent ORM framework)
<p align="center">
<img src="https://user-images.githubusercontent.com/1342803/36623958-dc6f07f0-18d7-11e8-8c6c-01737f496de9.png" height="64" alt="Fluent PostgreSQL">
<br>
<br>
<a href="http://docs.vapor.codes/3.0/">
<img src="http://img.shields.io/badge/read_the-docs-2196f3.svg" alt="Documentation">
</a>
<a href="http://vapor.team">
<img src="http://vapor.team/badge.svg" alt="Slack Team">
</a>
<a href="LICENSE">
<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License">
</a>
<a href="https://circleci.com/gh/vapor/fluent-postgresql">
<img src="https://circleci.com/gh/vapor/fluent-postgresql.svg?style=shield" alt="Continuous Integration">
</a>
<a href="https://swift.org">
<img src="http://img.shields.io/badge/swift-4.1-brightgreen.svg" alt="Swift 4.1">
</a>
</p>
Expand Up @@ -43,7 +43,8 @@ extension PostgreSQLDatabase: QuerySupporting {
reason: "Unsupported encodable type: \(type)",
suggestedFixes: [
"Conform \(type) to PostgreSQLDataCustomConvertible"
]
],
source: .capture()
)
}
return try convertible.convertToPostgreSQLData()
Expand Down
Expand Up @@ -10,7 +10,7 @@ extension PostgreSQLDatabase: ReferenceSupporting {
/// See `ReferenceSupporting.disableReferences(on:)`
public static func disableReferences(on connection: PostgreSQLConnection) -> Future<Void> {
return Future(
error: PostgreSQLError(identifier: "disableReferences", reason: "PostgreSQL does not support disabling foreign key checks.")
error: PostgreSQLError(identifier: "disableReferences", reason: "PostgreSQL does not support disabling foreign key checks.", source: .capture())
)
}
}
Expand Up @@ -45,7 +45,8 @@ extension PostgreSQLDatabase: SchemaSupporting, IndexSupporting {
suggestedFixes: [
"Conform \(type) to `PostgreSQLColumnStaticRepresentable` to specify field type or implement a custom migration.",
"Specify the `PostgreSQLColumn` manually using the schema builder in a migration."
]
],
source: .capture()
)
}
}
Expand Down
8 changes: 5 additions & 3 deletions Sources/FluentPostgreSQL/PostgreSQLRowDecoder.swift
Expand Up @@ -23,7 +23,7 @@ internal final class PostgreSQLRowDecoder: Decoder {

func require(key: CodingKey) throws -> PostgreSQLData {
guard let data = self.data[key.stringValue] else {
throw PostgreSQLError(identifier: "decode", reason: "No value found at key: \(key)")
throw PostgreSQLError(identifier: "decode", reason: "No value found at key: \(key)", source: .capture())
}
return data
}
Expand All @@ -36,7 +36,8 @@ private func unsupported() -> PostgreSQLError {
reason: "PostgreSQL rows only support a flat, keyed structure `[String: T]`",
suggestedFixes: [
"You can conform nested types to `PostgreSQLJSONType` or `PostgreSQLArrayType`. (Nested types must be `PostgreSQLDataCustomConvertible`.)"
]
],
source: .capture()
)
}

Expand Down Expand Up @@ -76,7 +77,8 @@ fileprivate struct PostgreSQLRowKeyedDecodingContainer<K>: KeyedDecodingContaine
reason: "Unsupported decodable type: \(type)",
suggestedFixes: [
"Conform \(type) to PostgreSQLDataCustomConvertible"
]
],
source: .capture()
)
}
return try convertible.convertFromPostgreSQLData(decoder.require(key: key)) as! T
Expand Down
3 changes: 2 additions & 1 deletion Sources/FluentPostgreSQL/PostgreSQLRowEncoder.swift
Expand Up @@ -80,7 +80,8 @@ fileprivate struct PostgreSQLRowKeyedEncodingContainer<K>: KeyedEncodingContaine
reason: "Unsupported encodable type: \(type)",
suggestedFixes: [
"Conform \(type) to PostgreSQLDataCustomConvertible"
]
],
source: .capture()
)
}
encoder.data[key.stringValue] = try convertible.convertToPostgreSQLData()
Expand Down

0 comments on commit 726bbf4

Please sign in to comment.