returns our join table model
760296
function () {
                if (!this.__joinTableDataset) {
                    var ds = this.__joinTableDataset = this.model.dataset.db.from(this.joinTableName), model = this.model, options = this.__opts;
                    var identifierInputMethod = isUndefined(options.identifierInputMethod) ? model.identifierInputMethod : options.identifierInputMethod,
                        identifierOutputMethod = isUndefined(options.identifierOutputMethod) ? model.identifierOutputMethod : options.identifierOutputMethod;
                    if (identifierInputMethod) {
                        ds.identifierInputMethod = identifierInputMethod;
                    }
                    if (identifierOutputMethod) {
                        ds.identifierOutputMethod = identifierOutputMethod;
                    }
                }
                return this.__joinTableDataset;
            }
460299
def _get_model_objs_to_sync(model_ids_to_sync, model_objs_map, sync_all):
    
    model_objs_to_sync = {}
    for ctype, model_ids_to_sync_for_ctype in model_ids_to_sync.items():
        model_qset = entity_registry.entity_registry.get(ctype.model_class()).queryset

        if not sync_all:
            model_objs_to_sync[ctype] = model_qset.filter(id__in=model_ids_to_sync_for_ctype)
        else:
            model_objs_to_sync[ctype] = [
                model_objs_map[ctype, model_id] for model_id in model_ids_to_sync_for_ctype
            ]

    return model_objs_to_sync
1276480
def get_model(model:nn.Module):
    ""
    return model.module if isinstance(model, (DistributedDataParallel, nn.DataParallel)) else model
153517
def get_sql_for_new_models(apps=None, using=DEFAULT_DB_ALIAS):
    
    connection = connections[using]
    
    # Get a list of already installed *models* so that references work right.
    tables = connection.introspection.table_names()
    seen_models = connection.introspection.installed_models(tables)
    created_models = set()
    pending_references = {}
    
    if apps:
        apps = [models.get_app(a) for a in apps]
    else:
        apps = models.get_apps()
    
    # Build the manifest of apps and models that are to be synchronized
    all_models = [
        (app.__name__.split('.')[-2], [
            m
            for m in models.get_models(app, include_auto_created=True)
            if router.allow_syncdb(using, m)
        ])
        for app in apps
    ]
    
    def model_installed(model):
        opts = model._meta
        converter = connection.introspection.table_name_converter
        db_table_in = (converter(opts.db_table) in tables)
        auto_create_in = (
            opts.auto_created and
            converter(opts.auto_created._meta.db_table) in tables
        )
        return not (db_table_in or auto_create_in)
    
    manifest = SortedDict(
        (app_name, filter(model_installed, model_list))
        for app_name, model_list in all_models
    )
    
    statements = []
    sql = None
    for app_name, model_list in manifest.items():
        for model in model_list:
            # Create the model's database table, if it doesn't already exist.
            sql, references = connection.creation.sql_create_model(
                model,
                no_style(),
                seen_models
            )
            
            seen_models.add(model)
            created_models.add(model)
            statements.append("### New Model: %s.%s" % (
                app_name,
                str(model).replace("'>", "").split(".")[-1]
            ))
            
            for refto, refs in references.items():
                pending_references.setdefault(refto, []).extend(refs)
                if refto in seen_models:
                    sql.extend(
                        connection.creation.sql_for_pending_references(
                            refto,
                            no_style(),
                            pending_references
                        )
                    )
            
            sql.extend(
                connection.creation.sql_for_pending_references(
                    model,
                    no_style(),
                    pending_references
                )
            )
            statements.extend(sql)
    
    custom_sql = None
    for app_name, model_list in manifest.items():
        for model in model_list:
            if model in created_models:
                custom_sql = custom_sql_for_model(
                    model,
                    no_style(),
                    connection
                )
                
                if custom_sql:
                    statements.extend(custom_sql)
    
    index_sql = None
    for app_name, model_list in manifest.items():
        for model in model_list:
            if model in created_models:
                index_sql = connection.creation.sql_indexes_for_model(
                    model,
                    no_style()
                )
                
                if index_sql:
                    statements.extend(index_sql)
    
    return statements
1348024
def get_connected_model_for_table_name(table_name):
    """"""
    for connected_model in get_heroku_connect_models():
        if connected_model.get_heroku_connect_table_name() == table_name:
            return connected_model
    raise LookupError('No connected model found for table %r' % (table_name,))
442785
def result_to_models(self, result):
        
        mysql_result = result['body']['ExecuteMSQLResult']

        if not mysql_result['Errors']:
            obj_result = mysql_result['ResultValue']['ObjectSearchResult']
            if not obj_result['Objects']:
                return []
            objects = obj_result['Objects']['MemberSuiteObject']

            model_list = []
            for obj in objects:
                model = self.ms_object_to_model(obj)
                model_list.append(model)

            return model_list

        else:
            raise ExecuteMSQLError(result)
564533
public function pivotModel()
    {
        if (!isset($this->pivotModel)) {
            $this->pivotModel = $this->modelFactory()->get(Join::class);
        }

        return $this->pivotModel;
    }
130056
private void setJoin(T model) {
        for (JoinParam joinParam : joinParams) {
            try {
                Object leftValue = AnimaUtils.invokeMethod(
                        model,
                        getGetterName(joinParam.getOnLeft()),
                        AnimaUtils.EMPTY_ARG);

                String sql = "SELECT * FROM " + AnimaCache.getTableName(joinParam.getJoinModel()) +
                        " WHERE " + joinParam.getOnRight() + " = ?";

                Field field = model.getClass()
                        .getDeclaredField(joinParam.getFieldName());


                if (field.getType().equals(List.class)) {
                    if (AnimaUtils.isNotEmpty(joinParam.getOrderBy())) {
                        sql += " ORDER BY " + joinParam.getOrderBy();
                    }
                    List<? extends Model> list = this.queryList(joinParam.getJoinModel(), sql, new Object[]{leftValue});
                    AnimaUtils.invokeMethod(model, getSetterName(joinParam.getFieldName()), new Object[]{list});
                }

                if (field.getType().equals(joinParam.getJoinModel())) {
                    Object joinObject = this.queryOne(joinParam.getJoinModel(), sql, new Object[]{leftValue});
                    AnimaUtils.invokeMethod(model, getSetterName(joinParam.getFieldName()), new Object[]{joinObject});
                }
            } catch (NoSuchFieldException e) {
                log.error("Set join error", e);
            }
        }
    }
437720
private function models() {
		$relationships = $dates = [];
		$tables = config('center.tables');

		//loop through once to create relationships between tables
		foreach ($tables as $table) {

			$dates[$table->name] = [];

			if (!isset($relationships[$table->name])) $relationships[$table->name] = [];
			
			foreach ($table->fields as $field) {
				
				//define relationships
				if ($field->type == 'checkboxes') {
	
					//out from this object
					$order_by = [];
					foreach ($tables[$field->source]->order_by as $column=>$direction) {
						$order_by[] = '->orderBy("' . $column . '", "' . $direction . '")';
					}
					$relationships[$table->name][] = '
					public function ' . $tables[$field->source]->name . '() {
						return $this->belongsToMany("LeftRight\Center\Models\\' . $tables[$field->source]->model . '", "' . $field->name . '", "' . RowController::formatKeyColumn($table->name) . '", "' . RowController::formatKeyColumn($tables[$field->source]->name) . '")' . implode($order_by) . ';
					}
					';
				
					//back from the related object
					$order_by = [];
					foreach ($table->order_by as $column=>$direction) {
						$order_by[] = '->orderBy("' . $column . '", "' . $direction . '")';
					}
					$relationships[$tables[$field->source]->name][] = '
					public function ' . $table->name . '() {
						return $this->belongsToMany("LeftRight\Center\Models\\' . $table->model . '", "' . $field->name . '", "' . RowController::formatKeyColumn($tables[$field->source]->name) . '", "' . RowController::formatKeyColumn($table->name) . '")' . implode($order_by) . ';
					}
					';	

				} elseif (in_array($field->type, ['date', 'datetime'])) {

					$dates[$table->name][] = '\'' . $field->name . '\'';
				
				} elseif ($field->type == 'image') {

					//cannot overwrite property
					$relationships[$table->name][] = '
					public function ' . substr($field->name, 0, -3) . '() {
						return $this->hasOne("LeftRight\Center\Models\File", "id", "' . $field->name . '");
					}
					';
				
				} elseif (in_array($field->type, ['select', 'user'])) {
					
					//public function ' . $tables[$field->source]->name . '() {

					//out from this object
					$relationships[$table->name][] = '
					public function ' . substr($field->name, 0, -3) . '() {
						return $this->belongsTo("LeftRight\Center\Models\\' . $tables[$field->source]->model . '", "' . $field->name . '");
					}
					';
	
					//back from the related object
					$relationships[$tables[$field->source]->name][] = '
					public function ' . $table->name . '() {
						return $this->hasMany("LeftRight\Center\Models\\' . $table->model . '", "' . $field->name . '");
					}
					';
				}
			}
		}
		
		//debug
		//dd($relationships);

		//now we must loop through again; the first loop set relationships on other tables
		foreach ($tables as $table) {
			eval('namespace LeftRight\Center\Models;
			use Illuminate\Database\Eloquent\SoftDeletes;
			use Auth;
			use DateTime;
			use DB;
			use Eloquent;

			class ' . $table->model . ' extends Eloquent {
			    ' . (isset($table->fields->deleted_at) ? 'use SoftDeletes;' : '') . '
				public $table      = \'' . $table->name . '\'; //public intentionally
				public $timestamps = false; //going to override if present
				protected $guarded = [];
				protected $dates   = [' . implode(',', $dates[$table->name]) . '];

				public static function boot() {
					parent::boot();
			        static::creating(function($object) {' . 
				        (isset($table->fields->precedence) ? '
						$object->precedence = DB::table(\'' . $table->name . '\')->max(\'precedence\') + 1;
						' : '') .
				        (isset($table->fields->created_by) ? '
						$object->created_by = Auth::id();
						' : '') .
				        ($table->timestamps && isset($table->fields->created_at) ? '
						$object->created_at = new DateTime();
						' : '') .
				        (isset($table->fields->updated_by) ? '
						$object->updated_by = Auth::id();
						' : '') .
				        ($table->timestamps && isset($table->fields->updated_at) ? '
						$object->updated_at = new DateTime();
						' : '') . 
					'});
			        static::updating(function($object) {' . 
			        	(isset($table->fields->updated_by) ? '
						$object->updated_by = Auth::id();
						' : '') .
				        ($table->timestamps && isset($table->fields->updated_at) ? '
						$object->updated_at = new DateTime();
						' : '') . 
			        '});
				}

				public function creator() {
					return $this->belongsTo(\'User\', \'created_by\');
				}

				public function updater() {
					return $this->belongsTo(\'User\', \'updated_by\');
				}

				' . implode(' ', $relationships[$table->name]) . '
			}');
			
		}

	}
347259
private function getRelatedModel()
    {
        $idSuffix = '_id';

        return substr($this->key, 0, strlen($this->key) - strlen($idSuffix));
    }
273498
def get_model():
    
    if not hasattr(g, 'model'):
        g.model = load_model(current_app.config['MODEL_CLS_PATH'],
                             current_app.config['MODEL_CLS_NAME'],
                             current_app.config['MODEL_LOAD_ARGS'])
    return g.model
1099578
def get_object(model, cid, engine_name=None, connection=None):
    
    from uliweb import settings
    
    if not id:
        return 
    
    if not check_enable():
        return
    
    redis = get_redis()
    if not redis: return

    tablename = model._alias or model.tablename
    
    info = settings.get_var('OBJCACHE_TABLES/%s' % tablename, {})
    if info is None:
        return
    
    _id = get_id(engine_name or model.get_engine_name(), tablename, cid)
    try:
        log.debug("Try to find objcache:get:table=%s:id=[%s]" % (tablename, _id))
        if redis.exists(_id):
            v = redis.hgetall(_id)
            o = model.load(v, from_='dump')
            log.debug("Found!")
            return o
        else:
            log.debug("Not Found!")
    except Exception as e:
        log.exception(e)
1186922
def get_column_model(name, model=None):
    
    if '.' in name:
        m, name = name.split('.')
        model = get_model(m)

    if model:
        return model.c.get(name), model
    else:
        return None, None
160900
def create_table(self, model):
        
        self.orm[model._meta.table_name] = model
        model._meta.database = self.database
        self.ops.append(model.create_table)
        return model
1120547
public function join()
	{
		// We do a left outer join here because we're not trying to limit the primary table's results
		// This function is primarily used when needing to sort by a field in the joined table
		$this->model->select($this->model->getQualifiedFieldName('*'))
		            ->join($this->related->getTableName(),
		                   $this->model->getQualifiedFieldName($this->localKey),
		                   $this->related->getQualifiedFieldName($this->relatedKey),
		                   'LEFT OUTER');

		return $this;
	}
49094
def get_schema_model():
    
    try:
        return django_apps.get_model(settings.POSTGRES_SCHEMA_MODEL, require_ready=False)
    except ValueError:
        raise ImproperlyConfigured("POSTGRES_SCHEMA_MODEL must be of the form 'app_label.model_name'")
    except LookupError:
        raise ImproperlyConfigured(
            "POSTGRES_SCHEMA_MODEL refers to model '%s' that has not been installed" % settings.POSTGRES_SCHEMA_MODEL
        )
688286
public static TableModel[] db2Models(Connection con, Dialect dialect) {
		return TableModelUtilsOfDb.db2Models(con, dialect);
	}