-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Codable firestore #838
Closed
Closed
Codable firestore #838
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
3598b86
Add Firestore_SwiftTests_iOS target to Xcode
wilhuff 959cc57
Clean up generated Firestore_SwiftTests_iOS test target
wilhuff ad832a1
Add FirebaseFirestoreSwift podspec
wilhuff 24daa10
Add Firestore_SwiftTests_iOS to the Podfile
wilhuff 6fc2dd4
Add CodableGeoPoint
wilhuff b5d72b0
Move Firestore_SwiftTests_iOS to the top-level of the Podfile
wilhuff c719b85
Add CodableGeoPointTests to the project
wilhuff 448bbbf
Add FirebaseEncoder
557883e
Update Encoder
86bbf4b
Fix typo
cb7e0a8
Make the extension available only from swift 4
6303624
Add FirestoreDecoder
f20e338
Make all the types in Encoder as available from swift 4
9f13acf
Add extension to document snapshot
a423896
Refactor to private Decoder and Encoder
dcc4b4a
Add internal type Firestore.Decoder
493a157
Add internal Firestore.Encoder type
c9b35c7
Move to proper sub folder
05e20fd
Confirm DocumentReference to Codable
735331d
Confirm FieldValue to Encodable protocol
889f29a
Fix copyright
4fed07f
Merge master into codable-firestore
ccdd0fc
Refactor to requireKey and requireValue private methods
93f7430
Fix field value comment
abe43e4
Fix names of the files
073901a
Move errors to separate file
a62364d
Refactor to use expectNotAtEnd
f19ea99
Fix using internal type mismatch method
3ea3eba
Refactor to require value private function
d23c201
Refactor to private methods to require values
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
Firestore/Swift/Source/Codable/DocumentReference+Codable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2018 Google | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import FirebaseFirestore | ||
|
||
/** | ||
* A protocol describing the encodable properties of a DocumentReference. | ||
* | ||
* Note: this protocol exists as a workaround for the Swift compiler: if the DocumentReference class was | ||
* extended directly to conform to Codable, the methods implementing the protcol would be need to be | ||
* marked required but that can't be done in an extension. Declaring the extension on the protocol | ||
* sidesteps this issue. | ||
*/ | ||
fileprivate protocol CodableDocumentReference: Codable {} | ||
|
||
extension CodableDocumentReference { | ||
public init(from decoder: Decoder) throws { | ||
throw FirestoreDecodingError.decodingIsNotSupported | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
throw FirestoreEncodingError.encodingIsNotSupported | ||
} | ||
} | ||
|
||
extension DocumentReference: CodableDocumentReference {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copyright notice. I realize this isn't super important to you, but this is the only way that Google allows me to continue to work in the open with you, so it's very important to me :-). |
||
// Errors.swift | ||
// FirebaseFirestoreSwift | ||
// | ||
// Created by Oleksii on 27/02/2018. | ||
// | ||
|
||
import Foundation | ||
|
||
enum FirestoreDecodingError: Error { | ||
case decodingIsNotSupported | ||
} | ||
|
||
enum FirestoreEncodingError: Error { | ||
case encodingIsNotSupported | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2018 Google | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import FirebaseFirestore | ||
|
||
/** | ||
* A protocol describing the encodable properties of a FirebaseFirestore. | ||
* | ||
* Note: this protocol exists as a workaround for the Swift compiler: if the FieldValue class was | ||
* extended directly to conform to Codable, the methods implementing the protcol would be need to be | ||
* marked required but that can't be done in an extension. Declaring the extension on the protocol | ||
* sidesteps this issue. | ||
*/ | ||
fileprivate protocol CodableFieldValue: Encodable {} | ||
|
||
extension CodableFieldValue { | ||
public func encode(to encoder: Encoder) throws { | ||
throw FirestoreEncodingError.encodingIsNotSupported | ||
} | ||
} | ||
|
||
extension FieldValue: CodableFieldValue {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The base state from which you branched was broken. I've since fixed this, but unfortunately these diffs remain. For all the
.xcscheme
files, make sure your upstream branch is up-to-date and then git checkout the master version of these files and commit them. After pushing you shouldn't see any additions to project files.