@@ -424,17 +424,27 @@ DataSource.prototype.defineRelations = function (modelClass, relations) {
424424
425425/*!
426426 * Set up the data access functions from the data source
427- * @param modelClass
428- * @param settings
427+ * @param { Model } modelClass The model class
428+ * @param { Object } settings The settings object
429429 */
430430DataSource . prototype . setupDataAccess = function ( modelClass , settings ) {
431- if ( this . connector && this . connector . define ) {
432- // pass control to connector
433- this . connector . define ( {
434- model : modelClass ,
435- properties : modelClass . definition . properties ,
436- settings : settings
437- } ) ;
431+ if ( this . connector ) {
432+ // Check if the id property should be generated
433+ var idName = modelClass . definition . idName ( ) ;
434+ var idProp = modelClass . definition . properties [ idName ] ;
435+ if ( idProp && idProp . generated && this . connector . getDefaultIdType ) {
436+ // Set the default id type from connector's ability
437+ var idType = this . connector . getDefaultIdType ( ) || String ;
438+ idProp . type = idType ;
439+ }
440+ if ( this . connector . define ) {
441+ // pass control to connector
442+ this . connector . define ( {
443+ model : modelClass ,
444+ properties : modelClass . definition . properties ,
445+ settings : settings
446+ } ) ;
447+ }
438448 }
439449
440450 // add data access objects
@@ -567,6 +577,14 @@ DataSource.prototype.getModelDefinition = function (name) {
567577 return this . modelBuilder . getModelDefinition ( name ) ;
568578} ;
569579
580+ /**
581+ * Get the data source type
582+ * @returns {String } The data source type, such as db/relational, db/nosql, rest
583+ */
584+ DataSource . prototype . getType = function ( ) {
585+ return this . connector && this . connector . getType ( ) ;
586+ } ;
587+
570588/**
571589 * Attach an existing model to a data source.
572590 *
0 commit comments