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

setting the namespace for a model sets the namespace for all models #3768

Closed
NullVoxPopuli opened this issue Sep 15, 2015 · 11 comments
Closed

Comments

@NullVoxPopuli
Copy link
Sponsor Contributor

They should set per model, yeah?

let host = this.get('host');
let hostId = host.get('id');
let hostType = host.get('type');
let parentPath = Ember.String.underscore(hostType);
parentPath = Ember.String.pluralize(parentPath);

let adapter = this.store.adapterFor('packages');

let rootNamespace = adapter.namespace; // api/
let eventDiscountNamespace = rootNamespace + '/' + parentPath + '/' + hostId + '/packages';

adapter.set('namespace', eventDiscountNamespace);

console.log(adapter.namespace);  // api/events/16/packages
console.log(this.store.adapterFor('packages').namespace); // api/events/16/packages

this.store.adapterFor('application').namespace = rootNamespace

console.log(adapter.namespace);  // api/
console.log(this.store.adapterFor('packages').namespace); // api/

as you can see, setting the namespace for packages also sets for the application and then setting for the application sets the packages namespace.

I believe this could result in race conditions issues

@fivetanley
Copy link
Member

Can you post your adapter definitions?

@fivetanley
Copy link
Member

I think this is pre-existing behavior. If you don't have a packages adapter defined, it will use the existing instance for the application adapter.

@NullVoxPopuli
Copy link
Sponsor Contributor Author

oh, ok. so, if I manually define the adapter, then I shouldn't have the above matching console.logs.
I'll try that out tonight.

@NullVoxPopuli
Copy link
Sponsor Contributor Author

just tried. same issue. :-(

both adapters have the same namespace. :-(

@pangratz
Copy link
Member

pangratz commented Oct 9, 2015

Looks like this works, see http://ember-twiddle.com/25804368a1d4ea121ed2. In application/route.js the namespace of the package adapter is overwritten.

@NullVoxPopuli can you reproduce this in another Ember Twiddle or JSBin?

@NullVoxPopuli
Copy link
Sponsor Contributor Author

I was using ActiveModelAdapter, I've recently switched to json-api, so I'll give this another go.

@bmac
Copy link
Member

bmac commented Oct 12, 2015

@NullVoxPopuli did you get a chance test this issue again?

@NullVoxPopuli
Copy link
Sponsor Contributor Author

not yet. been taking a small break from the project. I'll dive in to it again this week though.

@pangratz
Copy link
Member

@NullVoxPopuli did you have a chance to check if this is still valid?

@NullVoxPopuli
Copy link
Sponsor Contributor Author

I actually migrated everything and have been re-architecting my backend to accomodate a flat-api as having relationship-related namespaces is too difficult.

@pangratz
Copy link
Member

pangratz commented Mar 1, 2016

Okay, seems good. I am going to close this issue as it couldn't be reproduced. If somebody stumbles upon this and can reproduce, please open a new issue and back-reference this one.

@pangratz pangratz closed this as completed Mar 1, 2016
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