event.listen method for Sqlalchemy to set the sequence for this
        object and create an ObjectNumber value for the id_
431659
def before_insert(mapper, conn, target):
        """"""

        target._set_ids()

        if target.name and target.vname and target.cache_key and target.fqname and not target.dataset:
            return

        Partition.before_update(mapper, conn, target)
1047127
def update_object_in_db(self,
                            obj: Any,
                            table: str,
                            fieldlist: Sequence[str]) -> None:
        """"""
        self.ensure_db_open()
        pkvalue = getattr(obj, fieldlist[0])
        valuelist = []
        # Non-PK fields first
        for f in fieldlist[1:]:
            valuelist.append(getattr(obj, f))
        # Then PK
        valuelist.append(pkvalue)
        cursor = self.db.cursor()
        self.db_exec_with_cursor(
            cursor,
            get_sql_update_by_first_field(table, fieldlist, self.get_delims()),
            *valuelist
        )
825579
def next(cls):
        """"""
        try:
            with db.session.begin_nested():
                obj = cls()
                db.session.add(obj)
        except IntegrityError:  # pragma: no cover
            with db.session.begin_nested():
                # Someone has likely modified the table without using the
                # models API. Let's fix the problem.
                cls._set_sequence(cls.max())
                obj = cls()
                db.session.add(obj)
        return obj.recid
731949
def model_post_save(sender, instance, created=False, **kwargs):
    

    if sender._meta.app_label == 'rest_framework_reactive':
        # Ignore own events.
        return

    def notify():
        table = sender._meta.db_table
        if created:
            notify_observers(table, ORM_NOTIFY_KIND_CREATE, instance.pk)
        else:
            notify_observers(table, ORM_NOTIFY_KIND_UPDATE, instance.pk)

    transaction.on_commit(notify)
369449
def next_sequence_value(sequence_name)
      # if sequence_name is set to :autogenerated then it means that primary key will be populated by trigger
      return nil if sequence_name == AUTOGENERATED_SEQUENCE_NAME
      sequence_name = quote_table_name(sequence_name)
      sql = "SELECT #{sequence_name}.NEXTVAL id FROM dual"
      log(sql, 'SQL') { @connection.next_sequence_value(sequence_name) }
    end
382101
def trigger(self, attr, old, new, hint=None, setter=None):
        ''' 

        '''
        def invoke():
            callbacks = self._callbacks.get(attr)
            if callbacks:
                for callback in callbacks:
                    callback(attr, old, new)
        if hasattr(self, '_document') and self._document is not None:
            self._document._notify_change(self, attr, old, new, hint, setter, invoke)
        else:
            invoke()
284186
def listen(obj, name, func):
    
    signals = vars(obj).setdefault('_signals', {})
    signals.setdefault(name, []).append(func)
1005149
def update_id(self, sequence_id=None, force=True):
        """"""
        from ..identity import ObjectNumber

        if sequence_id:
            self.sequence_id = sequence_id

        assert self.d_vid

        if self.id is None or force:
            dataset_id = ObjectNumber.parse(self.d_vid).rev(None)
            self.d_id = str(dataset_id)
            self.id = str(TableNumber(dataset_id, self.sequence_id))

        if self.vid is None or force:
            dataset_vid = ObjectNumber.parse(self.d_vid)
            self.vid = str(TableNumber(dataset_vid, self.sequence_id))
650534
function(td, options) {
      var expected = options.indexes.expected[options.sequenceIndex] !== null;
      var exists = options.dataIndex !== null;
      td.setAttribute('data-expected', expected === exists ? 'yes' : 'no');
    }
351050
def _initialize(self, chain, length):
        
        # If this db was loaded from the disk, it may not have its
        # tallied step methods' getfuncs yet.
        if self._getfunc is None:
            self._getfunc = self.db.model._funs_to_tally[self.name]

        # First, see if the object has an explicit dtype.
        value = np.array(self._getfunc())

        if value.dtype is object:
            self._trace[chain] = zeros(length, dtype=object)

        elif value.dtype is not None:
            self._trace[chain] = zeros((length,) + shape(value), value.dtype)

        # Otherwise, if it's an array, read off its value's dtype.
        elif isinstance(value, ndarray):
            self._trace[chain] = zeros((length,) + shape(value), value.dtype)

        # Otherwise, let numpy type its value. If the value is a scalar, the trace will be of the
        # corresponding type. Otherwise it'll be an object array.
        else:
            self._trace[chain] = zeros(
                (length,
                 ) + shape(value),
                dtype=value.__class__)

        self._index[chain] = 0
301274
def insert_object_into_db_pk_unknown(self,
                                         obj: Any,
                                         table: str,
                                         fieldlist: Sequence[str]) -> None:
        """"""
        self.ensure_db_open()
        valuelist = []
        for f in fieldlist[1:]:
            valuelist.append(getattr(obj, f))
        cursor = self.db.cursor()
        self.db_exec_with_cursor(
            cursor,
            get_sql_insert_without_first_field(table, fieldlist,
                                               self.get_delims()),
            *valuelist
        )
        pkvalue = get_pk_of_last_insert(cursor)
        setattr(obj, fieldlist[0], pkvalue)
674657
public static void generateSubjectNext(SQLiteEntity entity, MethodSpec.Builder methodBuilder,
			SubjectType subjectType, String value) {
		String subInsertType = "";
		if (subjectType == SubjectType.INSERT) {
			if (entity.getPrimaryKey().isType(String.class)) {
				subInsertType = "WithUid";
			} else {
				subInsertType = "WithId";
			}
		}

		methodBuilder.beginControlFlow("if (result>0)");
		methodBuilder.addComment("rx management ");
		methodBuilder.addStatement("subject.onNext($T.create$L$L($L))", SQLiteEvent.class, subjectType.value(),
				subInsertType, value);
		methodBuilder.endControlFlow();
	}
657090
def trigger(self_, *param_names):
        
        events = self_.self_or_cls.param._events
        watchers = self_.self_or_cls.param._watchers
        self_.self_or_cls.param._events  = []
        self_.self_or_cls.param._watchers = []
        param_values = dict(self_.get_param_values())
        params = {name: param_values[name] for name in param_names}
        self_.self_or_cls.param._TRIGGER = True
        self_.set_param(**params)
        self_.self_or_cls.param._TRIGGER = False
        self_.self_or_cls.param._events = events
        self_.self_or_cls.param._watchers = watchers
670578
def set_event_handler(self, event, handler):
        """"""
        # QUESTION: Should we raise an exception if `event` is not in some
        # known event-type list?

        self._prepare_persistence_engine()

        callbacks = self._options.get('callbacks', {})
        callbacks[event] = handler
        self._options['callbacks'] = callbacks
97098
def subscribe(obj, event, callback, event_state=None):
    
    if inspect.isclass(obj):
        cls = obj.__name__
    else:
        cls = obj.__class__.__name__

    if event_state is None:
        event_state = states.ANY

    event_key = '.'.join([cls, event, event_state])
    if event_key not in EVENT_HANDLERS:
        EVENT_HANDLERS[event_key] = []

    EVENT_HANDLERS[event_key].append(callback)
    return
653188
function createListener(db, e, object) {
  function listener(err) {
    if (object.listeners(e).length > 0) {
      object.emit(e, err, db);

      // Emit on all associated db's if available
      for (let i = 0; i < db.s.children.length; i++) {
        db.s.children[i].emit(e, err, db.s.children[i]);
      }
    }
  }
  return listener;
}
244320
private void addTableSequence(NextValueRequest request) {
		IdSourceKeyMetadata idSourceKeyMetadata = request.getKey().getMetadata();
		String query = "MERGE (n" + labels( idSourceKeyMetadata.getName(), NodeLabel.TABLE_BASED_SEQUENCE.name() ) + " { " + idSourceKeyMetadata.getKeyColumnName() + ": {"
				+ SEQUENCE_NAME_QUERY_PARAM + "}} ) ON CREATE SET n." + idSourceKeyMetadata.getValueColumnName() + " = {" + INITIAL_VALUE_QUERY_PARAM + "} RETURN n";
		neo4jDb.execute( query, params( request ) );
	}