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

Method quote

src/dialects/abstract/query-generator.js:869–1025  ·  view source on GitHub ↗
(collection, parent, connector)

Source from the content-addressed store, hash-verified

867 @private
868 */
869 quote(collection, parent, connector) {
870 // init
871 const validOrderOptions = [
872 'ASC',
873 'DESC',
874 'ASC NULLS LAST',
875 'DESC NULLS LAST',
876 'ASC NULLS FIRST',
877 'DESC NULLS FIRST',
878 'NULLS FIRST',
879 'NULLS LAST'
880 ];
881
882 // default
883 connector = connector || '.';
884
885 // just quote as identifiers if string
886 if (typeof collection === 'string') {
887 return this.quoteIdentifiers(collection);
888 }
889 if (Array.isArray(collection)) {
890 // iterate through the collection and mutate objects into associations
891 collection.forEach((item, index) => {
892 const previous = collection[index - 1];
893 let previousAssociation;
894 let previousModel;
895
896 // set the previous as the parent when previous is undefined or the target of the association
897 if (!previous && parent !== undefined) {
898 previousModel = parent;
899 } else if (previous && previous instanceof Association) {
900 previousAssociation = previous;
901 previousModel = previous.target;
902 }
903
904 // if the previous item is a model, then attempt getting an association
905 if (previousModel && previousModel.prototype instanceof Model) {
906 let model;
907 let as;
908
909 if (typeof item === 'function' && item.prototype instanceof Model) {
910 // set
911 model = item;
912 } else if (_.isPlainObject(item) && item.model && item.model.prototype instanceof Model) {
913 // set
914 model = item.model;
915 as = item.as;
916 }
917
918 if (model) {
919 // set the as to either the through name or the model name
920 if (!as && previousAssociation && previousAssociation instanceof Association && previousAssociation.through && previousAssociation.through.model === model) {
921 // get from previous association
922 item = new Association(previousModel, model, {
923 as: model.name
924 });
925 } else {
926 // 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