Page 1 of 1

clsql: foreign key not saved in database

Posted: Mon Apr 18, 2016 9:11 am
by andrei-n
I'm trying to make a small demo application with orm. I'm using postgresql and clsql with sbcl. When there is one table everything seems to work: I can insert new records and modify them, and also read if I modify the database manually. But when I try to make an object that points to another object and store it like a foreign key (to an existing line in a table), the foreign key is not inserted (I have a null value instead).

I tried to make an example similar to this: http://clsql.kpe.io/manual/def-view-class.html.

Is it possible to do what I'm trying to to with these tools? Do I need to override reader and writer methods to make it work?

Thank you.

Re: clsql: foreign key not saved in database

Posted: Wed Apr 20, 2016 3:55 pm
by robby_dobby
Hello,

I see that nobody replied to your post. From your post, it looks like you have an object hierarchy model that you want persisted into your database. This sounds suspiciously like a problem for ORMs to handle. Have a look at CLIKI - ORM for ORM libraries in CL.

In short, you have two options:
  1. * Straighten out your UPDATE/INSERT queries that they exactly reference the right tables and objects
    * Use an ORM