UNPKG

sequelize

Version:

Multi dialect ORM for Node.JS/io.js

1,294 lines (1,293 loc) 184 kB
{ "type": "File", "start": 0, "end": 1397, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 49, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 1397, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 49, "column": 0 } }, "sourceType": "module", "body": [ { "type": "VariableDeclaration", "start": 141, "end": 169, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 11, "column": 28 } }, "declarations": [ { "type": "VariableDeclarator", "start": 147, "end": 168, "loc": { "start": { "line": 11, "column": 6 }, "end": { "line": 11, "column": 27 } }, "id": { "type": "Identifier", "start": 147, "end": 148, "loc": { "start": { "line": 11, "column": 6 }, "end": { "line": 11, "column": 7 }, "identifierName": "_" }, "name": "_", "leadingComments": null }, "init": { "type": "CallExpression", "start": 151, "end": 168, "loc": { "start": { "line": 11, "column": 10 }, "end": { "line": 11, "column": 27 } }, "callee": { "type": "Identifier", "start": 151, "end": 158, "loc": { "start": { "line": 11, "column": 10 }, "end": { "line": 11, "column": 17 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 159, "end": 167, "loc": { "start": { "line": 11, "column": 18 }, "end": { "line": 11, "column": 26 } }, "extra": { "rawValue": "lodash", "raw": "'lodash'" }, "value": "lodash" } ] }, "leadingComments": null } ], "kind": "const", "leadingComments": [ { "type": "CommentBlock", "value": "*\n Returns an object that treats MySQL's inabilities to do certain queries.\n\n @class QueryInterface\n @static\n @private\n ", "start": 15, "end": 139, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 9, "column": 3 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n A wrapper that fixes MySQL's inability to cleanly remove columns from existing tables if they have a foreign key constraint.\n\n @method removeColumn\n @for QueryInterface\n\n @param {String} tableName The name of the table.\n @param {String} columnName The name of the attribute that we want to remove.\n @param {Object} options\n @private\n ", "start": 171, "end": 531, "loc": { "start": { "line": 13, "column": 0 }, "end": { "line": 23, "column": 3 } } } ] }, { "type": "FunctionDeclaration", "start": 532, "end": 1359, "loc": { "start": { "line": 24, "column": 0 }, "end": { "line": 47, "column": 1 } }, "id": { "type": "Identifier", "start": 541, "end": 553, "loc": { "start": { "line": 24, "column": 9 }, "end": { "line": 24, "column": 21 }, "identifierName": "removeColumn" }, "name": "removeColumn", "leadingComments": null }, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 554, "end": 563, "loc": { "start": { "line": 24, "column": 22 }, "end": { "line": 24, "column": 31 }, "identifierName": "tableName" }, "name": "tableName" }, { "type": "Identifier", "start": 565, "end": 575, "loc": { "start": { "line": 24, "column": 33 }, "end": { "line": 24, "column": 43 }, "identifierName": "columnName" }, "name": "columnName" }, { "type": "Identifier", "start": 577, "end": 584, "loc": { "start": { "line": 24, "column": 45 }, "end": { "line": 24, "column": 52 }, "identifierName": "options" }, "name": "options" } ], "body": { "type": "BlockStatement", "start": 586, "end": 1359, "loc": { "start": { "line": 24, "column": 54 }, "end": { "line": 47, "column": 1 } }, "body": [ { "type": "ExpressionStatement", "start": 590, "end": 614, "loc": { "start": { "line": 25, "column": 2 }, "end": { "line": 25, "column": 26 } }, "expression": { "type": "AssignmentExpression", "start": 590, "end": 613, "loc": { "start": { "line": 25, "column": 2 }, "end": { "line": 25, "column": 25 } }, "operator": "=", "left": { "type": "Identifier", "start": 590, "end": 597, "loc": { "start": { "line": 25, "column": 2 }, "end": { "line": 25, "column": 9 }, "identifierName": "options" }, "name": "options" }, "right": { "type": "LogicalExpression", "start": 600, "end": 613, "loc": { "start": { "line": 25, "column": 12 }, "end": { "line": 25, "column": 25 } }, "left": { "type": "Identifier", "start": 600, "end": 607, "loc": { "start": { "line": 25, "column": 12 }, "end": { "line": 25, "column": 19 }, "identifierName": "options" }, "name": "options" }, "operator": "||", "right": { "type": "ObjectExpression", "start": 611, "end": 613, "loc": { "start": { "line": 25, "column": 23 }, "end": { "line": 25, "column": 25 } }, "properties": [] } } }, "trailingComments": [ { "type": "CommentBlock", "value": " jshint validthis:true ", "start": 618, "end": 645, "loc": { "start": { "line": 27, "column": 2 }, "end": { "line": 27, "column": 29 } } } ] }, { "type": "ReturnStatement", "start": 648, "end": 1357, "loc": { "start": { "line": 28, "column": 2 }, "end": { "line": 46, "column": 7 } }, "argument": { "type": "CallExpression", "start": 655, "end": 1356, "loc": { "start": { "line": 28, "column": 9 }, "end": { "line": 46, "column": 6 } }, "callee": { "type": "MemberExpression", "start": 655, "end": 1214, "loc": { "start": { "line": 28, "column": 9 }, "end": { "line": 43, "column": 9 } }, "object": { "type": "CallExpression", "start": 655, "end": 1204, "loc": { "start": { "line": 28, "column": 9 }, "end": { "line": 42, "column": 6 } }, "callee": { "type": "MemberExpression", "start": 655, "end": 802, "loc": { "start": { "line": 28, "column": 9 }, "end": { "line": 32, "column": 11 } }, "object": { "type": "CallExpression", "start": 655, "end": 790, "loc": { "start": { "line": 28, "column": 9 }, "end": { "line": 31, "column": 5 } }, "callee": { "type": "MemberExpression", "start": 655, "end": 675, "loc": { "start": { "line": 28, "column": 9 }, "end": { "line": 28, "column": 29 } }, "object": { "type": "MemberExpression", "start": 655, "end": 669, "loc": { "start": { "line": 28, "column": 9 }, "end": { "line": 28, "column": 23 } }, "object": { "type": "ThisExpression", "start": 655, "end": 659, "loc": { "start": { "line": 28, "column": 9 }, "end": { "line": 28, "column": 13 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 660, "end": 669, "loc": { "start": { "line": 28, "column": 14 }, "end": { "line": 28, "column": 23 }, "identifierName": "sequelize" }, "name": "sequelize" }, "computed": false, "leadingComments": null }, "property": { "type": "Identifier", "start": 670, "end": 675, "loc": { "start": { "line": 28, "column": 24 }, "end": { "line": 28, "column": 29 }, "identifierName": "query" }, "name": "query" }, "computed": false, "leadingComments": null }, "arguments": [ { "type": "CallExpression", "start": 683, "end": 744, "loc": { "start": { "line": 29, "column": 6 }, "end": { "line": 29, "column": 67 } }, "callee": { "type": "MemberExpression", "start": 683, "end": 721, "loc": { "start": { "line": 29, "column": 6 }, "end": { "line": 29, "column": 44 } }, "object": { "type": "MemberExpression", "start": 683, "end": 702, "loc": { "start": { "line": 29, "column": 6 }, "end": { "line": 29, "column": 25 } }, "object": { "type": "ThisExpression", "start": 683, "end": 687, "loc": { "start": { "line": 29, "column": 6 }, "end": { "line": 29, "column": 10 } } }, "property": { "type": "Identifier", "start": 688, "end": 702, "loc": { "start": { "line": 29, "column": 11 }, "end": { "line": 29, "column": 25 }, "identifierName": "QueryGenerator" }, "name": "QueryGenerator" }, "computed": false }, "property": { "type": "Identifier", "start": 703, "end": 721, "loc": { "start": { "line": 29, "column": 26 }, "end": { "line": 29, "column": 44 }, "identifierName": "getForeignKeyQuery" }, "name": "getForeignKeyQuery" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 722, "end": 731, "loc": { "start": { "line": 29, "column": 45 }, "end": { "line": 29, "column": 54 }, "identifierName": "tableName" }, "name": "tableName" }, { "type": "Identifier", "start": 733, "end": 743, "loc": { "start": { "line": 29, "column": 56 }, "end": { "line": 29, "column": 66 }, "identifierName": "columnName" }, "name": "columnName" } ] }, { "type": "CallExpression", "start": 752, "end": 784, "loc": { "start": { "line": 30, "column": 6 }, "end": { "line": 30, "column": 38 } }, "callee": { "type": "MemberExpression", "start": 752, "end": 760, "loc": { "start": { "line": 30, "column": 6 }, "end": { "line": 30, "column": 14 } }, "object": { "type": "Identifier", "start": 752, "end": 753, "loc": { "start": { "line": 30, "column": 6 }, "end": { "line": 30, "column": 7 }, "identifierName": "_" }, "name": "_" }, "property": { "type": "Identifier", "start": 754, "end": 760, "loc": { "start": { "line": 30, "column": 8 }, "end": { "line": 30, "column": 14 }, "identifierName": "assign" }, "name": "assign" }, "computed": false }, "arguments": [ { "type": "ObjectExpression", "start": 761, "end": 774, "loc": { "start": { "line": 30, "column": 15 }, "end": { "line": 30, "column": 28 } }, "properties": [ { "type": "ObjectProperty", "start": 763, "end": 772, "loc": { "start": { "line": 30, "column": 17 }, "end": { "line": 30, "column": 26 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 763, "end": 766, "loc": { "start": { "line": 30, "column": 17 }, "end": { "line": 30, "column": 20 }, "identifierName": "raw" }, "name": "raw" }, "value": { "type": "BooleanLiteral", "start": 768, "end": 772, "loc": { "start": { "line": 30, "column": 22 }, "end": { "line": 30, "column": 26 } }, "value": true } } ] }, { "type": "Identifier", "start": 776, "end": 783, "loc": { "start": { "line": 30, "column": 30 }, "end": { "line": 30, "column": 37 }, "identifierName": "options" }, "name": "options" } ] } ], "leadingComments": null }, "property": { "type": "Identifier", "start": 796, "end": 802, "loc": { "start": { "line": 32, "column": 5 }, "end": { "line": 32, "column": 11 }, "identifierName": "spread" }, "name": "spread" }, "computed": false, "leadingComments": null }, "arguments": [ { "type": "ArrowFunctionExpression", "start": 803, "end": 1203, "loc": { "start": { "line": 32, "column": 12 }, "end": { "line": 42, "column": 5 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 803, "end": 810, "loc": { "start": { "line": 32, "column": 12 }, "end": { "line": 32, "column": 19 }, "identifierName": "results" }, "name": "results" } ], "body": { "type": "BlockStatement", "start": 814, "end": 1203, "loc": { "start": { "line": 32, "column": 23 }, "end": { "line": 42, "column": 5 } }, "body": [ { "type": "IfStatement", "start": 861, "end": 1024, "loc": { "start": { "line": 34, "column": 6 }, "end": { "line": 37, "column": 7 } }, "test": { "type": "LogicalExpression", "start": 865, "end": 924, "loc": { "start": { "line": 34, "column": 10 }, "end": { "line": 34, "column": 69 } }, "left": { "type": "UnaryExpression", "start": 865, "end": 880, "loc": { "start": { "line": 34, "column": 10 }, "end": { "line": 34, "column": 25 } }, "operator": "!", "prefix": true, "argument": { "type": "MemberExpression", "start": 866, "end": 880, "loc": { "start": { "line": 34, "column": 11 }, "end": { "line": 34, "column": 25 } }, "object": { "type": "Identifier", "start": 866, "end": 873, "loc": { "start": { "line": 34, "column": 11 }, "end": { "line": 34, "column": 18 }, "identifierName": "results" }, "name": "results", "leadingComments": null }, "property": { "type": "Identifier", "start": 874, "end": 880, "loc": { "start": { "line": 34, "column": 19 }, "end": { "line": 34, "column": 25 }, "identifierName": "length" }, "name": "length" }, "computed": false, "leadingComments": null }, "extra": { "parenthesizedArgument": false }, "leadingComments": null }, "operator": "||", "right": { "type": "BinaryExpression", "start": 884, "end": 924, "loc": { "start": { "line": 34, "column": 29 }, "end": { "line": 34, "column": 69 } }, "left": { "type": "MemberExpression", "start": 884, "end": 910, "loc": { "start": { "line": 34, "column": 29 }, "end": { "line": 34, "column": 55 } }, "object": { "type": "MemberExpression", "start": 884, "end": 894, "loc": { "start": { "line": 34, "column": 29 }, "end": { "line": 34, "column": 39 } }, "object": { "type": "Identifier", "start": 884, "end": 891, "loc": { "start": { "line": 34, "column": 29 }, "end": { "line": 34, "column": 36 }, "identifierName": "results" }, "name": "results" }, "property": { "type": "NumericLiteral", "start": 892, "end": 893, "loc": { "start": { "line": 34, "column": 37 }, "end": { "line": 34, "column": 38 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 }, "computed": true }, "property": { "type": "Identifier", "start": 895, "end": 910, "loc": { "start": { "line": 34, "column": 40 }, "end": { "line": 34, "column": 55 }, "identifierName": "constraint_name" }, "name": "constraint_name" }, "computed": false }, "operator": "===", "right": { "type": "StringLiteral", "start": 915, "end": 924, "loc": { "start": { "line": 34, "column": 60 }, "end": { "line": 34, "column": 69 } }, "extra": { "rawValue": "PRIMARY", "raw": "'PRIMARY'" }, "value": "PRIMARY" } }, "leadingComments": null }, "consequent": { "type": "BlockStatement", "start": 926, "end": 1024, "loc": { "start": { "line": 34, "column": 71 }, "end": { "line": 37, "column": 7 } }, "body": [ { "type": "ReturnStatement", "start": 1009, "end": 1016, "loc": { "start": { "line": 36, "column": 8 }, "end": { "line": 36, "column": 15 } }, "argument": null, "leadingComments": [ { "type": "CommentLine", "value": " No foreign key constraints found, so we can remove the column", "start": 936, "end": 1000, "loc": { "start": { "line": 35, "column": 8 }, "end": { "line": 35, "column": 72 } } } ] } ], "directives": [] }, "alternate": null, "leadingComments": [ { "type": "CommentLine", "value": "Exclude primary key constraint", "start": 822, "end": 854, "loc": { "start": { "line": 33, "column": 6 }, "end": { "line": 33, "column": 38 } } } ] }, { "type": "ReturnStatement", "start": 1031, "end": 1197, "loc": { "start": { "line": 38, "column": 6 }, "end": { "line": 41, "column": 8 } }, "argument": { "type": "CallExpression", "start": 1038, "end": 1196, "loc": { "start": { "line": 38, "column": 13 }, "end": { "line": 41, "column": 7 } }, "callee": { "type": "MemberExpression", "start": 1038, "end": 1058, "loc": { "start": { "line": 38, "column": 13 }, "end": { "line": 38, "column": 33 } }, "object": { "type": "MemberExpression", "start": 1038, "end": 1052, "loc": { "start": { "line": 38, "column": 13 }, "end": { "line": 38, "column": 27 } }, "object": { "type": "ThisExpression", "start": 1038, "end": 1042, "loc": { "start": { "line": 38, "column": 13 }, "end": { "line": 38, "column": 17 } } }, "property": { "type": "Identifier", "start": 1043, "end": 1052, "loc": {