Don't replicate property that is normally replicated: ordering column,
    many-to-one relation that is marked for replication from other side.
484664
def exclude(prop):
    ''''''
    if isinstance(prop, QueryableAttribute):
        prop = prop.property
    assert isinstance(prop, (Column, ColumnProperty, RelationshipProperty))
    _excluded.add(prop)
    if isinstance(prop, RelationshipProperty):
        # Also exclude columns that participate in this relationship
        for local in prop.local_columns:
            _excluded.add(local)
987690
private static void addOrderPossiblyNested(AbstractHibernateDatastore datastore, Criteria c, Class<?> targetClass, String sort, String order, boolean ignoreCase) {
        int firstDotPos = sort.indexOf(".");
        if (firstDotPos == -1) {
            addOrder(c, sort, order, ignoreCase);
        } else { // nested property
            String sortHead = sort.substring(0,firstDotPos);
            String sortTail = sort.substring(firstDotPos+1);
            PersistentProperty property = getGrailsDomainClassProperty(datastore, targetClass, sortHead);
            if (property instanceof Embedded) {
                // embedded objects cannot reference entities (at time of writing), so no more recursion needed
                addOrder(c, sort, order, ignoreCase);
            } else if(property instanceof Association) {
                Criteria subCriteria = c.createCriteria(sortHead);
                Class<?> propertyTargetClass = ((Association)property).getAssociatedEntity().getJavaClass();
                GrailsHibernateUtil.cacheCriteriaByMapping(datastore, propertyTargetClass, subCriteria);
                addOrderPossiblyNested(datastore, subCriteria, propertyTargetClass, sortTail, order, ignoreCase); // Recurse on nested sort
            }
        }
    }
377580
function buildOrderArray (order) {
    var direction = ''
    // check if last element is asc/desc
    if (order[order.length - 1].match(/^asc|desc$/i)) {
        var direction = order.pop().toUpperCase()
    }
    // join columns together and add direction
    this.order.push(
        _.map(order, columnName => {
            // split column on . to see if it has prefix
            var parts = columnName.split('.')
            // column does not have prefix
            if (parts.length === 1) {
                return this.alias+'.'+this.quoteName(this.model.columnName(columnName, true))
            }
            // column has prefix
            else if (parts.length === 2) {
                var prefix = parts[0]
                columnName = parts[1]
                // prefix must be for joined model
                assert.ok(this.joinRelations[prefix])
                // get join for table prefix
                var join = this.joinRelations[prefix]
                // get relation for model
                var relation = this.model.relation(prefix)
                // return order sql
                return join.relationAlias+'.'+this.quoteName(relation.model.columnName(columnName, true))
            }
            // error
            else {
                throw new Error('invalid column in order '+columnName)
            }
        }).join(', ')+' '+direction
    )
}
415376
def ReorderByColumn( self, column ):
        """"""
        # TODO: store current selection and re-select after sorting...
        single_column = self.SetNewOrder( column )
        self.reorder( single_column = True )
        self.Refresh()
758409
def _fix_slicing_order(self, outer_fields, inner_select, order, inner_table_name):
        
        # Using ROW_NUMBER requires an ordering
        if order is None:
            meta = self.query.get_meta()
            column = meta.pk.db_column or meta.pk.get_attname()
            order = '{0}.{1} ASC'.format(
                inner_table_name,
                self.connection.ops.quote_name(column),
            )
        else:
            alias_id = 0
            # remap order for injected subselect
            new_order = []
            for x in order.split(','):
                # find the ordering direction
                m = _re_find_order_direction.search(x)
                if m:
                    direction = m.groups()[0]
                else:
                    direction = 'ASC'
                # remove the ordering direction
                x = _re_find_order_direction.sub('', x)
                # remove any namespacing or table name from the column name
                col = x.rsplit('.', 1)[-1]
                # Is the ordering column missing from the inner select?
                # 'inner_select' contains the full query without the leading 'SELECT '.
                # It's possible that this can get a false hit if the ordering
                # column is used in the WHERE while not being in the SELECT. It's
                # not worth the complexity to properly handle that edge case.
                if x not in inner_select:
                    # Ordering requires the column to be selected by the inner select
                    alias_id += 1
                    # alias column name
                    col = '{left_sql_quote}{0}___o{1}{right_sql_quote}'.format(
                        col.strip(self.connection.ops.left_sql_quote+self.connection.ops.right_sql_quote),
                        alias_id,
                        left_sql_quote=self.connection.ops.left_sql_quote,
                        right_sql_quote=self.connection.ops.right_sql_quote,
                    )
                    # add alias to inner_select
                    inner_select = '({0}) AS {1}, {2}'.format(x, col, inner_select)
                new_order.append('{0}.{1} {2}'.format(inner_table_name, col, direction))
            order = ', '.join(new_order)
        return outer_fields, inner_select, order
1328092
def ordered_uniqify(sequence):
    

    items = set()
    return [key for key in sequence if key not in items and not items.add(key)]
316756
def replicate_from(other_db, continuous = false, create_target = false, doc_ids = nil)
      replicate(other_db, continuous, :target => name, :create_target => create_target, :doc_ids => doc_ids)
    end
39088
public void setOrderBy(OrderBy ordering) throws TupleMRException {
    failIfNull(ordering, "OrderBy can't be null");
    failIfEmpty(ordering.getElements(), "OrderBy can't be empty");
    failIfEmpty(schemas, "Need to specify source schemas");
    failIfEmpty(groupByFields, "Need to specify group by fields");
    if (schemas.size() == 1) {
      if (ordering.getSchemaOrderIndex() != null) {
        throw new TupleMRException(
            "Not able to use source order when just one source specified");
      }
    }
    Schema firstSchema = schemas.get(0);

    for (SortElement sortElement : ordering.getElements()) {
      if (!fieldPresentInAllSchemas(sortElement.getName())) {
        throw new TupleMRException("Can't sort by field '" + sortElement.getName()
            + "' . Not present in all sources");
      }
      if (!fieldSameTypeInAllSources(sortElement.getName())) {
        throw new TupleMRException("Can't sort by field '" + sortElement.getName()
            + "' since its type differs among sources");
      }

      if (sortElement.getCustomComparator() != null) {
        Field field = firstSchema.getField(sortElement.getName());
        if (field.getType() != Type.OBJECT) {
          throw new TupleMRException("Not allowed to specify custom comparator for type=" + field.getType());
        }
      }
    }
    // group by fields need to be a prefix of sort by fields
    for (String groupField : groupByFields) {
      if (!ordering.containsBeforeSchemaOrder(groupField)) {
        throw new TupleMRException("Group by field '" + groupField
            + "' is not present in common order by before source order");
      }
    }

    this.commonOrderBy = ordering;
  }
66989
def shift_ordering_up(self, parent_id, position, db_session=None, *args, **kwargs):
        
        return self.service.shift_ordering_up(
            parent_id=parent_id,
            position=position,
            db_session=db_session,
            *args,
            **kwargs
        )
202064
def take_ordereds_out_of_turn(self) -> tuple:
        
        for replica in self._replicas.values():
            yield replica.instId, replica._remove_ordered_from_queue()
1351288
def shift_ordering_down(
        self, parent_id, position, db_session=None, *args, **kwargs
    ):
        
        return self.service.shift_ordering_down(
            parent_id=parent_id,
            position=position,
            db_session=db_session,
            *args,
            **kwargs
        )
405863
def sort(self, column, order=Qt.AscendingOrder):
        """"""
        self.sourceModel().sort(column, order)
867636
private List<ColumnRelation> getIndexedColumnRelations(String tableAlias, String foreignTableAlias, Map<String, String> tableAliases, ColumnRelationsStorage columnRelations) {
        List<ColumnRelation> ret = new ArrayList<>();
        List<ColumnRelation> matchedRelations = columnRelations.getRelations(tableAlias, foreignTableAlias);
        boolean hasColumnRelations = !matchedRelations.isEmpty();
        if (hasColumnRelations) {
            matchedRelations.forEach(matchedColumnRelation -> {
                for (ColumnRelation columnRelation : matchedColumnRelation.toList()) {
                    String leftTableName = tableAliases.get(columnRelation.getLeftTableAlias());
                    IndexSignature leftIndexSignature = new IndexSignature(leftTableName, Collections.singleton(columnRelation.getLeftColumn()));
                    String rightTableName = tableAliases.get(columnRelation.getRightTableAlias());
                    IndexSignature rightIndexSignature = new IndexSignature(rightTableName, Collections.singleton(columnRelation.getRightColumn()));
                    if (
                            !indexStorage.getSignatures().contains(leftIndexSignature) ||
                            !indexStorage.getSignatures().contains(rightIndexSignature)
                    ) {
                        return;
                    }
                }
                ret.add(matchedColumnRelation);
                columnRelations.removeRelation(tableAlias, foreignTableAlias, matchedColumnRelation);
            });
        }
        return ret;
    }
1024465
public Criteria copy(boolean includeGroupBy, boolean includeOrderBy, boolean includePrefetchedRelationships)
    {
        Criteria copy = new Criteria();

        copy.m_criteria = new Vector(this.m_criteria);
        copy.m_negative = this.m_negative;

        if (includeGroupBy)
        {
            copy.groupby = this.groupby;
        }
        if (includeOrderBy)
        {
            copy.orderby = this.orderby;
        }
        if (includePrefetchedRelationships)
        {
            copy.prefetchedRelationships = this.prefetchedRelationships;
        }

        return copy;
    }
418101
def order_by(self, field, orientation='ASC'):
        
        if isinstance(field, list):
            self.raw_order_by.append(field)
        else:
            self.raw_order_by.append([field, orientation])

        return self
253942
def if_exists(self):
        
        if self.model._has_counter:
            raise IfExistsWithCounterColumn('if_exists cannot be used with tables containing counter columns')
        clone = copy.deepcopy(self)
        clone._if_exists = True
        return clone
957994
public OrderingList<S> concat(OrderingList<S> other) {
        if (size() == 0) {
            return other;
        }
        OrderingList<S> newList = this;
        if (other.size() > 0) {
            for (OrderedProperty<S> property : other) {
                newList = newList.concat(property);
            }
        }
        return newList;
    }