This pull request adds a function that escape single quotes. The function is used to escape single quotes in the sql code that is generated as a string and then ran.
Also moved the adding of the comma between sql values to the end of the function instead of being used in each if statement.
Related Ticket(s)
Fixes the bug in Issue #79 (generateSqlTable() should escape quotes)
Problem to Solve
SQL throwing errors when there is a single quote in the supplied data.
Proposed Changes
Escape all single quotes in string values from the JSON files we are using to create the database.
Expected Behavior
The last_name in Customers "O'Conner" should not throw an error and should be changed to "O''Conner".
Steps to Test Solution
Add ' between O and C in the last_name "OConner" in the customers JSON data. Or add it anywhere in any of the string values.
Description
This pull request adds a function that escape single quotes. The function is used to escape single quotes in the sql code that is generated as a string and then ran.
Also moved the adding of the comma between sql values to the end of the function instead of being used in each if statement.
Related Ticket(s)
Fixes the bug in Issue #79 (generateSqlTable() should escape quotes)
Problem to Solve
SQL throwing errors when there is a single quote in the supplied data.
Proposed Changes
Escape all single quotes in string values from the JSON files we are using to create the database.
Expected Behavior
The last_name in Customers "O'Conner" should not throw an error and should be changed to "O''Conner".
Steps to Test Solution
npm run db:generate