firebase-to-supabase icon indicating copy to clipboard operation
firebase-to-supabase copied to clipboard

auth: import issue when displayName includes an '

Open tylermcdonald opened this issue 10 months ago • 1 comments

Bug report

Describe the bug

While using the auth solution in this repo, if you export a list of users to a .json and then attempt to import those users, if any user has a display name with an ' in it (example: "O'Leary"), the SQL that's generated throws an error.

To Reproduce

  1. Create a user in Firebase Auth with a displayName containing an apostrophe.
  2. Export that user to a list of users.
  3. Try to import that user with the import_users.js script
  4. See error

Expected behavior

Import works for names with apostrophes.

tylermcdonald avatar Apr 06 '24 23:04 tylermcdonald

I think adding a custom replacer to the JSON.stringify(user) of something like:

function replacer(key, value) {
    if (typeof value === 'string') {
        return value.replace(/'/g, "''");
    }
    return value;
}
...
JSON.stringify(user, replacer);

would work

tylermcdonald avatar Apr 06 '24 23:04 tylermcdonald