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

getting deprecation message #324

Closed
rinoldsimon opened this issue Aug 18, 2016 · 11 comments
Closed

getting deprecation message #324

rinoldsimon opened this issue Aug 18, 2016 · 11 comments

Comments

@rinoldsimon
Copy link

DEPRECATION: Using the global version of DS is deprecated. Please either import the specific modules needed or import DS from 'ember-data';. [deprecation id: ember-data.global-ds]

my model:

import DS from 'ember-data';
import { validator, buildValidations } from 'ember-cp-validations';

const { attr } = DS;

var Validations = buildValidations({
  first_name: {
    description: 'Firstname',
    validators: [
      validator('presence', true),
      validator('length', {
        max: 15
      })
    ]
  }
});

export default DS.Model.extend(Validations, {
  first_name: attr('string'),
  last_name: attr('string'),
  ...
});
@leoeuclids
Copy link

The deprecation your getting is related to 'ember-data', not 'ember-cp-validations'.

Anyway, it's quite simple to fix. Just remove the DS import and import the modules directly.

import Model from 'ember-data/model';
import attr from 'ember-data/attr';

Reference: https://guides.emberjs.com/v2.6.0/models/defining-models/

@rinoldsimon
Copy link
Author

rinoldsimon commented Aug 18, 2016

I'm using Ember version 2.7.0 !
The guide says to import DS from 'ember-data'

Reference : https://guides.emberjs.com/v2.7.0/models/defining-models/

@leoeuclids
Copy link

Yep! I've seen that too.
The 2.7.0 Guides are showing the old way of importing 'ember-data'.
Try doing it as described on the 2.6.0 guides, which should work without deprecations.

@leoeuclids
Copy link

It's actually being fixed emberjs/guides#1597.
Should close this one.

@rinoldsimon
Copy link
Author

Even the below code throws the same DEPRECATION message !

import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import { validator, buildValidations } from 'ember-cp-validations';

var Validations = buildValidations({
  first_name: {
    description: 'Firstname',
    validators: [
      validator('presence', true),
      validator('length', {
        max: 15
      })
    ]
  }
});

export default Model.extend(Validations, {
  first_name: attr('string'),
  last_name: attr('string'),
  ...
});

Removing Validations from export default Model.extent({ }); works fine without any DEPRECATION message. So the problem is with ember-cp-validations

@rwjblue
Copy link
Member

rwjblue commented Aug 18, 2016

This deprecation happens when using window.DS not the DS from import DS from 'ember-data'; (as referenced from the guides).

It looks like ember-cp-validations is always grabbing DS from the module (GH code search here), so I doubt the deprecation is coming from ember-cp-validations.

@rwjblue
Copy link
Member

rwjblue commented Aug 18, 2016

Looks like this was fixed in #239 actually.

@rinoldsimon
Copy link
Author

But getting the DEPRECATION message. What should be changed in my side ?

@leoeuclids
Copy link

It seems that the fix made it to master (released on version v3.0.0-beta.5), but not the v2.x branch, as seen here https://github.com/offirgolan/ember-cp-validations/blob/v2.x/addon/utils/utils.js, so v2.9.4 still has the issue.

@rinoldsimon
Copy link
Author

rinoldsimon commented Aug 18, 2016

After updating the addon ember-cp-validations to 3.0.0-beta.5 fixed the issue. But now there is another deprecation when i start my ember server.

DEPRECATION: ember-cli-htmlbars-inline-precompile is opting out of caching due to an AST plugin that does not provide a caching strategy: `v-get`.
DEPRECATION: ember-cli-htmlbars is opting out of caching due to an AST plugin that does not provide a caching strategy: `v-get`.

my addons version for htmlbars are listed below

"ember-cli-htmlbars": "^1.1.0",
"ember-cli-htmlbars-inline-precompile": "^0.3.5",

@offirgolan
Copy link
Collaborator

DEPRECATION: Using the global version of DS is deprecated. Please either import the specific modules needed or import DS from 'ember-data';. [deprecation id: ember-data.global-ds]

A patch release has been published to take care of this for 2.x users.

After updating the addon ember-cp-validations to 3.0.0-beta.5 fixed the issue. But now there is another deprecation when i start my ember server.

This issue has been resolved and is currently in master. I will issue a new beta release in a few days once I get 2 other PRs merged.

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

No branches or pull requests

4 participants