Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import text values as null instead of blank #61

Open
ebbauer opened this issue Feb 27, 2019 · 2 comments
Open

Import text values as null instead of blank #61

ebbauer opened this issue Feb 27, 2019 · 2 comments

Comments

@ebbauer
Copy link

ebbauer commented Feb 27, 2019

When importing data to a Postgres database use the copy command default behavior which is null values instead of blank ones.

For an experienced DBA, it is expected that the default value of a blank text field to be null because if you insert data on a table and do not specify any value as a default for that field the database is going to insert it as a null value.

quoting Postgres doc:
"If no default value is declared explicitly, the default value is the null value. This usually makes sense because a null value can be considered to represent unknown data." - https://www.postgresql.org/docs/current/ddl-default.html

@raginjason
Copy link

raginjason commented Sep 7, 2019

Given the following example:

foo,"",bar
foo,,bar

Would you consider the first record to have an empty string and the second to have null?

@ebbauer
Copy link
Author

ebbauer commented Sep 12, 2019

yes!

furthermore, we could have a parameter in cases like the first one where we would like it to be null. Something like --nullIf = "value" 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants