MCPcopy
hub / github.com/sequelize/sequelize / quote

Method quote

lib/dialects/abstract/query-generator.js:761–917  ·  view source on GitHub ↗
(collection, parent, connector)

Source from the content-addressed store, hash-verified

759 @private
760 */
761 quote(collection, parent, connector) {
762 // init
763 const validOrderOptions = [
764 'ASC',
765 'DESC',
766 'ASC NULLS LAST',
767 'DESC NULLS LAST',
768 'ASC NULLS FIRST',
769 'DESC NULLS FIRST',
770 'NULLS FIRST',
771 'NULLS LAST'
772 ];
773
774 // default
775 connector = connector || '.';
776
777 // just quote as identifiers if string
778 if (typeof collection === 'string') {
779 return this.quoteIdentifiers(collection);
780 }
781 if (Array.isArray(collection)) {
782 // iterate through the collection and mutate objects into associations
783 collection.forEach((item, index) => {
784 const previous = collection[index - 1];
785 let previousAssociation;
786 let previousModel;
787
788 // set the previous as the parent when previous is undefined or the target of the association
789 if (!previous && parent !== undefined) {
790 previousModel = parent;
791 } else if (previous && previous instanceof Association) {
792 previousAssociation = previous;
793 previousModel = previous.target;
794 }
795
796 // if the previous item is a model, then attempt getting an association
797 if (previousModel && previousModel.prototype instanceof Model) {
798 let model;
799 let as;
800
801 if (typeof item === 'function' && item.prototype instanceof Model) {
802 // set
803 model = item;
804 } else if (_.isPlainObject(item) && item.model && item.model.prototype instanceof Model) {
805 // set
806 model = item.model;
807 as = item.as;
808 }
809
810 if (model) {
811 // set the as to either the through name or the model name
812 if (!as && previousAssociation && previousAssociation instanceof Association && previousAssociation.through && previousAssociation.through.model === model) {
813 // get from previous association
814 item = new Association(previousModel, model, {
815 as: model.name
816 });
817 } else {
818 // get association from previous model

Callers 4

selectQueryMethod · 0.95
aliasGroupingMethod · 0.95
getQueryOrdersMethod · 0.95
handleSequelizeMethodMethod · 0.95

Calls 8

quoteIdentifiersMethod · 0.95
quoteIdentifierMethod · 0.95
quoteTableMethod · 0.95
handleSequelizeMethodMethod · 0.95
formatMethod · 0.80
literalMethod · 0.80
inspectMethod · 0.80

Tested by

no test coverage detected