From 52e3ea84895004f81d647ab8582564d1e7ab3c73 Mon Sep 17 00:00:00 2001 From: Amy While <26681721+elihwyma@users.noreply.github.com> Date: Sun, 6 Feb 2022 17:59:33 +0000 Subject: [PATCH 1/3] Add a Value conformance for Foundation NSURL --- Sources/SQLite/Foundation.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Sources/SQLite/Foundation.swift b/Sources/SQLite/Foundation.swift index 2acbc00e..c1a4c501 100644 --- a/Sources/SQLite/Foundation.swift +++ b/Sources/SQLite/Foundation.swift @@ -84,3 +84,20 @@ extension UUID: Value { } } + +extension URL: Value { + + public static var declaredDatatype: String { + String.declaredDatatype + } + + public static func fromDatatypeValue(_ stringValue: String) -> URL { + URL(string: stringValue)! + } + + public var datatypeValue: String { + absoluteString + } + +} + From 3eb1fdceda903ea3b7ba0f49a522258578a168d5 Mon Sep 17 00:00:00 2001 From: Amy While <26681721+elihwyma@users.noreply.github.com> Date: Sat, 12 Feb 2022 13:13:42 +0000 Subject: [PATCH 2/3] Remove Extra Trailing New Line --- Sources/SQLite/Foundation.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/SQLite/Foundation.swift b/Sources/SQLite/Foundation.swift index c1a4c501..44a31736 100644 --- a/Sources/SQLite/Foundation.swift +++ b/Sources/SQLite/Foundation.swift @@ -100,4 +100,3 @@ extension URL: Value { } } - From ee905fe357157b6b48ed6641aa5abcf16a6ac354 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Sat, 16 Jul 2022 23:27:17 +0200 Subject: [PATCH 3/3] Add tests for NSURL conformance --- Tests/SQLiteTests/FoundationTests.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Tests/SQLiteTests/FoundationTests.swift b/Tests/SQLiteTests/FoundationTests.swift index 075e755b..453febcd 100644 --- a/Tests/SQLiteTests/FoundationTests.swift +++ b/Tests/SQLiteTests/FoundationTests.swift @@ -26,4 +26,15 @@ class FoundationTests: XCTestCase { XCTAssertEqual(UUID(uuidString: "4ABE10C9-FF12-4CD4-90C1-4B429001BAD3"), uuid) } + func testURLFromString() { + let string = "http://foo.com" + let url = URL.fromDatatypeValue(string) + XCTAssertEqual(URL(string: string), url) + } + + func testStringFromURL() { + let url = URL(string: "http://foo.com")! + let string = url.datatypeValue + XCTAssertEqual("http://foo.com", string) + } }