upsertMany for the mysql adaptor

@dsurrao , I’ve taken a quick look and there’s no upsertMany for mysqlcan we build this together?

I’ll reach out over email to set up a time where we can crack open devtools and get it done, but would love to keep as much of the technical back and forth and decision making here in the forum so others can get a sense of the process.

@Mamadou , what’s your advice on the best example of how to write an upsertMany function? I’m looking at your work here in postgres and here in mssql. For reference, here’s how upsert works in the mysql adaptor.

@taylordowns2000 I would say postgres is more similar to mysql than mssql so it’s best to take inspiration from it.

However, the adaptor for mysql have a greater abstraction on how queries are build using this function that generate the query : mysql.format(sql, inserts);

So it woul be interesting to see how it can generate multivalued queries for an upsertMany

1 Like

Hi @taylordowns2000 , happy to work on this together. Thanks for the tips @Mamadou !

Hi @taylordowns2000, @Mamadou I got devtools working, and created a version of upsertMany in my repo here.

It uses a subquery to handle multiple upserts, following MySQL documentation recommendations.

Thoughts?

1 Like

@dsurrao , this looks great. I noticed that the package.json for the main openfn/language-mysql repo was a bit outdated, so i’ve bumped a dependency to language-common and added the new formatting with the check-package-json command. It shouldn’t interfere with your work, but I would love it if you could either pull or rebase and check to see that all’s well.

If this works locally, the documentation is built properly when calling npm run build (btw, npm run build is now a replacement for make) and you’re happy with the setup, the best thing to do would be to open a pull request.

From there, we’ll get @stu and @Mamadou to take a look, make any suggestions, and merge it in!

@taylordowns2000 I pulled the changes and it works! Also, should the lib folder be in the .gitignore file for language-mysql?

Wonderful. Please keep lib in git. (So, don’t add it to .gitignore.) I might be confused about this, but I’m pretty sure it’s what allows the Github releases (with those tarballs) to work and we want to make sure we’re not dependent on npmjs.com for folks to be able to download and work with these adaptors.

If you’re curious about how this stuff eventually gets onto the platform, you can poke around the scripts in devtools. After a set of commits is made to main (or master) we run release . and package-release . from devtools, which check, build, bundle, and create releases on npm and github.

From there folks (or applications, like OpenFn/platform) can access the modules however they like.

Excited to see the PR!

Great, I just made the PR, thanks!