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

[SEMVER-MAJOR] Discard sugar method for model creation #2401

Merged
merged 1 commit into from Sep 7, 2016

Conversation

gunjpan
Copy link
Contributor

@gunjpan gunjpan commented Jun 3, 2016

Current implementation of app.model(modelName, settings)
works as a sugar for model creation. In 3.0, this is
not supported anymore. This implementation reports an
error when sugar is used for model creation.
Includes:

  • Updated app.model() method
  • Fixed test cases reflecting the change

Connect to https://github.com/strongloop-internal/scrum-loopback/issues/772

@gunjpan
Copy link
Contributor Author

gunjpan commented Jun 3, 2016

@bajtos : Please review, thank you.

@gunjpan
Copy link
Contributor Author

gunjpan commented Jun 6, 2016

@slnode test please

@bajtos bajtos changed the title Discard sugar method for model creation [SEMVER-MAJOR] Discard sugar method for model creation Jun 7, 2016

`app.model(modelName, settings)`, a sugar for creating non-existing model, is
now removed in favor of promoting use of:
- `app.registry.createModel(modelName, properties, options) to create new model
Copy link
Member

Choose a reason for hiding this comment

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

Missing backslash character after )

@bajtos bajtos assigned gunjpan and unassigned bajtos Jun 7, 2016
@bajtos
Copy link
Member

bajtos commented Jun 7, 2016

@gunjpan reviewed, PTAL. Also make sure that npm test passes on your local machine.

if (typeof Model === 'string') {
var msg = 'app.model(modelName, settings) is no longer supported. ' +
'Use app.registry.createModel(modelName, definition) and ' +
'app.model(modelCtor, config) instead.';
Copy link
Member

Choose a reason for hiding this comment

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

ModelCtor please, we usually use Pascal Case for constructors (class names).

@bajtos
Copy link
Member

bajtos commented Jun 8, 2016

@gunjpan two more comments, otherwise the patch LGTM.

No further review is necessary, please squash the commits before landing.

@bajtos bajtos removed their assignment Jun 8, 2016
@gunjpan
Copy link
Contributor Author

gunjpan commented Jun 10, 2016

@slnode test please

@gunjpan
Copy link
Contributor Author

gunjpan commented Jul 12, 2016

@slnode test please

1 similar comment
@gunjpan
Copy link
Contributor Author

gunjpan commented Aug 4, 2016

@slnode test please

@gunjpan gunjpan force-pushed the compat_flag_cleanup branch 2 times, most recently from 80cd52f to bc0b6f7 Compare August 15, 2016 20:18
app.set('remoting', { errorHandler: { debug: true, log: false }});
app.use(loopback.rest());
app.enableAuth();
app.dataSource('test', { connector: 'memory' });
Copy link
Member

Choose a reason for hiding this comment

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

I think we misunderstood each other. Keep the app creation in the before hook, because that part is typically shared by all test. Keep the line var MyTestModel = ... in the test, because the model is specific to the test case.

Copy link
Contributor Author

@gunjpan gunjpan Aug 16, 2016

Choose a reason for hiding this comment

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

@bajtos : In the previous review cycle, IIRC, (can't quote commit as rebased), I had kept the before() part, but was advised to remove it as there is only one case in that describe() block.

Do you still recommend changing it?

Copy link
Member

Choose a reason for hiding this comment

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

I see. Let's not bike shed and keep the code as it is now.

@bajtos
Copy link
Member

bajtos commented Aug 16, 2016

@gunjpan LGTM

@bajtos
Copy link
Member

bajtos commented Aug 16, 2016

@gunjpan please rebase on top of the current master and check CI results before landing.

@gunjpan
Copy link
Contributor Author

gunjpan commented Aug 16, 2016

@slnode test please

Current implementation of `app.model(modelName, settings)`
works as a sugar for model creation. In 3.0, this is
not supported anymore. This implementation reports an
error when sugar is used for model creation.
Includes:
 - Updated app.model() method
 - Fixed test cases reflecting the change
@bajtos
Copy link
Member

bajtos commented Sep 7, 2016

@gunjpan I have rebased your patch on top of the latest master. All CI builds are passing with the exception of node=0.10,os=windows which fails because of an unrelated problem (phantomjs cannot be started due to resource leaks).

I am going to land this patch.

@bajtos bajtos merged commit da09876 into master Sep 7, 2016
@bajtos bajtos removed the #review label Sep 7, 2016
@bajtos bajtos deleted the compat_flag_cleanup branch September 7, 2016 10:44
gunjpan added a commit that referenced this pull request Sep 22, 2016
Current implementation of `app.model(modelName, settings)`
works as a sugar for model creation. In LB 3.0, this is
not supported anymore. This backporting:
- keeps the sugar method for model creation  for backward
compatibility
- updates test cases to use `app.registry.createModel()`
for model creation

Backport of #2401
gunjpan added a commit that referenced this pull request Sep 23, 2016
Current implementation of `app.model(modelName, settings)`
works as a sugar for model creation. In LB 3.0, this is
not supported anymore. This backporting:
- keeps the sugar method for model creation  for backward
compatibility
- updates test cases to use `app.registry.createModel()`
for model creation

Backport of #2401
gunjpan added a commit that referenced this pull request Sep 27, 2016
Current implementation of `app.model(modelName, settings)`
works as a sugar for model creation. In LB 3.0, this is
not supported anymore. This backporting:
- keeps the sugar method for model creation  for backward
compatibility
- updates test cases to use `app.registry.createModel()`
for model creation

Backport of #2401
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

2 participants