@axiosleo/orm-mysql 0.9.7 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/orm-mysql.js CHANGED
@@ -9,7 +9,7 @@ const app = new App({
9
9
  name: 'MySQL ORM CLI',
10
10
  desc: 'migrate, model, seed, etc.',
11
11
  bin: 'orm-mysql',
12
- version: '0.9.7',
12
+ version: '0.9.8',
13
13
  commands_dir: path.join(__dirname, '../commands'),
14
14
  });
15
15
 
package/index.d.ts CHANGED
@@ -365,7 +365,7 @@ export declare class MigrationInterface {
365
365
  autoIncrement?: boolean,
366
366
  primaryKey?: boolean,
367
367
  uniqIndex?: boolean,
368
- after?: string
368
+ after?: string,
369
369
  }): void;
370
370
 
371
371
  createIndex(tableName: string, columns: string[], options?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiosleo/orm-mysql",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "description": "MySQL ORM tool",
5
5
  "keywords": [
6
6
  "mysql",
package/src/builder.js CHANGED
@@ -150,6 +150,7 @@ class Builder {
150
150
  table = `\`${table}\``;
151
151
  }
152
152
  let sql = '';
153
+ join_type = join_type.toLowerCase();
153
154
  switch (join_type) {
154
155
  case 'left':
155
156
  sql = 'LEFT JOIN ';
@@ -386,20 +387,9 @@ class ManageSQLBuilder extends Builder {
386
387
  }
387
388
 
388
389
  createColumn(options) {
389
- _validate(options, {
390
- table: 'required|string',
391
- name: 'required|string',
392
- type: 'required|string',
393
- length: 'integer',
394
- unsigned: 'boolean',
395
- allowNull: 'boolean',
396
- default: 'string',
397
- comment: 'string',
398
- autoIncrement: 'boolean',
399
- primaryKey: 'boolean',
400
- uniqIndex: 'boolean',
401
- after: 'string'
402
- });
390
+ if (!options.table) {
391
+ throw new Error('Table name is required');
392
+ }
403
393
  return `ALTER TABLE \`${options.table}\` ADD COLUMN ` + this.renderSingleColumn(options);
404
394
  }
405
395
 
@@ -430,6 +420,8 @@ class ManageSQLBuilder extends Builder {
430
420
  }
431
421
 
432
422
  createForeignKey(options) {
423
+ options.reference.onDelete = options.reference.onDelete ? options.reference.onDelete.toUpperCase() : 'NO ACTION';
424
+ options.reference.onUpdate = options.reference.onUpdate ? options.reference.onUpdate.toUpperCase() : 'NO ACTION';
433
425
  _validate(options, {
434
426
  name: 'required|string',
435
427
  table: 'required|string',