go-workflows
go-workflows copied to clipboard
Postgres backend
This looks super interesting for some projects I have in mind, but I mostly work in Postgres so I took a stab at implementing a backend with it. It's mostly a copy of the MySQL one with a few differences:
- Changed the params in queries from
?
to numbered params:$1
,$2
, etc- This led to some minor logic changes where you were previously able to build a query string with
n
number of arguments. I think it's mostly the same end result but open to feedback on it.
- This led to some minor logic changes where you were previously able to build a query string with
-
createInstance
seemed to rely on the behavior of the MySQL driver to return 0 as therowsAffected
if an update used the same values that already existed in the table. Postgres will always return 1 whether the values changed or not so I added aWHERE
clause to check for a NULL in the column that seemed to matter. - Added the tables in a
gwf
schema so the names don't interfere with existing tables if you want to share a DB. Not 100% sure on this one but it made sense at the time. - Changed the schema of the tables slightly, mostly switching BLOB to JSONB
- Changed the syntax around the previous
INSERT IGNORE
andSKIP LOCKED
to the PG equivalents - Added the ability to pass in an existing connection if you already have one
I'm fairly new to Go and still wrapping my head around the package system so I'm also not sure if the changes to go.mod
are valid or should be reverted a bit. Either way, all the tests seem to pass and I tried a bunch of the samples as well and it seems to work so let me know what you think.