chicken-sloths / bangazon-api-sprint1

API for a mock Amazon + Etsy platform providing developers access to the company's employee & product data
0 stars 0 forks source link

Escape Single Quotes in Faker String #80

Closed TimAConner closed 6 years ago

TimAConner commented 6 years ago

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

  1. 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.
  2. Run npm run db:generate
  3. There should be no errors.
kenziebottoms commented 6 years ago

fixes #79