Titanium JIRA Archive
Alloy (ALOY)

[ALOY-467] idAttribute assignable from Model config

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-08-06T06:24:55.000+0000
Affected Version/sn/a
Fix Version/sAlloy 0.3.5, 2013 Sprint 02
ComponentsRuntime
Labelsqe-Alloy, qe-manualtest
ReporterTony Lukasavage
AssigneeTony Lukasavage
Created2013-01-16T11:37:54.000+0000
Updated2014-08-06T06:24:55.000+0000

Description

The Backbone idAttribute property, which determines which backend property is the unique identifier for a Backbone model, should be assignable through the model.js config.definition object. That way Alloy can automatically apply that idAttribute to all created models. It will also signal Alloy to *_not_* create an additional "id" field like it does now for uniquely identifying records. Alloy should only create an additional id row if absolutely necessary and this will allow the developers to prevent that.

sample

This sample will tell Alloy (and Backbone) to use *myId* as the idAttribute for all models created from this definition. It will additionally tell Alloy to *_not_* create an additional id field for uniquely identifying records. If we were to remove the *idAttribute* property, then Alloy would in fact create an id column.
exports.definition = {
	config: {
		"columns": {
			"name":"TEXT",
			"nickname":"TEXT",
			"myId": "INTEGER PRIMARY KEY AUTOINCREMENT"
		},
		"adapter": {
			"type": "sql",
			"collection_name": "fighters",
		},
		"idAttribute": "myId"
	}
}

Comments

  1. Tony Lukasavage 2013-01-17

    Present in this test app: https://github.com/appcelerator/alloy/tree/master/test/apps/models/sql_keywords
  2. Federico Casali 2013-01-26

    Verified fixed also on 1_0_X master branch android device: 4.2 iPhone devices: iPhone 6 and iPad 4.3.5 TiSDK: 3.0.2.v20130124164131 CLI: 3.0.23 Closing.
  3. Federico Casali 2013-01-26

    Reopening for adding labels

JSON Source