[ALOY-1649] Creating a collection or model with leading slash throw error on require
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | None |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Alloy 1.13.8 |
Fix Version/s | n/a |
Components | Runtime |
Labels | n/a |
Reporter | Ewan Harris |
Assignee | Bruce Wayne |
Created | 2019-03-12T11:41:28.000+0000 |
Updated | 2019-03-12T20:00:35.000+0000 |
Description
Description
CallingcreateModel()
or createCollection()
where the argument is prefixed with a leading slash, or the model is in a directory. This looks to be down to the uppercasing of models done by Alloy on the create call.
// Controller creation
runCode('Controller', 'test/name');
runCode('Controller', '/test/name');
runCode('Controller', 'name');
runCode('Controller', '/name');
// Collection creation
runCode('Collection', 'test/people');
runCode('Collection', '/test/people');
runCode('Collection', 'othermodel');
runCode('Collection', '/othermodel');
// Model creation
runCode('Model', 'test/people');
runCode('Model', '/test/people');
runCode('Model', 'othermodel');
runCode('Model', '/othermodel');
$.index.open();
function runCode(type, path) {
try {
const functionName = create${type}
;
const thing = Alloy[functionName](path);
console.log(Made ${type} with ${path}
);
} catch (error) {
console.error(error);
console.error(${type} with ${path} threw
)
}
}
Steps to reproduce
1. Create the following files **controllers/name.js
** controllers/test/name.js
** models/othermodel.js
** models/test/people.js
2. Add the code above to your controllers/index.js
file
3. Run on any device or sim
Actual
Logs like below
[INFO] Made Controller with test/name
[INFO] Made Controller with /test/name
[INFO] Made Controller with name
[INFO] Made Controller with /name
[ERROR] Couldn't find module: /alloy/models/Test/people for architecture: x86_64
[ERROR] Collection with test/people threw
[ERROR] Couldn't find module: /alloy/models//test/people for architecture: x86_64
[ERROR] Collection with /test/people threw
[INFO] No config.adapter.idAttribute specified for table "othermodel"
[INFO] Adding "alloy_id" to uniquely identify rows
[INFO] Made Collection with othermodel
[ERROR] Couldn't find module: /alloy/models//othermodel for architecture: x86_64
[ERROR] Collection with /othermodel threw
[ERROR] Couldn't find module: /alloy/models/Test/people for architecture: x86_64
[ERROR] Model with test/people threw
[ERROR] Couldn't find module: /alloy/models//test/people for architecture: x86_64
[ERROR] Model with /test/people threw
[INFO] Made Model with othermodel
[ERROR] Couldn't find module: /alloy/models//othermodel for architecture: x86_64
[ERROR] Model with /othermodel threw
Expected
Logging should have no "x with y threw" error logsComments
- Ewan Harris 2019-03-12 A note from when I was playing around with testing this, I don't think models are actually supported in folders by Alloy, so part of this might be irrelevant