-
Notifications
You must be signed in to change notification settings - Fork 49
Json format: refactor error handling + add JSON_UNESCAPED_UNICODE #25
Json format: refactor error handling + add JSON_UNESCAPED_UNICODE #25
Conversation
Pull Request Test Coverage Report for Build 113
💛 - Coveralls |
Pull Request Test Coverage Report for Build 117
💛 - Coveralls |
@assemblie Nice job. This looks good to me. And yes, we welcome all improvements/features :) |
src/Database.php
Outdated
|
||
if (!$file) { | ||
/** | ||
* FIXME: shouldn't we raise an exception in this case? + implement add/create method? |
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.
not sure if its ok from users viewpoint that get (read) method returns empty document object if file doesn't exists? seems weird
maybe we should throw en exception in get (read) and implement add/create, getOrCreate or something like that?
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.
I think the initial idea was to provide production sites with safety in case of failure so that you could create new docs without checking if old existed. That's why I built the method has()
which checks if the document exists.
An issue like this came up before where things created when I didn't want them too, so there is a config option for read_only
so that it only reads the documents that exist. (of course thats not good if you do want to make updates, so its a narrow use-case. But yeah it's not perfect, and could use a bit more transparency for the developer.
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.
But as to your point, the get()
was designed to get a document (from the file system) or an empty document if doenst exist. But only creates a new document in the filesystem if you call the save()
method. This way you can get all the docs you want and then populate data, so if it exists or not intially, it can be created or updated.
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.
@assemblie Do you have a way to chat/talk. Like email, or slack etc? This way we can discuss without having to comment each time? really need a github messaging system...
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.
@timothymarois ok i get it imo this approach is ok but we need to state this in documentation explicitly and yes if you have slack workspace invite me here [email protected]
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.
@assemblie Agreed. and invite sent.
hi! :) i really like your library so i of your ok with it i could try to implement some new features like new formats, filesystem abstraction, validation abstraction so it could use json schema (http://json-schema.org/) etc.
& refactor some of the functionality
i just wanted to add JSON_UNESCAPED_UNICODE to pretty print but decided to give Format a little refactor
hit me if your ok with it and ill implement Reading/Saving Exceptions + add tests