UNPKG

sequelize

Version:

Multi dialect ORM for Node.JS/io.js

1,550 lines (1,549 loc) 558 kB
{ "type": "File", "start": 0, "end": 2987, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 105, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 2987, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 105, "column": 0 } }, "sourceType": "module", "body": [ { "type": "VariableDeclaration", "start": 34, "end": 76, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 42 } }, "declarations": [ { "type": "VariableDeclarator", "start": 40, "end": 75, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 41 } }, "id": { "type": "Identifier", "start": 40, "end": 49, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 15 }, "identifierName": "dataTypes" }, "name": "dataTypes", "leadingComments": null }, "init": { "type": "CallExpression", "start": 52, "end": 75, "loc": { "start": { "line": 4, "column": 18 }, "end": { "line": 4, "column": 41 } }, "callee": { "type": "Identifier", "start": 52, "end": 59, "loc": { "start": { "line": 4, "column": 18 }, "end": { "line": 4, "column": 25 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 60, "end": 74, "loc": { "start": { "line": 4, "column": 26 }, "end": { "line": 4, "column": 40 } }, "extra": { "rawValue": "./data-types", "raw": "'./data-types'" }, "value": "./data-types" } ] }, "leadingComments": null } ], "kind": "const", "leadingComments": [ { "type": "CommentBlock", "value": " jshint -W110 ", "start": 15, "end": 33, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 18 } } } ] }, { "type": "VariableDeclaration", "start": 77, "end": 105, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 28 } }, "declarations": [ { "type": "VariableDeclarator", "start": 83, "end": 104, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 27 } }, "id": { "type": "Identifier", "start": 83, "end": 84, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 7 }, "identifierName": "_" }, "name": "_" }, "init": { "type": "CallExpression", "start": 87, "end": 104, "loc": { "start": { "line": 5, "column": 10 }, "end": { "line": 5, "column": 27 } }, "callee": { "type": "Identifier", "start": 87, "end": 94, "loc": { "start": { "line": 5, "column": 10 }, "end": { "line": 5, "column": 17 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 95, "end": 103, "loc": { "start": { "line": 5, "column": 18 }, "end": { "line": 5, "column": 26 } }, "extra": { "rawValue": "lodash", "raw": "'lodash'" }, "value": "lodash" } ] } } ], "kind": "const" }, { "type": "FunctionDeclaration", "start": 107, "end": 2112, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 72, "column": 1 } }, "id": { "type": "Identifier", "start": 116, "end": 122, "loc": { "start": { "line": 7, "column": 9 }, "end": { "line": 7, "column": 15 }, "identifierName": "escape" }, "name": "escape" }, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 123, "end": 126, "loc": { "start": { "line": 7, "column": 16 }, "end": { "line": 7, "column": 19 }, "identifierName": "val" }, "name": "val" }, { "type": "Identifier", "start": 128, "end": 136, "loc": { "start": { "line": 7, "column": 21 }, "end": { "line": 7, "column": 29 }, "identifierName": "timeZone" }, "name": "timeZone" }, { "type": "Identifier", "start": 138, "end": 145, "loc": { "start": { "line": 7, "column": 31 }, "end": { "line": 7, "column": 38 }, "identifierName": "dialect" }, "name": "dialect" }, { "type": "Identifier", "start": 147, "end": 153, "loc": { "start": { "line": 7, "column": 40 }, "end": { "line": 7, "column": 46 }, "identifierName": "format" }, "name": "format" } ], "body": { "type": "BlockStatement", "start": 155, "end": 2112, "loc": { "start": { "line": 7, "column": 48 }, "end": { "line": 72, "column": 1 } }, "body": [ { "type": "VariableDeclaration", "start": 159, "end": 180, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 23 } }, "declarations": [ { "type": "VariableDeclarator", "start": 163, "end": 179, "loc": { "start": { "line": 8, "column": 6 }, "end": { "line": 8, "column": 22 } }, "id": { "type": "Identifier", "start": 163, "end": 171, "loc": { "start": { "line": 8, "column": 6 }, "end": { "line": 8, "column": 14 }, "identifierName": "prependN" }, "name": "prependN" }, "init": { "type": "BooleanLiteral", "start": 174, "end": 179, "loc": { "start": { "line": 8, "column": 17 }, "end": { "line": 8, "column": 22 } }, "value": false } } ], "kind": "let" }, { "type": "IfStatement", "start": 183, "end": 246, "loc": { "start": { "line": 9, "column": 2 }, "end": { "line": 11, "column": 3 } }, "test": { "type": "LogicalExpression", "start": 187, "end": 220, "loc": { "start": { "line": 9, "column": 6 }, "end": { "line": 9, "column": 39 } }, "left": { "type": "BinaryExpression", "start": 187, "end": 204, "loc": { "start": { "line": 9, "column": 6 }, "end": { "line": 9, "column": 23 } }, "left": { "type": "Identifier", "start": 187, "end": 190, "loc": { "start": { "line": 9, "column": 6 }, "end": { "line": 9, "column": 9 }, "identifierName": "val" }, "name": "val" }, "operator": "===", "right": { "type": "Identifier", "start": 195, "end": 204, "loc": { "start": { "line": 9, "column": 14 }, "end": { "line": 9, "column": 23 }, "identifierName": "undefined" }, "name": "undefined" } }, "operator": "||", "right": { "type": "BinaryExpression", "start": 208, "end": 220, "loc": { "start": { "line": 9, "column": 27 }, "end": { "line": 9, "column": 39 } }, "left": { "type": "Identifier", "start": 208, "end": 211, "loc": { "start": { "line": 9, "column": 27 }, "end": { "line": 9, "column": 30 }, "identifierName": "val" }, "name": "val" }, "operator": "===", "right": { "type": "NullLiteral", "start": 216, "end": 220, "loc": { "start": { "line": 9, "column": 35 }, "end": { "line": 9, "column": 39 } } } } }, "consequent": { "type": "BlockStatement", "start": 222, "end": 246, "loc": { "start": { "line": 9, "column": 41 }, "end": { "line": 11, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 228, "end": 242, "loc": { "start": { "line": 10, "column": 4 }, "end": { "line": 10, "column": 18 } }, "argument": { "type": "StringLiteral", "start": 235, "end": 241, "loc": { "start": { "line": 10, "column": 11 }, "end": { "line": 10, "column": 17 } }, "extra": { "rawValue": "NULL", "raw": "'NULL'" }, "value": "NULL" } } ], "directives": [] }, "alternate": null }, { "type": "SwitchStatement", "start": 249, "end": 828, "loc": { "start": { "line": 12, "column": 2 }, "end": { "line": 28, "column": 3 } }, "discriminant": { "type": "UnaryExpression", "start": 257, "end": 267, "loc": { "start": { "line": 12, "column": 10 }, "end": { "line": 12, "column": 20 } }, "operator": "typeof", "prefix": true, "argument": { "type": "Identifier", "start": 264, "end": 267, "loc": { "start": { "line": 12, "column": 17 }, "end": { "line": 12, "column": 20 }, "identifierName": "val" }, "name": "val" }, "extra": { "parenthesizedArgument": false } }, "cases": [ { "type": "SwitchCase", "start": 275, "end": 601, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 20, "column": 24 } }, "consequent": [ { "type": "IfStatement", "start": 495, "end": 576, "loc": { "start": { "line": 17, "column": 6 }, "end": { "line": 19, "column": 7 } }, "test": { "type": "LogicalExpression", "start": 499, "end": 542, "loc": { "start": { "line": 17, "column": 10 }, "end": { "line": 17, "column": 53 } }, "left": { "type": "BinaryExpression", "start": 499, "end": 519, "loc": { "start": { "line": 17, "column": 10 }, "end": { "line": 17, "column": 30 } }, "left": { "type": "Identifier", "start": 499, "end": 506, "loc": { "start": { "line": 17, "column": 10 }, "end": { "line": 17, "column": 17 }, "identifierName": "dialect" }, "name": "dialect", "leadingComments": null }, "operator": "===", "right": { "type": "StringLiteral", "start": 511, "end": 519, "loc": { "start": { "line": 17, "column": 22 }, "end": { "line": 17, "column": 30 } }, "extra": { "rawValue": "sqlite", "raw": "'sqlite'" }, "value": "sqlite" }, "leadingComments": null }, "operator": "||", "right": { "type": "BinaryExpression", "start": 523, "end": 542, "loc": { "start": { "line": 17, "column": 34 }, "end": { "line": 17, "column": 53 } }, "left": { "type": "Identifier", "start": 523, "end": 530, "loc": { "start": { "line": 17, "column": 34 }, "end": { "line": 17, "column": 41 }, "identifierName": "dialect" }, "name": "dialect" }, "operator": "===", "right": { "type": "StringLiteral", "start": 535, "end": 542, "loc": { "start": { "line": 17, "column": 46 }, "end": { "line": 17, "column": 53 } }, "extra": { "rawValue": "mssql", "raw": "'mssql'" }, "value": "mssql" } }, "leadingComments": null }, "consequent": { "type": "BlockStatement", "start": 544, "end": 576, "loc": { "start": { "line": 17, "column": 55 }, "end": { "line": 19, "column": 7 } }, "body": [ { "type": "ReturnStatement", "start": 554, "end": 568, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 22 } }, "argument": { "type": "UnaryExpression", "start": 561, "end": 567, "loc": { "start": { "line": 18, "column": 15 }, "end": { "line": 18, "column": 21 } }, "operator": "+", "prefix": true, "argument": { "type": "UnaryExpression", "start": 562, "end": 567, "loc": { "start": { "line": 18, "column": 16 }, "end": { "line": 18, "column": 21 } }, "operator": "!", "prefix": true, "argument": { "type": "UnaryExpression", "start": 563, "end": 567, "loc": { "start": { "line": 18, "column": 17 }, "end": { "line": 18, "column": 21 } }, "operator": "!", "prefix": true, "argument": { "type": "Identifier", "start": 564, "end": 567, "loc": { "start": { "line": 18, "column": 18 }, "end": { "line": 18, "column": 21 }, "identifierName": "val" }, "name": "val" }, "extra": { "parenthesizedArgument": false } }, "extra": { "parenthesizedArgument": false } }, "extra": { "parenthesizedArgument": false } } } ], "directives": [] }, "alternate": null, "leadingComments": [ { "type": "CommentLine", "value": " SQLite doesn't have true/false support. MySQL aliases true/false to 1/0", "start": 295, "end": 369, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 14, "column": 78 } } }, { "type": "CommentLine", "value": " for us. Postgres actually has a boolean type with true/false literals,", "start": 374, "end": 447, "loc": { "start": { "line": 15, "column": 4 }, "end": { "line": 15, "column": 77 } } }, { "type": "CommentLine", "value": " but sequelize doesn't use it yet.", "start": 452, "end": 488, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 16, "column": 40 } } } ] }, { "type": "ReturnStatement", "start": 583, "end": 601, "loc": { "start": { "line": 20, "column": 6 }, "end": { "line": 20, "column": 24 } }, "argument": { "type": "BinaryExpression", "start": 590, "end": 600, "loc": { "start": { "line": 20, "column": 13 }, "end": { "line": 20, "column": 23 } }, "left": { "type": "StringLiteral", "start": 590, "end": 592, "loc": { "start": { "line": 20, "column": 13 }, "end": { "line": 20, "column": 15 } }, "extra": { "rawValue": "", "raw": "''" }, "value": "" }, "operator": "+", "right": { "type": "UnaryExpression", "start": 595, "end": 600, "loc": { "start": { "line": 20, "column": 18 }, "end": { "line": 20, "column": 23 } }, "operator": "!", "prefix": true, "argument": { "type": "UnaryExpression", "start": 596, "end": 600, "loc": { "start": { "line": 20, "column": 19 }, "end": { "line": 20, "column": 23 } }, "operator": "!", "prefix": true, "argument": { "type": "Identifier", "start": 597, "end": 600, "loc": { "start": { "line": 20, "column": 20 }, "end": { "line": 20, "column": 23 }, "identifierName": "val" }, "name": "val" }, "extra": { "parenthesizedArgument": false } }, "extra": { "parenthesizedArgument": false } } } } ], "test": { "type": "StringLiteral", "start": 280, "end": 289, "loc": { "start": { "line": 13, "column": 9 }, "end": { "line": 13, "column": 18 } }, "extra": { "rawValue": "boolean", "raw": "'boolean'" }, "value": "boolean" } }, { "type": "SwitchCase", "start": 606, "end": 643, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 22, "column": 22 } }, "consequent": [ { "type": "ReturnStatement", "start": 627, "end": 643, "loc": { "start": { "line": 22, "column": 6 }, "end": { "line": 22, "column": 22 } }, "argument": { "type": "BinaryExpression", "start": 634, "end": 642, "loc": { "start": { "line": 22, "column": 13 }, "end": { "line": 22, "column": 21 } }, "left": { "type": "Identifier", "start": 634, "end": 637, "loc": { "start": { "line": 22, "column": 13 }, "end": { "line": 22, "column": 16 }, "identifierName": "val" }, "name": "val" }, "operator": "+", "right": { "type": "StringLiteral", "start": 640, "end": 642, "loc": { "start": { "line": 22, "column": 19 }, "end": { "line": 22, "column": 21 } }, "extra": { "rawValue": "", "raw": "''" }, "value": "" } } } ], "test": { "type": "StringLiteral", "start": 611, "end": 619, "loc": { "start": { "line": 21, "column": 9 }, "end": { "line": 21, "column": 17 } }, "extra": { "rawValue": "number", "raw": "'number'" }, "value": "number" } }, { "type": "SwitchCase", "start": 648, "end": 824, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 27, "column": 12 } }, "consequent": [ { "type": "ExpressionStatement", "start": 780, "end": 811, "loc": { "start": { "line": 26, "column": 6 }, "end": { "line": 26, "column": 37 } }, "expression": { "type": "AssignmentExpression", "start": 780, "end": 810, "loc": { "start": { "line": 26, "column": 6 }, "end": { "line": 26, "column": 36 } }, "operator": "=", "left": { "type": "Identifier", "start": 780, "end": 788, "loc": { "start": { "line": 26, "column": 6 }, "end": { "line": 26, "column": 14 }, "identifierName": "prependN" }, "name": "prependN", "leadingComments": null }, "right": { "type": "BinaryExpression", "start": 791, "end": 810, "loc": { "start": { "line": 26, "column": 17 }, "end": { "line": 26, "column": 36 } }, "left": { "type": "Identifier", "start": 791, "end": 798, "loc": { "start": { "line": 26, "column": 17 }, "end": { "line": 26, "column": 24 }, "identifierName": "dialect" }, "name": "dialect" }, "operator": "===", "right": { "type": "StringLiteral", "start": 803, "end": 810, "loc": { "start": { "line": 26, "column": 29 }, "end": { "line": 26, "column": 36 } }, "extra": { "rawValue": "mssql", "raw": "'mssql'" }, "value": "mssql" } }, "leadingComments": null }, "leadingComments": [ { "type": "CommentLine", "value": " In mssql, prepend N to all quoted vals which are originally a string (for", "start": 667, "end": 743, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 80 } } }, { "type": "CommentLine", "value": " unicode compatibility)", "start": 748, "end": 773, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 25, "column": 29 } } } ] }, { "type": "BreakStatement", "start": 818, "end": 824, "loc": { "start": { "line": 27, "column": 6 }, "end": { "line": 27, "column": 12 } }, "label": null } ], "test": { "type": "StringLiteral", "start": 653, "end": 661, "loc": { "start": { "line": 23, "column": 9 }, "end": { "line": 23, "column": 17 } }, "extra": { "rawValue": "string", "raw": "'string'" }, "value": "string" } } ] }, { "type": "IfStatement", "start": 832, "end": 946, "loc": { "start": { "line": 30, "column": 2 }, "end": { "line": 32, "column": 3 } }, "test": { "type": "BinaryExpression", "start": 836, "end": 855, "loc": { "start": { "line": 30, "column": 6 }, "end": { "line": 30, "column": 25 } }, "left": { "type": "Identifier", "start": 836, "end": 839, "loc": { "start": { "line": 30, "column": 6 }, "end": { "line": 30, "column": 9 }, "identifierName": "val" }, "name": "val" }, "operator": "instanceof", "right": { "type": "Identifier", "start": 851, "end": 855, "loc": { "start": { "line": 30, "column": 21 }, "end": { "line": 30, "column": 25 }, "identifierName": "Date" }, "name": "Date" } }, "consequent": { "type": "BlockStatement", "start": 857, "end": 946, "loc": { "start": { "line": 30, "column": 27 }, "end": { "line": 32, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 863, "end": 942, "loc": { "start": { "line": 31, "column": 4 }, "end": { "line": 31, "column": 83 } }, "expression": { "type": "AssignmentExpression", "start": 863, "end": 941, "loc": { "start": { "line": 31, "column": 4 }, "end": { "line": 31, "column": 82 } }, "operator": "=", "left": { "type": "Identifier", "start": 863, "end": 866, "loc": { "start": { "line": 31, "column": 4 }, "end": { "line": 31, "column": 7 }, "identifierName": "val" }, "name": "val" }, "right": { "type": "CallExpression", "start": 869,