Create a new pivot model instance.
194841
def new_pivot(self, attributes=None, exists=False):
        
        from .morph_pivot import MorphPivot

        pivot = MorphPivot(self._parent, attributes, self._table, exists)

        pivot.set_pivot_keys(self._foreign_key, self._other_key)\
            .set_morph_type(self._morph_type)\
            .set_morph_class(self._morph_class)

        return pivot
676548
def create_new(cls, oldvalue, *args):
    ""
    if oldvalue is not None:
        raise AlreadyExistsException('%r already exists' % (oldvalue,))
    return cls.create_instance(*args)
1342196
def set_pivot_keys(self, foreign_key, other_key):
        
        self.__foreign_key = foreign_key
        self.__other_key = other_key

        return self
760250
public function newPivot(Model $parent, array $attributes, $table, $exists, $using = null)
    {
        $className = $using ?: Pivot::class;

        return new $className($parent, $attributes, $table, $exists);
    }
1230584
def create(img_rows, img_cols, img_channels, num_classes):
    
    def instantiate(**_):
        return Net(img_rows, img_cols, img_channels, num_classes)
    return ModelFactory.generic(instantiate)
247398
def new_pivot(self, attributes=None, exists=False):
        
        from .morph_pivot import MorphPivot

        pivot = MorphPivot(self._parent, attributes, self._table, exists)

        pivot.set_pivot_keys(self._foreign_key, self._other_key).set_morph_type(
            self._morph_type
        ).set_morph_name(self._morph_name)

        return pivot
1006444
def create(self, _attributes=None, **attributes):
        
        if _attributes is not None:
            attributes.update(_attributes)

        instance = self._related.new_instance(attributes)

        self._set_foreign_attributes_for_create(instance)

        instance.save()

        return instance
794453
def _hydrate_pivot_relation(self, models):
        
        for model in models:
            pivot = self.new_existing_pivot(self._clean_pivot_attributes(model))

            model.set_relation("pivot", pivot)
1165892
def create_columns(self):
        """"""
        reader = self._get_csv_reader()
        headings = six.next(reader)
        try:
            examples = six.next(reader)
        except StopIteration:
            examples = []

        found_fields = set()
        for i, value in enumerate(headings):
            if i >= 20:
                break

            infer_field = self.has_headings and value not in found_fields

            to_field = (
                {
                    "date": "date",
                    "amount": "amount",
                    "description": "description",
                    "memo": "description",
                    "notes": "description",
                }.get(value.lower(), "")
                if infer_field
                else ""
            )

            if to_field:
                found_fields.add(to_field)

            TransactionCsvImportColumn.objects.update_or_create(
                transaction_import=self,
                column_number=i + 1,
                column_heading=value if self.has_headings else "",
                to_field=to_field,
                example=examples[i].strip() if examples else "",
            )
1280391
def create(self, model):
        

        signals.pre_create.send(model.__class__, model=model)
        signals.pre_save.send(model.__class__, model=model)

        param = self.to_pg(model)
        query = """
                INSERT INTO {table} ({dirty_cols})
                VALUES ({dirty_vals})
                RETURNING {cols};
                """

        query = query.format(
            cols=self.field_cols(model),
            dirty_cols=self.dirty_cols(model),
            dirty_vals=self.dirty_vals(model),
            table=model.rtype,
        )

        result = self.query(query, param=param)

        signals.post_create.send(model.__class__, model=model)
        signals.post_save.send(model.__class__, model=model)

        return model.merge(result[0], clean=True)
1355516
def update_existing_pivot(self, id, attributes, touch=True):
        
        if self.updated_at() in self._pivot_columns:
            attributes = self.set_timestamps_on_attach(attributes, True)

        updated = self._new_picot_statement_for_id(id).update(attributes)

        if touch:
            self.touch_if_touching()

        return updated
749407
function createInstances(seqObj, models, config, done) {
    Object.keys(models).forEach((key) => {
      let modelObj = models[key],
        attributes = {},
        options = thorin.util.extend({}, modelObj.options);
      modelObj.privateAttributes = [];
      // map the attributes
      Object.keys(modelObj.fields).forEach((fieldName) => {
        let fieldOpt = modelObj.fields[fieldName];
        if (modelObj.getters[fieldName]) {
          fieldOpt.get = modelObj.getters[fieldName];
        }
        if (modelObj.setters[fieldName]) {
          fieldOpt.set = modelObj.setters[fieldName];
        }
        if (fieldOpt.private) {
          modelObj.privateAttributes.push(fieldName);
        }
        attributes[fieldName] = fieldOpt;
      });
      if (options.createdAt === true) options.createdAt = 'created_at';
      if (options.updatedAt === true) {
        options.updatedAt = 'updated_at';
        if (!attributes[options.updatedAt]) {
          attributes[options.updatedAt] = {
            defaultValue: null,
            allowNull: true,
            type: sequelize.DATE
          }
        }
      }
      if (options.deletedAt === true) {
        options.deletedAt = 'deleted_at';
        if (!attributes[options.deletedAt]) {
          attributes[options.deletedAt] = {
            defaultValue: null,
            allowNull: true,
            type: sequelize.DATE
          }
        }
      }
      // create the inner options.
      options.underscored = true;
      options.charset = config.options.charset || 'utf8';
      options.collate = config.options.collate || 'utf8_general_ci';
      options.tableName = modelObj.tableName;
      options.indexes = modelObj.indexes;
      options.instanceMethods = modelObj.methods;
      options.classMethods = modelObj.statics;
      options.hooks = modelObj.hooks;
      options.validate = {};
      let validatorId = 0;
      // set validations
      modelObj.validations.forEach((item) => {
        if (item.name) { // we have a field validator.
          if (!attributes[item.name]) {
            console.warn('Thorin.sql: model ' + key + " does not have field " + item.name + ' for validator.');
            return;
          }
          if (!attributes[item.name].validate) attributes[item.name].validate = {};
          attributes[item.name].validate['validate' + item.name + validatorId] = item.fn;
          validatorId++;
          return;
        }
        // we have a model validator.
        options.validate['thorinValidate' + validatorId] = item.fn;
        validatorId++;
      });

      // wrap the toJSON function to exclude private fields.
      function ToJSON(jsonName) {
        if (jsonName === 'result') jsonName = 'default';
        let args = Array.prototype.slice.call(arguments);
        if (typeof jsonName === 'undefined') {
          jsonName = 'default';
        } else if (typeof jsonName === 'string') {
          args.splice(0, 1);  //remove the name.
        }
        let jsonFn = modelObj.jsons[jsonName],
          result = this.dataValues;
        if (typeof jsonFn === 'undefined' && jsonName !== 'default') { // silent fallback
          if (typeof modelObj.jsons['default'] === 'function') {
            result = modelObj.jsons['default'].apply(this, args);
          }
        } else {
          if (typeof modelObj.jsons[jsonName] === 'function') {
            result = modelObj.jsons[jsonName].apply(this, args);
          } else {
            result = this.dataValues;
          }
        }
        if (result === this) {
          result = this.dataValues;
        }
        if (typeof result === 'object' && result != null) {
          for (let i = 0; i < modelObj.privateAttributes.length; i++) {
            if (typeof result[modelObj.privateAttributes[i]] !== 'undefined') {
              delete result[modelObj.privateAttributes[i]];
            }
          }
        }
        return result;
      }

      options.instanceMethods['toJSON'] = ToJSON;
      // we do a synonym to .json()
      options.instanceMethods['json'] = ToJSON;

      // Check model prefix
      if (typeof modelObj.prefix === 'string' && typeof options.tableName === 'string') {
        options.tableName = modelObj.prefix + options.tableName;
      }
      var modelInstance;
      try {
        modelInstance = seqObj.define(modelObj.code, attributes, options);
      } catch (e) {
        console.error('Thorin.sql: could not create sequelize schema for: ' + modelObj.code + '\n', e.stack);
        return;
      }
      if (typeof attributes['id'] === 'undefined') {
        if (modelObj.options.primaryKey === false) {
          modelInstance.removeAttribute('id');
        }
      }
      modelObj.setInstance(modelInstance);
    });
    done();
  }
563746
def create(blocks, mode='basic', inplanes=64, cardinality=4, image_features=64, divisor=4, num_classes=1000):
    
    block_dict = {
        # 'basic': BasicBlock,
        'bottleneck': ResNeXtBottleneck
    }

    def instantiate(**_):
        return ResNeXt(block_dict[mode], blocks, inplanes=inplanes, image_features=image_features, cardinality=cardinality, divisor=divisor, num_classes=num_classes)

    return ModelFactory.generic(instantiate)
1345263
public function newPivot(Model $parent, array $attributes, $table, $exists, $using = null)
    {
        $permissionModel = app()['config']->get('defender.permission_model');

        if ($parent instanceof $permissionModel) {
            return PermissionRolePivot::fromAttributes($parent, $attributes, $table, $exists);
        }

        return parent::newPivot($parent, $attributes, $table, $exists, $using);
    }
446147
def create(self, ex):
    ""
    if ex.name in self:
      if ex.nexists: return
      raise ValueError('table_exists',ex.name)
    if any(c.pkey for c in ex.cols):
      if ex.pkey:
        raise sqparse2.SQLSyntaxError("don't mix table-level and column-level pkeys",ex)
      # todo(spec): is multi pkey permitted when defined per column?
      ex.pkey = sqparse2.PKeyX([c.name for c in ex.cols if c.pkey])
    if ex.inherits:
      # todo: what if child table specifies constraints etc? this needs work.
      if len(ex.inherits) > 1: raise NotImplementedError('todo: multi-table inherit')
      parent = self[ex.inherits[0]] = copy.deepcopy(self[ex.inherits[0]]) # copy so rollback works
      child = self[ex.name] = table.Table(ex.name, parent.fields, parent.pkey)
      parent.child_tables.append(child)
      child.parent_table = parent
    else:
      self[ex.name]=table.Table(ex.name,ex.cols,ex.pkey.fields if ex.pkey else [])
6838
public function newPivot(Model $parent, array $attributes, $table, $exists)
	{
		return new Pivot($parent, $attributes, $table, $exists);
	}
6117
def _new_pivot_query(self):
        
        query = super(MorphToMany, self)._new_pivot_query()

        return query.where(self._morph_type, self._morph_class)