Merged
Conversation
Number fixes for sqlite. Should fix #310
Owner
|
I just published sql-query@0.1.12. What happens if no |
Collaborator
Author
|
Hmm looking at: // ORM.prototype.define
id : opts.id || this.settings.get("properties.primary_key"),
// Instance.js
for (var i = 0; i < opts.id.length; i++) {
k = opts.id[i];
allProperties[k] = opts.properties[k] || {
type: 'serial', rational: 'false', key: true, klass: 'key'
};
}if someone defines |
Owner
|
What I meant was:
|
Collaborator
Author
|
This PR doesn't change the behaviour. It's an intermediate step that allowed some code cleanups. That said, I can work on part two (with |
Owner
|
Yes, go for it. Looks good to me :) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
To fix #310 I needed a way to reliably pass a model property definition to a DML drivers
valueToPropertymethod from within anInstance.Since some properties were set on
Model.propertieswhilst others like ids & association fields existed only in an array of strings (and their types were inferred by the drivers DDLsynccode) this made life difficult.It also introduced duplicate code, and issues with redefining key columns, and no good way to specify exact types for ALL columns.
I've come up with
Model.allPropertieswhich stores definitions of all constant properties (normal properties, id props, association fields). Extra properties remain separate as they are transient.This allowed for some nice code cleanups in driver
syncmethods, and a simplification ofopts.datainitialization code insideInstance.It also fixes some inconsistent behaviour I found along the way, like
Model.createcasting properties when they are set andinstance.savenot doing so.Lastly, it introduces a new syntax (only internally for now) for defining keys, as discussed in #313 :
Composite keys:
Keys are currently still set via the
idproperty, however now that the underlying work is done, we can change this in future to thekeysyntax without too much pain.Note: We now have both
Model.allPropertiesandModel.properties. It should be possible to remove the latter in the future. It was taking me forever to finish this refactor, so consider this code a transition step.@dresende the failing tests depend on sql-query 0.11.12 being published - the change in sql-query is small.