Skip to content
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

Feature/query operators #45

Merged
merged 17 commits into from
Mar 23, 2017
Merged

Feature/query operators #45

merged 17 commits into from
Mar 23, 2017

Conversation

loudmouth
Copy link
Contributor

No description provided.

@loudmouth loudmouth force-pushed the feature/query-operators branch 2 times, most recently from ba44680 to e958a61 Compare March 20, 2017 18:02
@coveralls
Copy link

Coverage Status

Coverage decreased (-6.2%) to 77.531% when pulling e958a61 on feature/query-operators into be98aa7 on develop.

JP Wright added 15 commits March 21, 2017 17:41
Remove unnecessary generic protocol abstraction
while preserving the benefits of generics
Make a protocol called ClientFieldst that users will conform to help
them map fields.

map identifier like, entry.sys.id

Add ObjectMapper and replace Deodable,

Wrap Link's in an Enum to make them stateful
Debug Link resolution for one-to-one links
Debug Link resoulution for one-to-many links
Debug SyncSpace, API Error parsing, content type decoding

& Include resolution

Use ImmutableMappable

Reimplement Decoding tests and rename then ObjectMappingTests

Make query syntax read better

Update ContentModel protocol to be easier to make use of
Separate code paths for query'ing entries and assets

Don't restrict ContentModel to class types
@coveralls
Copy link

Coverage Status

Coverage decreased (-3.4%) to 80.243% when pulling 051775a on feature/query-operators into be98aa7 on develop.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.2%) to 82.478% when pulling e464379 on feature/query-operators into be98aa7 on develop.

Copy link
Contributor

@mariobodemann mariobodemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small improvements I'd like to suggest ...

private func parseLocalizedFields(_ json: Any) throws -> (String, [String:[String:Any]]) {
let fields = try json => "fields" as! [String: Any]
let locale: String? = try? json => "sys" => "locale"
//internal extension String {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we either uncomment or remove?


public let id: String

public let linkType: String // "Entry" or "Asset" (-> Easier to resolve with this information.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

being picky ) is missing at the end of the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just rm this comment. It was just for me ;-)

}
}

// internal static func validatecombinationsRecursively(operations: QueryOperation...) throws {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To comment or to delete, that is here the question ... ;)

extension String {

func isValidSelection() -> Bool {
if characters.split(separator: ".").count > 2 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fields..foo will still pass... What about fields..foo".characters.split(separator:".", maxSplits:34, omittingEmptySubsequences:false)

createdAt = try? map.value("createdAt")
updatedAt = try? map.value("updatedAt")
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to map space and revision too?

case .asset(let image):
expect(url(image).absoluteString).to(equal("https://images.contentful.com/cfexampleapi/4gp6taAwW4CmSgumq2ekUm/9da0cd1936871b8d72343e895a00d611/Nyan_cat_250px_frame.png"))
default:
fail("Should not have a link of the wrong type her")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here?

let entry = Entry(localizedField: ["":["":""]])
let link = Link.entry(entry)
let newLink = Link.link(from: link)
expect(newLink).toNot(beNil())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this test be more explicit? I.e. what about changing it from .toNot(beNil()) to testing if the newLink sys.id equals the linked entry id, or so?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooops, I thought I had deleted this file. Turns out i only removed it from the xcode project index. It's not a necessary test.



// PERSISTENCE
//final class Cat: NSManagedObject, ContentModel {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those tests to be used once persistence is updated, or can we uncomment them, make them useful?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops. i forgot to address those. I'll remove them


switch result {
case .success(let dogs):
let doge = dogs.first!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it wise to depend on the undefined ordering here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure...any better ideas?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes: Also request an ordering by any field ... ;)

} catch let error as QueryError {
expect(error.message).toNot(beNil())
} catch _ {
fail("Should throw a QueryError")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need to catch the exception here, or can you let it bubble through to the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm catching here to make sure that the error thrown is the right type of Error. So yes, I do indeed need to catch it now.

Copy link
Contributor

@mariobodemann mariobodemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙆‍♂️

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.2%) to 82.497% when pulling d0614cc on feature/query-operators into be98aa7 on develop.

@loudmouth loudmouth merged commit 03913ca into develop Mar 23, 2017
@loudmouth loudmouth deleted the feature/query-operators branch March 23, 2017 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants