Skip to content

Commit

Permalink
bug fix backup to sql
Browse files Browse the repository at this point in the history
  • Loading branch information
budiadiono committed Feb 10, 2019
1 parent 74bdb50 commit be88734
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,17 @@ export class Table<M, T extends ConstructorClass<M>, TDb> extends Dialect<
return ''
}

// build ordered column names
const keys = Object.keys(values[0])

// build insert values sql
const sql = `INSERT INTO ${tbl} (${cols}) VALUES ${values
const sql = `INSERT INTO ${tbl} (${keys
.map(c => Utils.quote(c))
.join(', ')}) VALUES ${values
.map(value => {
return (
'(' +
Object.keys(value)
keys
.map(col =>
Utils.asRawValue(this.info.columns[col].type, value[col])
)
Expand Down

0 comments on commit be88734

Please sign in to comment.