Skip to content

Attribute Parse (WIP) - #223

Closed
topleft wants to merge 10 commits into
sequelize:masterfrom
topleft:attribute-parse
Closed

topleft wants to merge 10 commits into
sequelize:masterfrom
topleft:attribute-parse

Conversation

@topleft

@topleft topleft commented Nov 14, 2015

Copy link
Copy Markdown

I have created a set of parsing functions that would allow for field attributes to be specified via the command line on create:model. Work still needs to be done on the templating of both the model and migrations for this to work. And of course updating the tests. I would like to continue to hack at it, but I am having trouble modifying the tests. I may have a templating solution for the model on another branch, but won't know until the tests run. Any help/advice would be awesome!

@topleft

topleft commented Nov 14, 2015

Copy link
Copy Markdown
Author

repo with tests for these parse functions

@topleft

topleft commented Nov 15, 2015

Copy link
Copy Markdown
Author

@sdepold can I get some feedback on this before I re-write ALL the tests, please. Thanks!

@sdepold

sdepold commented Nov 15, 2015

Copy link
Copy Markdown
Member

@topleft so this allows:

sequelize model:create --name foo --attributes name:[type:string,required:true] age:[type:integer, required: false]

?

Can we keep the backwards compatibility and support

sequelize model:create --name foo --attributes name:[type:string,required:true] age:integer

?

@topleft

topleft commented Nov 15, 2015

Copy link
Copy Markdown
Author

I think so. Let me rework the parse function.

@mjhea0 mjhea0 mentioned this pull request Nov 16, 2015
@topleft

topleft commented Nov 16, 2015

Copy link
Copy Markdown
Author

@sdepold
I have adjusted the parsing functions to accept the the current command format. I think this is a good start to allowing for more specific attribute definition, thus saving a lot of work for the user in updating two files (model and migration). There are several issues/questions that need to be addressed.

Backwards Compatibility

  • The tests are not passing because the object I am returning is a different format and the templates (model and migration) can't use them
  • Using the current template would require two sets of parsing functions and would use the new command format
  • The current output format in the model file:
{ fieldName: DataTypes.TYPE }
  • Desired output:
{ fieldName: {
     type: DataTypes.TYPE
  }
}
  • My parsing functions return the object in this desired format

Current Hangups

Lodash Template
  • model.js
  • migration.js
Tests
  • as this parsing is fundamental, many of the tests are touched by this change

I am interested in taking this further with some help. What do you think?

@sdepold

sdepold commented Nov 17, 2015

Copy link
Copy Markdown
Member

I'm OK with changing the format of the output if the previous CLI interface is backwards compatible (sequelize model:create --name foo --attributes name:[type:string,required:true] age:integer).

Thanks for your effort :)

@sushantdhiman

Copy link
Copy Markdown
Contributor

Closing (PR Cleanup), Open new PR if you wish to continue your work

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.

3 participants