(attributes, options)
| 673 | } |
| 674 | |
| 675 | attributesToSQL(attributes, options) { |
| 676 | const result = {}, |
| 677 | existingConstraints = []; |
| 678 | let key, |
| 679 | attribute; |
| 680 | |
| 681 | for (key in attributes) { |
| 682 | attribute = attributes[key]; |
| 683 | |
| 684 | if (attribute.references) { |
| 685 | |
| 686 | if (existingConstraints.indexOf(attribute.references.model.toString()) !== -1) { |
| 687 | // no cascading constraints to a table more than once |
| 688 | attribute.onDelete = ''; |
| 689 | attribute.onUpdate = ''; |
| 690 | } else if (attribute.unique && attribute.unique === true) { |
| 691 | attribute.onDelete = ''; |
| 692 | attribute.onUpdate = ''; |
| 693 | } else { |
| 694 | existingConstraints.push(attribute.references.model.toString()); |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | if (key && !attribute.field && typeof attribute === 'object') attribute.field = key; |
| 699 | result[attribute.field || key] = this.attributeToSQL(attribute, options); |
| 700 | } |
| 701 | |
| 702 | return result; |
| 703 | } |
| 704 | |
| 705 | createTrigger() { |
| 706 | throwMethodUndefined('createTrigger'); |
no test coverage detected