If column name is an SQL keyword, pgfutter fails with no error message
Using pgfutter_windows_amd64.exe binary on Windows 10, with CSV files edited in Notepad++ in UTF-8 encoding: I attempted to import a table which included a column named "Union" (for trade union), and pgfutter exited after printing out the column name list only, with no further message. By trial and error I figured out where the problem was, and also tested it by renaming the column to "test" (which worked) and then "select" (which didn't). If it was possible to catch invalid column names (and maybe prefix them with a '_') that would be great, but at the least it would be helpful if there was an error message, preferably identifying the rogue column name.
Looks like Postgres 11 SQL Keywords could be used as a reference for this.
@lukasmartinelli I see 3 possible solutions, in my personal order of preference:
- Quote column names that are reserved words
- Quote all column names
- Prefix/suffix column names that are reserved words
I like option 1 as it allows the table structure to remain in line with the file headers, which I think would be the expected behavior from a user. Option 2 is a bit of a shotgun/brute-force solution. Option 3 would absolutely work, but I think it's a non-obvious behavior from a user perspective. If you have a preferred solution, please let me know; I'd be happy to submit a pull request
Personally I don't have a problem with Option 3, after all column headers with spaces and capitals are amended to suit PG requirements. But I'm just really pleased that this excellent tool is being maintained again after a bit of a hiatus!