-
Notifications
You must be signed in to change notification settings - Fork 379
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
Issue with new model instance and JSON encoded values #168
Comments
The instance is stored in object notation when it is initialized in the first place. In my case the objects I am parsing are already JSON strings that are parsed to create the model instances. It seems a bit silly to parse the JSON, re-stringify parts of the model instance, and decode them again when the instances are created. This solution provides a means by which you can supply a raw object (or array) which is still valid JSON. |
The |
I found the bug, at least in mysql this happens too. I'm going to change in the other drivers. |
Please test this last commit :) |
This should be ok now, reopen if the problem persists. |
Suppose I have a model like this:
Upon creation unless the created object's field contains a JSON string it will be null. It will always be a string from the database, but in a situation where I am creating the object it does not always make sense. I think that both cases below should work.
I have a workaround for the Postgres driver at least, by editing lib/Drivers/DML/postgres.js and adding the following code right below
case "object"
(https://github.com/dresende/node-orm2/blob/master/lib/Drivers/DML/postgres.js#L252)It may be as simple as adding that to all of the drivers.
The text was updated successfully, but these errors were encountered: