diogob / postgres-copy

Simple PostgreSQL's COPY command support in ActiveRecord models
MIT License
429 stars 64 forks source link

Carriage return and empty strings #49

Closed conradchu closed 5 years ago

conradchu commented 5 years ago

The current implementations parses on newlines and will not work with quoted values with carriage returns or empty strings.

To support carriage returns in quoted values: This PR implement a simple line buffer that terminates on EOL or EOF.

To support converting empty strings to NULL, this PR implements the FORCE_NULL option that Postgres 9.4 introduced.

diogob commented 5 years ago

thanks for the PR 👍 Could you check why travis is failing? There might be some issue with the postgresql version being used in the test environment since the error message mention the lack of a force_null option: ERROR: option "force_null" not recognized

conradchu commented 5 years ago

It's because force_null was introduced in Postgres 9.4+ (I mentioned that in the README modifications). How do you want to handle options supported in later Postgres versions? Though Postgres 9.4 is over 4-years old by now, so I suppose you need to draw the line somewhere.

diogob commented 5 years ago

@conradchu I wouldn't mind dropping support for previous versions, since 9.4 is the next one to be stop receiving updates. If you could update the travis configuration to run on a more recent version that would be perfect.

diogob commented 5 years ago

Thanks for the fix @conradchu