-
Notifications
You must be signed in to change notification settings - Fork 2
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
"ERROR: null value in column" when trying to insert into the database #8
Comments
I wonder if it could be related with https://github.com/donut-party/datapotato/wiki/database-integration#optional-define-a-get-inserted-method |
I also ran into this, because it seems that the documentation is a bit inaccurate here. What was working for me if I set the relations as namespace-qualified keywords. (def potato-schema
{:company {:prefix :c
:fixtures {:table-name "companies"}
:generate {:schema ::spec.company/complete}}
:user {:prefix :u
:fixtures {:table-name "users"}
:generate {:schema ::spec.user/complete}
:relations {:company_id [:company :companies/id]}}})
(defn potato-db [db]
{:schema potato-schema
:generate {:generator generator}
:fixtures (assoc dnj/config :dbspec db)})
(defn insert [db]
(dc/with-fixtures (potato-db db)
(dc/insert-fixtures {:user [{:count 3}]}))) I believe the reason is that |
I can verify that is the problem there. If you set a custom insert function that uses the |
Because you are using a separate schema, I guess it would be |
I just realized that the easiest option is to override the datapotato/datapotato-next-jdbc/src/donut/datapotato/next_jdbc.clj Lines 78 to 82 in 9e48138
|
So I'm just trying to insert data into the database using postgres and next.jdbc, but when it actually tries to write the data the values in the foreign key fields are always NULLS.
I thought it was related to my model but I get the same behaviour with the sample code from the README, it works fine for the mock db but not for a real Postgres db.
If I look at the output from
generate
I see that it's all correct, but not when I try to insert data, any idea why it could be wrong?The code is pretty much just this, I had to redefine
get-connection
, but I don't think that's the problem, it connects just fine it just seems to lose the data when trying to write out.The text was updated successfully, but these errors were encountered: