Skip to content

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

Merged
bajtos merged 1 commit into
masterfrom
compat_flag_cleanup
Sep 7, 2016
Merged

[SEMVER-MAJOR] Discard sugar method for model creation#2401
bajtos merged 1 commit into
masterfrom
compat_flag_cleanup

Conversation

@gunjpan

Copy link
Copy Markdown
Contributor

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
gunjpanforce-pushed the compat_flag_cleanup branch from c774c51 to 0c6b1b0CompareJune 3, 2016 21:08
@gunjpan

Copy link
Copy Markdown
ContributorAuthor

@bajtos : Please review, thank you.

@gunjpan

Copy link
Copy Markdown
ContributorAuthor

@slnode test please

@bajtosbajtos changed the title Discard sugar method for model creation[SEMVER-MAJOR] Discard sugar method for model creationJun 7, 2016
Comment thread3.0-RELEASE-NOTES.md Outdated

`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
Copy Markdown
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 )

@bajtosbajtos assigned gunjpan and unassigned bajtosJun 7, 2016
@bajtos

bajtos commented Jun 7, 2016

Copy link
Copy Markdown
Member

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

Comment threadlib/application.js Outdated
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
Copy Markdown
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
Copy Markdown
Member

@gunjpan two more comments, otherwise the patch LGTM.

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

@bajtosbajtos removed their assignment Jun 8, 2016
@gunjpan
gunjpanforce-pushed the compat_flag_cleanup branch from 7839b88 to 08b273cCompareJune 9, 2016 21:47
@gunjpan

Copy link
Copy Markdown
ContributorAuthor

@slnode test please

@gunjpan
gunjpanforce-pushed the compat_flag_cleanup branch from 08b273c to cffb4f1CompareJune 14, 2016 14:39
@gunjpan

Copy link
Copy Markdown
ContributorAuthor

@slnode test please

1 similar comment
@gunjpan

Copy link
Copy Markdown
ContributorAuthor

@slnode test please

@gunjpan
gunjpanforce-pushed the compat_flag_cleanup branch 2 times, most recently from 80cd52f to bc0b6f7CompareAugust 15, 2016 20:18
Comment threadtest/acl.test.js
app.set('remoting', { errorHandler: { debug: true, log: false }});
app.use(loopback.rest());
app.enableAuth();
app.dataSource('test', { connector: 'memory' });

Copy link
Copy Markdown
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.

@gunjpangunjpanAug 16, 2016

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
Member

@gunjpan LGTM

@bajtos

Copy link
Copy Markdown
Member

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

@gunjpan

Copy link
Copy Markdown
ContributorAuthor

@slnode test please

@gunjpan
gunjpanforce-pushed the compat_flag_cleanup branch from bc0b6f7 to 214269eCompareAugust 22, 2016 20:44
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
Copy Markdown
Member

@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 masterSep 7, 2016
@bajtosbajtos 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 freeto 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.

2 participants

@gunjpan@bajtos