Uploaded image for project: 'Alloy'
  1. Alloy
  2. ALOY-1649

Creating a collection or model with leading slash throw error on require

    Details

    • Type: Bug
    • Status: Open
    • Priority: None
    • Resolution: Unresolved
    • Affects Version/s: Alloy 1.13.8
    • Fix Version/s: None
    • Component/s: Runtime
    • Labels:
      None

      Description

      Description

      Calling createModel() 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 logs

        Attachments

          Activity

            People

            • Assignee:
              batman Bruce Wayne
              Reporter:
              eharris Ewan Harris
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

                • Alloy <> Alloy
                  Synced with:
                  ALOY-11
                  Sync status:
                  PENDING
                  Last received:
                  Last sent:

                  Git Integration