Skip to content

Commit

Permalink
lib: Improve debug output formatting
Browse files Browse the repository at this point in the history
Don't output the mostly unnecessary "SQL:" line and add a semicolon at the end of the SQL statement.
  • Loading branch information
nwoltman committed Nov 3, 2017
1 parent c6bbfe1 commit a43815f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions lib/PoolPlus.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,7 @@ function debugOperations(operations, debuggingError) {
header +
operations.map(operation =>
'type: ' + opTypeNames.find(typeName => Operation.Types[typeName] === operation.type) +
'\nSQL:\n' +
operation.sql
`\n${operation.sql};`
).join('\n\n') +
'\n\n===================================================\n'
);
Expand Down
9 changes: 3 additions & 6 deletions test/unit/PoolPlus.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -892,17 +892,15 @@ describe('PoolPlus', () => {
'============= mysql-plus operations: ==============',
'',
'type: CREATE_TABLE',
'SQL:',
'CREATE TABLE `pool_plus_test_table_debug_a` (',
' `id` int unsigned NOT NULL,',
' PRIMARY KEY (`id`)',
')',
');',
'',
'type: CREATE_TABLE',
'SQL:',
'CREATE TABLE `pool_plus_test_table_debug_b` (',
' `id` char(1)',
')',
');',
'',
'===================================================',
'',
Expand Down Expand Up @@ -939,9 +937,8 @@ describe('PoolPlus', () => {
'====== mysql-plus sync errored on operation: ======',
'',
'type: ADD_FOREIGN_KEY',
'SQL:',
'ALTER TABLE `pool_plus_test_table_debug_error` ADD CONSTRAINT `fk_pool_plus_test_table_debug_error_id`',
' FOREIGN KEY (`id`) REFERENCES `non_existent_table` (`id`)',
' FOREIGN KEY (`id`) REFERENCES `non_existent_table` (`id`);',
'',
'===================================================',
'',
Expand Down

0 comments on commit a43815f

Please sign in to comment.